Decision Tree On Laptop Dataset
Decision Tree On Laptop Dataset
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
from sklearn.preprocessing import LabelEncoder
from sklearn.tree import plot_tree
import matplotlib.pyplot as plt
In [2]: df = pd.read_csv('laptops.csv')
df.head()
Out[2]: Storage Final
Laptop Status Brand Model CPU RAM Storage GPU Screen Touch
type Price
MSI Katana GF66 12UC-082XES Intel Core i7- Intel Core RTX
3 New MSI Katana 16 1000 SSD 15.6 No 1199.00
1270... i7 3050
# Split the data into features (X) and target variable (y)
X = df.drop(columns=['Status'])
y = df['Status']
df.head()
Out[14]: Final Brand_Deep GPU_Radeon GPU_T GPU_T GPU
Status RAM Storage Screen Brand_Acer Brand_Alurin Brand_Apple Brand_Asus ...
Price Gaming RX 6600M 1000 1200 20
0 New 8 512 15.6 1009.00 False False False True False ... False False False Fa
1 New 8 256 15.6 299.00 False True False False False ... False False False Fa
2 New 8 256 15.6 789.00 False False False True False ... False False False Fa
3 New 16 1000 15.6 1199.00 False False False False False ... False False False Fa
4 New 16 512 15.6 669.01 False False False False False ... False False False Fa
Confusion Matrix:
[[260 43]
[ 42 87]]
In [ ]:
In [ ]:
Loading [MathJax]/jax/output/CommonHTML/fonts/TeX/fontdata.js