Decision tree classifier
The DecisionTtreeClassifier
from scikit-learn has been utilized for modeling purposes, which is available in the tree
submodule:
# Decision Tree Classifier
>>> from sklearn.tree import DecisionTreeClassifier
The parameters selected for the DT classifier are in the following code with splitting criterion as Gini, Maximum depth as 5, the minimum number of observations required for qualifying split is 2, and the minimum samples that should be present in the terminal node is 1:
>>> dt_fit = DecisionTreeClassifier(criterion="gini", max_depth=5,min_samples_split=2, min_samples_leaf=1,random_state=42)
>>> dt_fit.fit(x_train,y_train)
>>> print ("\nDecision Tree - Train Confusion Matrix\n\n", pd.crosstab(y_train, dt_fit.predict(x_train),rownames = ["Actuall"],colnames = ["Predicted"]))
>>> from sklearn.metrics import accuracy_score, classification_report
>>> print ("\nDecision Tree - Train accuracy\n\n",round...