Exploring breast cancer traits using Decision Trees
Next, we will discuss exploratory analysis based on Decision Trees. Decision trees are a set of rules that classify our data – they may sound simple at first, but they can be very powerful. The big advantage of Decision Trees is that they will give us the rules that constructed the decision tree, providing some understanding of what is going on with our data.
Getting ready
We’ll use the sklearn Breast Cancer dataset as before. The code for this recipe can be found in Ch04/Ch04-4-decision-trees.ipynb.
How to do it...
- First, we’ll import our libraries:
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier, plot_tree
from sklearn.metrics import (
accuracy_score,
confusion_matrix,
classification_report,
precision_score,
recall_score,
f1_score
)
import matplotlib.pyplot as plt
import seaborn as...