Decision tree models
We will work with the heart disease data again in this chapter. This will be a great way to compare our results from the logistic regression model to those of a non-parametric model such as a decision tree. Follow these steps:
- First, we load the same libraries that we have been using so far. The new modules are
DecisionTreeClassifier
from scikit-learn andSMOTENC
from Imbalance Learn, which will help us deal with imbalanced data:import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import OneHotEncoder from imblearn.pipeline import make_pipeline from sklearn.compose import ColumnTransformer from sklearn.model_selection import RandomizedSearchCV from imblearn.over_sampling import SMOTENC from sklearn.tree import DecisionTreeClassifier, plot_tree from scipy.stats import randint import sklearn.metrics as skmet import os import sys sys.path.append(os.getcwd() + "/helperfunctions") from...