Model Pipeline - Decision tree classifier
A decision tree classifier is a simple model that splits data step-by-step based on feature values to decide the class of new data points. It works like a flowchart of yes/no questions leading to a decision.
A decision tree classifier is a simple model that splits data step-by-step based on feature values to decide the class of new data points. It works like a flowchart of yes/no questions leading to a decision.
Loss
0.5 |****
0.4 |***
0.3 |**
0.2 |*
0.1 |
+----
1 2 3 4 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.45 | 0.8 | Initial tree with few splits, moderate accuracy |
| 2 | 0.3 | 0.88 | More splits added, accuracy improves |
| 3 | 0.2 | 0.92 | Tree fits training data better, loss decreases |
| 4 | 0.15 | 0.95 | Final tree with good balance, high accuracy |
Decision Tree Classifier in machine learning?X_test = [[5, 3]]?
from sklearn.tree import DecisionTreeClassifier X_train = [[2, 3], [10, 15], [6, 8], [1, 1]] y_train = [0, 1, 1, 0] model = DecisionTreeClassifier(max_depth=2) model.fit(X_train, y_train) print(model.predict(X_test))
from sklearn.tree import DecisionTreeClassifier model = DecisionTreeClassifier(max_depth=-1) model.fit(X_train, y_train)
Pass the test and this pattern moves unknown