pdpbox.info_plots.InteractPredictPlot¶
- class pdpbox.info_plots.InteractPredictPlot(df, features, feature_names, model, model_features, pred_func=None, n_classes=None, predict_kwds=None, chunk_size=-1, num_grid_points=10, grid_types='percentile', percentile_ranges=None, grid_ranges=None, cust_grid_points=None, show_outliers=False, endpoints=True)¶
PredictPlot for interaction between two features.
- Attributes:
- dfpd.DataFrame
A processed DataFrame that includes feature and target (for target plot) or predict (for predict plot) columns, feature buckets, along with the count of samples within each bucket.
- feature_infoslist of
FeatureInfo
A list of FeatureInfo objects.
- feature_colslist of str
List of feature columns.
- targetlist of int
List of target indices. For binary and regression problems, the list will be just [0]. For multi-class targets, the list is the class indices.
- n_classesint
The number of classes provided, or inferred from the model when it is not provided.
- plot_typestr
The type of the plot to be generated.
- plot_enginesdict
A dictionary that maps plot types to their plotting engines.
- summary_dfpd.DataFrame
A DataFrame that contains the summary statistics of target (for target plot) or predict (for predict plot) values for each feature bucket.
- plot_dfpd.DataFrame
A DataFrame that contains the aggregated target (for target plot) or predict (for predict plot) values for each unique pair of feature values.
Methods
plot(**kwargs)
Generates the plot.
Both pdpbox.info_plots.InteractTargetPlot
and pdpbox.info_plots.InteractPredictPlot
inherit from pdpbox.info_plots._InteractInfoPlot
class and share the same plot
method.
- class pdpbox.info_plots._InteractInfoPlot(df, features, feature_names, target=None, model=None, model_features=None, pred_func=None, n_classes=None, predict_kwds=None, chunk_size=-1, plot_type='interact_target', **kwargs)¶
Methods
plot
([which_classes, show_percentile, ...])Generate the interaction plot.
- plot(which_classes=None, show_percentile=False, figsize=None, dpi=300, ncols=2, annotate=False, plot_params=None, engine='plotly', template='plotly_white')¶
Generate the interaction plot.
- Parameters:
- which_classeslist of int, optional
List of class indices to plot. If None, all classes will be plotted. Default is None.
- show_percentilebool, optional
If True, percentiles are shown in the plot. Default is False.
- figsizetuple or None, optional
The figure size for matplotlib or plotly figure. If None, the default figure size is used. Default is None.
- dpiint, optional
The resolution of the plot, measured in dots per inch. Only applicable when engine is ‘matplotlib’. Default is 300.
- ncolsint, optional
The number of columns of subplots in the figure. Default is 2.
- annotatebool, optional
If it is True, the circles on the plot will be annotated with detailed information. Default is False.
- plot_paramsdict or None, optional
Custom plot parameters that control the style and aesthetics of the plot. Default is None.
- engine{‘matplotlib’, ‘plotly’}, optional
The plotting engine to use. Default is plotly.
- templatestr, optional
The template to use for plotly plots. Only applicable when engine is ‘plotly’. Reference: https://plotly.com/python/templates/ Default is plotly_white.
- Returns:
- matplotlib.figure.Figure or plotly.graph_objects.Figure
A Matplotlib or Plotly figure object depending on the plot engine being used.
- dict of matplotlib.axes.Axes or None
A dictionary of Matplotlib axes objects. The keys are the names of the axes. The values are the axes objects. If engine is ‘ploltly’, it is None.
- pd.DataFrame
A DataFrame that contains the summary statistics of target (for target plot) or predict (for predict plot) values for each feature bucket.