Skip to content

Instantly share code, notes, and snippets.

@tcramm0nd
Created May 25, 2020 17:00
Show Gist options
  • Save tcramm0nd/29167fe860bef65416a2d884c8109386 to your computer and use it in GitHub Desktop.
Save tcramm0nd/29167fe860bef65416a2d884c8109386 to your computer and use it in GitHub Desktop.
Quick overview of how to use a Random Forest Classifier using Scitkit Learn
# A breif overview of how to create a Random Forest Classifier using Scikit-Learn. For a more detailed breakdown and
# an overview of what a Random Forest is, you can find the original post here: http://timcrammond.com/blog/what-is-random-forest/
from sklearn import datasets, metrics
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
wine = datasets.load_wine()
X = wine.data
y = wine.target
y = wine.target
random_forest = RandomForestClassifier(n_estimators=100)
random_forest.fit(X_train, y_train)
y_predict = random_forest.predict(X_test)
print(f'Our Random Forest Classifier is {metrics.accuracy_score(y_test, y_predict)} accurate')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment