4 Decision Tree - Jupyter Notebook
4 Decision Tree - Jupyter Notebook
...
...
In [23]: # Dividing the input and output variable for Training Dataset
X_train = iris_train.iloc[:,0:4]
X_train
y_train = iris_train.iloc[:,4]
y_train
...
...
In [9]: # X_train and X_test are the dataset for training and Testing
#y_train ,y_test are target predictor for Training and Testing Dataset
In [27]: # Fitting Decision Tree Classification to the Training set
# step 1 :import libraries and methods
from sklearn.tree import DecisionTreeClassifier
# step 2 : Create an alogrithm using imported methods
classifier = DecisionTreeClassifier(criterion = 'entropy')
# Step3 : applying algorithm on training dataset ( Xtrain , ytrain)
classifier.fit(X_train, y_train)
...
In [11]: # Predicting the Test set results by applying the algorithm only in input
#variables of testing dataset (xtest)
y_pred = classifier.predict(X_test)
#y_pred
...
In [14]: Accuracy_Score
Out[14]: 0.9466666666666667
In [ ]: