Created
May 25, 2020 17:00
Quick overview of how to use a Random Forest Classifier using Scitkit Learn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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