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...
Here are the steps to try this recipe:
- 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...