cristal.plotter module#

Implementation of the CFPlotter class for plotting level sets and boundaries of DyCF models.

class cristal.plotter.DyCFPlotter(model)#

Bases: BasePlotter

Plotter for levelsets and boundaries associated with a DyCF model.

model#

The model to study, which should have a dimension d of 2. This model should be fitted before plotting.

Type:

DyCF

__init__(model)#

Initialize the CFPlotter.

Parameters:

model (DyCF) – The model to study, which should have a dimension d of 2.

boundary(x, *, n_x1=100, n_x2=100, show=True, save=False, save_title='CF_boundary.png', close=True, fig=None, ax=None)#

Plot the boundary decision of the model. In green, the points where the decision function is positive (considered as inliers), in red, the points where the decision function is negative (considered as outliers).

Return type:

None | tuple[Figure, Axes]

Parameters:
  • x (np.ndarray) – The data points to plot, shape (n_samples, n_features=2).

  • n_x1 (int) – Number of points along the first dimension for the grid.

  • n_x2 (int) – Number of points along the second dimension for the grid.

  • show (bool) – Whether to show the plot. Defaults to True.

  • save (bool) – Whether to save the plot to a file. Defaults to False.

  • save_title (str) – Title for the saved plot file. Defaults to “CF_boundary.png”.

  • close (bool) – Whether to close the plot or return it after saving or showing. Defaults to True.

  • fig (Figure | None) – The figure to plot on. If None, a new figure is created.

  • ax (Axes | None) – The axes to plot on. If None, a new axes is created.

levelset(x, *, n_x1=100, n_x2=100, levels=None, percentiles=None, show=True, save=False, save_title='CF_levelset.png', close=True, fig=None, ax=None)#

Plot the level sets of the model’s decision function. The reference level 1 is plotted in red.

Return type:

None | tuple[Figure, Axes]

Parameters:
  • x (np.ndarray) – The data points to plot, shape (n_samples, n_features=2).

  • n_x1 (int) – Number of points along the first dimension for the grid.

  • n_x2 (int) – Number of points along the second dimension for the grid.

  • levels (list[int | float], optional) – Specific levels to plot. If None, defaults to [].

  • percentiles (list[int | float], optional) – Percentiles to compute and plot as levels. If None, defaults to [].

  • show (bool) – Whether to show the plot. Defaults to True.

  • save (bool) – Whether to save the plot to a file. Defaults to False.

  • save_title (str) – Title for the saved plot file. Defaults to “CF_levelset.png”.

  • close (bool) – Whether to close the plot or return it after saving or showing. Defaults to True.

  • fig (Figure | None) – The figure to plot on. If None, a new figure is created.

  • ax (Axes | None) – The axes to plot on. If None, a new axes is created.