Decision Tree - Jupyter Notebook
Decision Tree - Jupyter Notebook
import Libraries
In [9]: # Import necessary libraries
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score, classification_report
0 25 Low 600 No No
4 23 Low 580 No No
7 28 Low 590 No No
9 33 Low 620 No No
0 25 1 600 0 0
1 45 0 700 1 1
2 35 2 650 0 1
3 50 0 720 1 1
4 23 1 580 0 0
5 40 2 660 1 1
6 30 0 680 1 1
7 28 1 590 0 0
8 55 0 740 1 1
9 33 1 620 0 0
In [21]: # Split the dataset into training and testing sets (80% train, 20% tes
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.
Out[23]: DecisionTreeClassifier(random_state=42)
In a Jupyter environment, please rerun this cell to show the HTML representation or
trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page
with nbviewer.org.
Accuracy: 100.00%
Classification Report:
precision recall f1-score support
accuracy 1.00 2
macro avg 1.00 1.00 1.00 2
weighted avg 1.00 1.00 1.00 2
In [ ]: