Plots¶
causeinfer plots provide graphical representations of model performance.
Functions
- causeinfer.evaluation.plot_eval(df, kind=None, n=100, percent_of_pop=False, normalize=False, figsize=(15, 5), fontsize=20, axis=None, legend_metrics=None, *args, **kwargs)[source]¶
Plots one of the effect/gain/qini charts of model estimates.
- Parameters:
- dfpandas.DataFrame
A data frame with model estimates and unit outcomes as columns.
- kindstroptional (default=’gain’)
The kind of plot to draw: ‘effect,’ ‘gain,’ and ‘qini’ are supported.
- nint, optional (default=100)
The number of samples to be used for plotting.
- percent_of_popbooloptional (default=False)
Whether the X-axis is displayed as a percent of the whole population.
- normalizeboolfor inheritance (default=False)
Passes this argument to interior functions directly.
- figsizetupleoptional
Allows for quick changes of figures sizes.
- fontsizeint or floatoptional (default=20)
The font size of the plots, with all labels scaled accordingly.
- axisstroptional (default=None)
Adds an axis to the plot so they can be combined.
- legend_metricsbooloptional (default=True)
Calculate AUUC or Qini metrics to add to the plot legend for gain and qini respectively.
- causeinfer.evaluation.plot_cum_effect(df, n=100, models=None, percent_of_pop=False, outcome_col='y', treatment_col='w', treatment_effect_col='tau', random_seed=None, figsize=None, fontsize=20, axis=None, legend_metrics=None)[source]¶
Plots the causal effect chart of model estimates in cumulative population.
- Parameters:
- dfpandas.DataFrame
A data frame with model estimates and actual data as columns.
- kindeffect
The kind of plot to draw
- nint, optional (default=100)
The number of samples to be used for plotting.
- modelslist
A list of models corresponding to estimated treatment effect columns.
- percent_of_popbooloptional (default=False)
Whether the X-axis is displayed as a percent of the whole population.
- outcome_colstroptional (default=y)
The column name for the actual outcome.
- treatment_colstroptional (default=w)
The column name for the treatment indicator (0 or 1).
- treatment_effect_colstroptional (default=tau)
The column name for the true treatment effect.
- random_seedint, optional (default=None)
Random seed for numpy.random.rand().
- figsizetupleoptional
Allows for quick changes of figures sizes.
- fontsizeint or floatoptional (default=20)
The font size of the plots, with all labels scaled accordingly.
- axisstroptional (default=None)
Adds an axis to the plot so they can be combined.
- legend_metricsbooloptional (default=False)
Not supported for plot_cum_effect - the user will be notified.
- Returns:
- A plot of the cumulative effects of all models in df.
- causeinfer.evaluation.plot_cum_gain(df, n=100, models=None, percent_of_pop=False, outcome_col='y', treatment_col='w', treatment_effect_col='tau', normalize=False, random_seed=None, figsize=None, fontsize=20, axis=None, legend_metrics=True)[source]¶
Plots the cumulative gain chart (or uplift curve) of model estimates.
- Parameters:
- dfpandas.DataFrame
A data frame with model estimates and actual data as columns.
- kindgain
The kind of plot to draw
- nint, optional (default=100)
The number of samples to be used for plotting.
- modelslist
A list of models corresponding to estimated treatment effect columns.
- percent_of_popbooloptional (default=False)
Whether the X-axis is displayed as a percent of the whole population.
- outcome_colstroptional (default=y)
The column name for the actual outcome.
- treatment_colstroptional (default=w)
The column name for the treatment indicator (0 or 1).
- treatment_effect_colstroptional (default=tau)
The column name for the true treatment effect.
- normalizebooloptional (default=False)
Whether to normalize the y-axis to 1 or not.
- random_seedint, optional (default=None)
Random seed for numpy.random.rand().
- figsizetupleoptional
Allows for quick changes of figures sizes.
- fontsizeint or floatoptional (default=20)
The font size of the plots, with all labels scaled accordingly.
- axisstroptional (default=None)
Adds an axis to the plot so they can be combined.
- legend_metricsbooloptional (default=True)
Calculates AUUC metrics to add to the plot legend.
- Returns:
- A plot of the cumulative gains of all models in df.
- causeinfer.evaluation.plot_qini(df, n=100, models=None, percent_of_pop=False, outcome_col='y', treatment_col='w', treatment_effect_col='tau', normalize=False, random_seed=None, figsize=None, fontsize=20, axis=None, legend_metrics=True)[source]¶
Plots the Qini chart (or uplift curve) of model estimates.
- Parameters:
- dfpandas.DataFrame
A data frame with model estimates and actual data as columns.
- kindqini
The kind of plot to draw
- nint, optional (default=100)
The number of samples to be used for plotting.
- modelslist
A list of models corresponding to estimated treatment effect columns.
- percent_of_popbooloptional (default=False)
Whether the X-axis is displayed as a percent of the whole population.
- outcome_colstroptional (default=y)
The column name for the actual outcome.
- treatment_colstroptional (default=w)
The column name for the treatment indicator (0 or 1).
- treatment_effect_colstroptional (default=tau)
The column name for the true treatment effect.
- normalizebooloptional (default=False)
Whether to normalize the y-axis to 1 or not.
- random_seedint, optional (default=None)
Random seed for numpy.random.rand().
- figsizetupleoptional
Allows for quick changes of figures sizes.
- fontsizeint or floatoptional (default=20)
The font size of the plots, with all labels scaled accordingly.
- axisstroptional (default=None)
Adds an axis to the plot so they can be combined.
- legend_metricsbooloptional (default=True)
Calculates Qini metrics to add to the plot legend.
- Returns:
- A plot of the qini curves of all models in df.
- causeinfer.evaluation.plot_batch_metrics(df, kind=None, n=10, models=None, outcome_col='y', treatment_col='w', normalize=False, figsize=(15, 5), fontsize=20, axis=None, *args, **kwargs)[source]¶
Plots the batch chart: the cumulative batch metrics predicted by a model given ranked treatment effects.
- Parameters:
- dfpandas.DataFrame
A data frame with model estimates and unit outcomes as columns.
- kindstroptional (default=’gain’)
The kind of plot to draw: ‘effect,’ ‘gain,’ ‘qini,’ and ‘response’ are supported.
- nint, optional (default=10, deciles; 20, quintiles also standard)
The number of batches to split the units into.
- modelslist
A list of models corresponding to estimated treatment effect columns.
- outcome_colstroptional (default=y)
The column name for the actual outcome.
- treatment_colstroptional (default=w)
The column name for the treatment indicator (0 or 1).
- figsizetupleoptional
Allows for quick changes of figures sizes.
- fontsizeint or floatoptional (default=20)
The font size of the plots, with all labels scaled accordingly.
- axisstroptional (default=None)
Adds an axis to the plot so they can be combined.
- Returns:
- A plot of batch metrics of all models in df.
- causeinfer.evaluation.plot_batch_responses(df, n=10, models=None, outcome_col='y', treatment_col='w', normalize=False, figsize=(15, 5), fontsize=20, axis=None)[source]¶
Plots the batch response chart: the cumulative batch responses predicted by a model given ranked treatment effects.
- Parameters:
- dfpandas.DataFrame
A data frame with model estimates and unit outcomes as columns.
- kindresponse
The kind of plot to draw
- nint, optional (default=10, deciles; 20, quintiles also standard)
The number of batches to split the units into.
- modelslist
A list of models corresponding to estimated treatment effect columns.
- outcome_colstroptional (default=y)
The column name for the actual outcome.
- treatment_colstroptional (default=w)
The column name for the treatment indicator (0 or 1).
- figsizetupleoptional
Allows for quick changes of figures sizes.
- fontsizeint or floatoptional (default=20)
The font size of the plots, with all labels scaled accordingly.
- axisstroptional (default=None)
Adds an axis to the plot so they can be combined.
- Returns:
- A plot of batch responses of all models in df.