import numpy as nm
import matplotlib.pyplot as mtp
import pandas as pd
data_set= pd.read.csv('/content/user_data_deci_tree.csv')
x= data_set.iloc[:, (2,3)].values
y= data_set.iloc[:, 4].values
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test= train_test_split(x, y, test_size= 0.2
5)
from sklearn.preprocessing import StandardScaler
st_x= StandardScaler()
x_train= st_x.fit_transform(x_train)
x_test= st_x.transform(x_test)
from sklearn.tree import DecisionTreeClassifier
classifier= DecisionTreeClassifier(criterion='entropy', random_state=0)
classifier.fit(x_train, y_train)
#DecisionTreeClassifier(class_weight=None, criterion='entropy', max_dep
th=None,
max_features=None, max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, presort=False,
random_state=0, splitter='best')
y_pred= classifier.predict(x_test)
From sklearn.metrics import confusion_matrix
cm= confusion_matrix(y_test, y_pred)
cm
from sklearn import tree
fig, ax = plt.subplots(figsize=(10, 10)) #figsize value changes the siz
e of plot
tree.plot_tree(classifier,ax=ax,feature_names=['Age','EstimatedSalary']
,fontsize=6)
plt.show()