Skip to content

pdp.isolate for multiple class(>2) feature column #94

@fuhsiao

Description

@fuhsiao

I checked /tutorials/pdpbox_binary_classification.ipynb and saw PDPisolate for the feature 'Sex',
but that is for binary feature. If I want to plot pdp.isolate for a multi-class feature like 'Pclass', is that possible?
I did a simple test, but the axis labels did not change correctly
and plot_pts_dist=True doesn't seem to work either.

Can someone share how to plot PDP isolation graphs for features with more than 2 classes? Thank you!

pdp_pclass = pdp.PDPIsolate(
    model=titanic_model,
    df=titanic_data,
    model_features=titanic_features,
    feature="Pclass",
    feature_name="Pclass",
)

fig, axes = pdp_pclass.plot(
    center=False,
    plot_lines=True,
    frac_to_plot=100,
    cluster=False,
    n_cluster_centers=None,
    cluster_method='accurate',
    plot_pts_dist=True,
    to_bins=False,
    show_percentile=False,
    which_classes=None,
    figsize=None,
    dpi=300,
    ncols=3,
    plot_params={"pdp_hl": True},
    engine='plotly',
    template='plotly_white',
)

fig.update_xaxes(ticktext=["p1", "p2", "p3"], row=3, col=1)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions