scikit-learn 1 · Training models

Train and predict

Every estimator has fit and predict. Train on the training set, then predict labels for new rows.

from sklearn.ensemble import RandomForestClassifier

clf = RandomForestClassifier(n_estimators=200, random_state=42)
clf.fit(X_train, y_train)
predictions = clf.predict(X_test)

Official scikit-learn 1 documentation

More training models commands

All training models commands · scikit-learn 1 cheatsheet

Was this page helpful?