mlnext.plot.plot_signals#
- mlnext.plot.plot_signals(x: ndarray | DataFrame, y: ndarray | DataFrame | None = None, *, x_pred: ndarray | DataFrame | 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.
- Parameters:
y (T.Union[np.ndarray, pd.DataFrame]) – Labels.
x (T.Union[np.ndarray, pd.DataFrame]) – Ground truth. Default: None.
x_pred (T.Union[np.ndarray, pd.DataFrame], optional) – Prediction. Default: None.
path (str, optional) – Path to save fig to. Default: T.Optional.
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( ... x_pred=np.zeros((10, 2)), ... y=np.array([0] * 5 + [1] * 5), ... x=np.ones((10, 2)), ... path='signals.png' ... )
Expected result: