Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn.model_selection import train_test_split
- X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) # 70% training and 30% test
- #Import Random Forest Model
- from sklearn.ensemble import RandomForestClassifier
- #Create a Gaussian Classifier
- clf=RandomForestClassifier(n_estimators=100)
- #Train the model using the training sets y_pred=clf.predict(X_test)
- clf.fit(X_train,y_train)
- y_pred=clf.predict(X_test)
- #Import scikit-learn metrics module for accuracy calculation
- from sklearn import metrics
- # Model Accuracy, how often is the classifier correct?
- print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement