cyclic_boosting.plots package#
Submodules#
cyclic_boosting.plots.plot_utils module#
- cyclic_boosting.plots.plot_utils.add_missing_values_box(ax, nan_value=None, nan_uncert=None, nan_count=None)[source]#
Adds a Neurobayes analysis-plot-style box to plot axes indicating the corresponding value for NaN-data.
The function assumes that there is free space to the right of the plot. It was originally designed to fit the NaN-box between a 2-D
matplotlib.pyplot.imshow()
plot and its colorbar (see example below).- Parameters:
ax (matplotlib.axes.Axes) – The axes object corresponding to the plot to which the nan box should be added
nan_value (float) – A value to be displayed in the NaN box
nan_uncert (float) – If not None, uncertainty that will be printed as plusminus deviation
- Returns:
axes object of the NaN-box
- Return type:
matplotlib.axes.Axes
- cyclic_boosting.plots.plot_utils.append_extension(file, extension)[source]#
Small helper method to append possibly missing extension to a file name.
Only works on instances of basestring. Leaves all other objects unchanged
- Parameters:
file (any object) –
extension (str) – extension (including ‘.’) to be appended to file
- Returns:
result
- Return type:
object of same type as file
- cyclic_boosting.plots.plot_utils.blue_cyan_green_cmap()[source]#
Colormap from blue over cyan to green
- Return type:
matplotlib.colors.LinearSegmentedColormap
- cyclic_boosting.plots.plot_utils.calc_extent_with_missing_values_box(xmin, xmax)[source]#
Calculates new extent of a plot when a missing values box is added
- Parameters:
xmin (float) – minimum x-limit of the original plot
xmax (float) – maximum x-limit of the original plot
- Returns:
tuple of x-coordinates for the middle and the right edge of the box (the left edge is already given by xmax)
- Return type:
(float, float)
- cyclic_boosting.plots.plot_utils.colorful_histogram(ax, x, bin_boundaries, cmap)[source]#
Plot a histogram on a given matplotlib axis ax for to-be-binned values x with bin boundaries
bin_boundaries
(is passed tonp.histogram
). Each bin column is colored using the map provided bycmap
.
- cyclic_boosting.plots.plot_utils.fill_missing_values_box(ax, xmax, xmin, ymin, ymax)[source]#
Fill the yellow area and return x coordinates for the missing values box.
- Parameters:
ax (matplotlib.axes.Axes) – axes object into which the missing values box will be drawn
xmax (float) – maximum x-limit of the axes
xmin (float) – minimum x-limit of the axes
ymin (float) – minimum y-limit of the axes
ymax (float) – maximum y-limit of the axes
Note
Be careful of the unintuitive order of the parameters.
- Returns:
tuple of x-coordinates for the middle and the right edge of the box (the left edge is already given by xmax)
- Return type:
(float, float)
- cyclic_boosting.plots.plot_utils.nbpy_style_context()#
Activate nbpy’s Matplotlib style default settings locally.
Module contents#
Plots for the Cyclic Boosting family
- cyclic_boosting.plots.plot_analysis(plot_observer, file_obj, binners=None, figsize=(11.69, 8.27), use_tightlayout=True, plot_yp=True)[source]#
Plot factors as a multipage PDF, also include plots for Loss and factor change behaviour and an insample diagonal plot.
- Parameters:
plot_observer (
PlottingObserver
) – A fitted plotting observer.file (string or file-like) – If a string indicates the name of the file, to which the plots are written. The ending ‘.pdf’ is added if it is not present already. You may also pass a file-like object.
binners (list) – A list of binners. If binners are given the labels of the x-axis of factor plots are better interpretable.
figsize (tuple) – A tuple with length containing the width and height of the figures.
use_tightlayout (bool) – If true the tightlayout option of matplotlib is used.
- cyclic_boosting.plots.plot_factor_1d(feature, bin_bounds=None, with_errorbars=True, ylimits_include_errors=True, link_function=None, plot_yp=True)[source]#
Plots a single one dimensional factor plot.
- Parameters:
bin_bounds (list) – Bin boundaries to label the bins.
feature (cyclic_boosting.base.Feature) – Feature as it can be obtained from the plotting observers
features
property.link_function (cyclic_boosting.link.LinkFunction) – Link function of the plotted feature
with_errorbars (bool) – Option to switch errorbars on/off.
ylimits_include_errors (bool) – Option to show the errorbars in the plot completely.
plot_yp (bool) – Show deviation between truth and prediction in last iteration.
- cyclic_boosting.plots.plot_factor_2d(n_bins_finite, feature, grid_item=None)[source]#
Plots a single two dimensional factor plot. For an example see the cyclic_boosting_analysis_plots
- Parameters:
n_bins_finite (int) – Number of finite bins
feature (cyclic_boosting.base.Feature) – Feature as it can be obtained from the plotting observers
features
property.grid_item (
matplotlib.gridspec.SubplotSpec
) – If the plot should be imbedded into a larger grid.
- cyclic_boosting.plots.plot_factor_change(plot_observer)[source]#
Plot the global factor changes for all iterations.
- Parameters:
plot_observer (
PlottingObserver
) – A fitted plotting observer.
- cyclic_boosting.plots.plot_factor_high_dim(feature)#
Plots a histogram of the given factors with a logarithmic y-axis.
- Parameters:
feature (cyclic_boosting.base.Feature) – Feature object from as it can be obtained from a plotting observer
- cyclic_boosting.plots.plot_factor_histogram(feature)[source]#
Plots a histogram of the given factors with a logarithmic y-axis.
- Parameters:
feature (cyclic_boosting.base.Feature) – Feature object from as it can be obtained from a plotting observer
- cyclic_boosting.plots.plot_factors(plot_observer, binners=None, feature_groups_or_ids=None, features_per_row=2, use_tightlayout=True, plot_yp=True)[source]#
Create a matplotlib figure containing several factor plots (of a possibly pre-defined subset of features) in a grid.
- Parameters:
plot_observer (
PlottingObserver
) – A fitted plotting observer.binners (list) – A list of binners. If binners are given the labels of the x-axis of factor plots are better interpretable.
feature_groups_or_ids (list) – A list of feature group names or
cyclic_boosting.base.FeatureID
for which the factors will be plotted. Default is to plot the factors of all features.features_per_row (int) – The number of factor plots in one row.
use_tightlayout (bool) – If true the tightlayout option of matplotlib is used.
- cyclic_boosting.plots.plot_in_sample_diagonal_plot(plot_observer)[source]#
Plot the in sample diagonal plot for prediction and truth.
- Parameters:
plot_observer (
PlottingObserver
) – A fitted plotting observer.
- cyclic_boosting.plots.plot_iteration_info(plot_observer)[source]#
Convenience method calling
plot_loss()
andplot_factor_change()
.- Parameters:
plot_observer (
PlottingObserver
) – A fitted plotting observer.
- cyclic_boosting.plots.plot_loss(plot_observer)[source]#
Plot the change of the loss function between the in-sample y and the predicted factors for all iterations. For the zeroth iteration the mean of y is used as prediction.
- Parameters:
plot_observer (
PlottingObserver
) – A fitted plotting observer.