Advertisement
gk231192

Module 9.2 Decision Tree

Jul 3rd, 2025
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. # 4. Decision Tree
  2. # What it does: Creates a tree where each split is a question about a feature. Easy to visualize.
  3. # Use Case: Medical diagnosis, loan approval.
  4.  
  5. from sklearn.tree import DecisionTreeClassifier
  6.  
  7. dt = DecisionTreeClassifier(random_state=42)
  8. dt.fit(X_train, y_train)
  9. y_pred = dt.predict(X_test)
  10.  
  11. print("Decision Tree Confusion Matrix:\n", confusion_matrix(y_test, y_pred))
  12. print("\nDecision Tree Classification Report:\n", classification_report(y_test, y_pred))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement