pdstools.adm.Plots._binning¶
Predictor binning visualisations and lift charts.
Classes¶
Common attribute surface used by every plot mixin. |
Module Contents¶
- class _BinningPlotsMixin¶
Bases:
pdstools.adm.Plots._base._PlotsBaseCommon attribute surface used by every plot mixin.
- predictor_binning(model_id: str, predictor_name: str, return_df: bool = False)¶
Generate a predictor binning plot for a specific model and predictor.
- Parameters:
- Returns:
Plotly figure showing predictor binning or DataFrame if return_df=True
- Return type:
Union[Figure, pl.LazyFrame]
- Raises:
ValueError – If no data is available for the provided model ID and predictor name
Examples
>>> # Predictor binning for a single predictor on a model >>> fig = dm.plot.predictor_binning( ... model_id="M-1001", ... predictor_name="Customer.Age", ... )
>>> # Retrieve the underlying binning data >>> df = dm.plot.predictor_binning( ... model_id="M-1001", ... predictor_name="Customer.Age", ... return_df=True, ... )
- multiple_predictor_binning(model_id: str, query: pdstools.utils.types.QUERY | None = None, show_all=True) list[pdstools.utils.plot_utils.Figure]¶
Generate predictor binning plots for all predictors in a model.
- Parameters:
- Returns:
A list of Plotly figures, one for each predictor in the model
- Return type:
Examples
>>> # Plot binning for every predictor in a model >>> figs = dm.plot.multiple_predictor_binning(model_id="M-1001")
>>> # Collect figures without displaying, filtered to IH predictors >>> figs = dm.plot.multiple_predictor_binning( ... model_id="M-1001", ... query={"PredictorCategory": "IH"}, ... show_all=False, ... )
- binning_lift(model_id: str, predictor_name: str, *, query: pdstools.utils.types.QUERY | None = None, return_df: bool = False)¶
Generate a binning lift plot for a specific predictor showing propensity lift per bin.
- Parameters:
model_id (str) – The ID of the model containing the predictor
predictor_name (str) – Name of the predictor to analyze for lift
query (Optional[QUERY], optional) – Optional query to filter the predictor data, by default None
return_df (bool, optional) – Whether to return a dataframe instead of a plot, by default False
- Returns:
Plotly bar chart showing binning lift or DataFrame if return_df=True
- Return type:
Union[Figure, pl.LazyFrame]
Examples
>>> # Lift chart for a single predictor on a model >>> fig = dm.plot.binning_lift( ... model_id="M-1001", ... predictor_name="Customer.Age", ... )
>>> # Return the lift data for further analysis >>> df = dm.plot.binning_lift( ... model_id="M-1001", ... predictor_name="Customer.Age", ... return_df=True, ... )