Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. from sklearn.model_selection import train_test_split
  2. X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) # 70% training and 30% test
  3.  
  4. #Import Random Forest Model
  5. from sklearn.ensemble import RandomForestClassifier
  6.  
  7. #Create a Gaussian Classifier
  8. clf=RandomForestClassifier(n_estimators=100)
  9.  
  10. #Train the model using the training sets y_pred=clf.predict(X_test)
  11. clf.fit(X_train,y_train)
  12.  
  13. y_pred=clf.predict(X_test)
  14.  
  15. #Import scikit-learn metrics module for accuracy calculation
  16. from sklearn import metrics
  17. # Model Accuracy, how often is the classifier correct?
  18. print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement