Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 4. Decision Tree
- # What it does: Creates a tree where each split is a question about a feature. Easy to visualize.
- # Use Case: Medical diagnosis, loan approval.
- from sklearn.tree import DecisionTreeClassifier
- dt = DecisionTreeClassifier(random_state=42)
- dt.fit(X_train, y_train)
- y_pred = dt.predict(X_test)
- print("Decision Tree Confusion Matrix:\n", confusion_matrix(y_test, y_pred))
- print("\nDecision Tree Classification Report:\n", classification_report(y_test, y_pred))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement