SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top