text_plain_output_1.png
from sklearn.metrics import accuracy_score, confusion_matrix, classification_report

from sklearn.model_selection import GridSearchCV

from sklearn.tree import DecisionTreeClassifier

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data = pd.read_csv('../input/disease/Disease.csv')

from sklearn.tree import DecisionTreeClassifier
tree_clf = DecisionTreeClassifier(random_state=0)
tree_clf.fit(X_train, y_train)

test_score = accuracy_score(y_test, tree_clf.predict(X_test)) * 100
train_score = accuracy_score(y_train, tree_clf.predict(X_train)) * 100
results_df = pd.DataFrame(data=[['Decision Tree Classifier', train_score, test_score]], columns=['Model', 'Training Accuracy %', 'Testing Accuracy %'])
results_df

pred = tree_clf.predict(X_train)
tree_clf_report = pd.DataFrame(classification_report(y_train, pred, output_dict=True))

params = {'criterion': ('gini', 'entropy'), 'splitter': ('best', 'random'), 'max_depth': list(range(1, 20)), 'min_samples_split': [2, 3, 4], 'min_samples_leaf': list(range(1, 20))}
tree_clf = DecisionTreeClassifier(random_state=0)
tree_cv = GridSearchCV(tree_clf, params, scoring='accuracy', n_jobs=-1, verbose=1, cv=3, iid=True)
tree_cv.fit(X_train, y_train)
best_params = tree_cv.best_params_
print(f'Best_params: {best_params}')
tree_clf = DecisionTreeClassifier(**best_params)
tree_clf.fit(X_train, y_train)