Partial Dependence Plots
Another tool that is model-agnostic is a partial dependence plot. It is a visual tool for analyzing the effect of a feature on the target variable. To achieve this, we can plot the values of the feature we are interested in analyzing on the x
-axis and the target variable on the y
-axis and then show all the observations from the dataset on this graph. Let's try it on the Breast Cancer dataset from sklearn
:
from sklearn.datasets import load_breast_cancer import pandas as pd data = load_breast_cancer() df = pd.DataFrame(data.data, columns=data.feature_names)
Now that we have loaded the data and converted it to a DataFrame, let's have a look at the worst concave points column:
import altair as alt alt.Chart(df).mark_circle(size=60).encode( x='worst concave points', y='target' )
From this plot, we can see:
- Most...