Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 5. Random Forest
- # What it does: Combines many decision trees. Each tree votes, and the most common vote wins.
- # Use Case: Credit scoring, fraud detection.
- from sklearn.ensemble import RandomForestClassifier
- rf = RandomForestClassifier(n_estimators=100, random_state=42)
- rf.fit(X_train, y_train)
- y_pred = rf.predict(X_test)
- print("Random Forest Confusion Matrix:\n", confusion_matrix(y_test, y_pred))
- print("\nRandom Forest Classification Report:\n", classification_report(y_test, y_pred))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement