3.P5 Training a Random Forest and Predicting
[video] /api/lesson-media/videos/9b417aa2-5e9f-4ae3-a9db-2a3b7f03f372-1794878471116-e38392d7bc0e8501.mp4
[markdown] content available only on the platform
[markdown] content available only on the platform
Flashcards · 3.P5 Training a Random Forest and Predicting
RandomForestClassifier — scikit-learn's Random Forest for classification problems.
model = RandomForestClassifier(random_state=100)
fit() — Trains a model on features and their true labels.
model.fit(x_train, y_train)
predict() — Returns one predicted label for each row of the input features.
y_pred = model.predict(x_test)
Ground truth — The true labels that predictions are compared against; also called label or target.
y_test
y_pred — The array of labels the model predicts for the test set.
154 values of 0 or 1.
classification_report() — Builds precision, recall, F1 and support per class from true and predicted labels.
classification_report(y_test, y_pred)
output_dict=True — Makes classification_report return a dictionary instead of text, so it can be shown as a table.
pd.DataFrame(report).transpose()
Create-fit-predict pattern — The standard sequence for every scikit-learn model.
model = ...; model.fit(...); model.predict(...)
