Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn.ensemble import RandomForestClassifier
- # Initialize a classifier object with default params
- classifier = RandomForestClassifier()
- classifier.fit(X_train, y_train)
- # Make predictions using both train and test set
- rf_train_pred = classifier.predict(X_train)
- rf_test_pred = classifier.predict(X_test)
- training_score = classifier.score(X_train, y_train)
- test_score = classifier.score(X_test, y_test)
- print("Has a training accuracy of {} % ".format(round(training_score.mean(), 5) * 100))
- print("Has a test accuracy of {} % ".format(round(test_score.mean(), 5) * 100))
- # The accuracy score on its own is less useful for classification. Need to check the confusion matrix
- # Notice how severe the overfitting is
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement