Skip to content

Instantly share code, notes, and snippets.

@Lakshmi-1212
Created February 21, 2021 11:22
Show Gist options
  • Save Lakshmi-1212/b343c1109ac59d8f7b2026447f43f0f1 to your computer and use it in GitHub Desktop.
Save Lakshmi-1212/b343c1109ac59d8f7b2026447f43f0f1 to your computer and use it in GitHub Desktop.
Random Forest Classifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import r2_score
# Create a random forest classifier and fit the training data
rfmodel = RandomForestClassifier().fit(X_train, y_train)
# Predict the values on the test dataset using sklearn
y_pred_rf = rfmodel.predict(X_test)
r2_score(y_test, y_pred_rf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment