Created
December 26, 2021 16:37
-
-
Save yashprakash13/ba73e8596be049b1ba072e59cffeb901 to your computer and use it in GitHub Desktop.
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
# MODEL Pipeline | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.metrics import confusion_matrix, accuracy_score | |
import matplotlib.pyplot as plt | |
# random forest classifier | |
rf_classifier = RandomForestClassifier(n_estimators = 11, criterion='entropy', random_state=0) | |
rf_model_pipeline = Pipeline(steps=[ | |
('preprocessing', columns_transformer), | |
('rf_model', rf_classifier), | |
]) | |
rf_model_pipeline.fit(X_train, y_train) | |
# predict on test set | |
y_pred = rf_model_pipeline.predict(X_test) | |
# calculate accuracy | |
ac = accuracy_score(y_test, y_pred) | |
print(f"Accuracy= {ac}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment