mlnext.plot.plot_signals_binary#

mlnext.plot.plot_signals_binary(x: ndarray | DataFrame, y: ndarray | DataFrame | None = None, *, x_pred: ndarray | DataFrame | None = None, bern_mean: ndarray | None = None, path: str | None = None, return_fig: bool = False) Figure | None[source]#

Plots the signal x in color of the label y. Optionally, x_pred is signal prediction to be plotted. x are the inputs or ground truth. Additionally, with bern_mean the mean of the underlying bernoulli distribution can be plotted.

Parameters:
  • x_pred (T.Union[np.ndarray, pd.DataFrame]) – Prediction.

  • y (T.Union[np.ndarray, pd.DataFrame]) – Labels. Default: None.

  • x (T.Union[np.ndarray, pd.DataFrame], optional) – Ground truth. Default: None.

  • bern_mean (np.ndarray, optional) – Mean of the underlying bernoulli distribution. Default: None.

  • path (str, optional) – Path to save figure to. Default: None.

  • return_fig (bool) – Whether to return the figure. Otherwise, plt.show() is called. Default: False.

Returns:

Returns the figure if return_fig is true.

Return type:

T.Optional[matplotlib.figure.Figure]

Example

>>> import mlnext
>>> import numpy as np
>>> mlnext.plot_signals_binary(
...    x_pred=np.zeros((10, 2)),
...    y=np.array([0] * 5 + [1] * 5),
...    x=np.ones((10, 2)),
...    bern_mean=np.array(np.ones((10, 2))) * 0.5,
...    path='signals.png'
... )

Expected result:

../_images/plot_signals_binary.png