matcha.utils.plotting
Plotting utilities for regression and classification model evaluation.
Provides interactive Plotly-based visualizations including scatter plots with trendlines and fold-error boundaries for regression, and ROC/PR curves with probability histograms for classification.
Functions
|
Create a scatter plot of true vs predicted values with trendline using Plotly. |
|
Create a three-panel classification plot with ROC, PR, and probability histograms. |
|
Save a Plotly figure as an HTML file. |
Module Contents
- matcha.utils.plotting.plot_regression(true_values: numpy.ndarray, pred_values: numpy.ndarray, plot_title: str = 'Regression performance', labels: list = None, is_log10: bool = False)[source]
Create a scatter plot of true vs predicted values with trendline using Plotly.
Includes OLS trendline, perfect prediction diagonal, and 2-fold/3-fold error boundary lines.
- Parameters:
true_values (numpy.ndarray) – Array of true target values.
pred_values (numpy.ndarray) – Array of predicted target values.
plot_title (str) – Title for the plot.
labels (list) – Optional list of labels for hover data corresponding to each data point.
is_log10 (bool) – Whether the values are log10-transformed. Adjusts fold-error boundary calculations accordingly.
- Returns:
A Plotly figure object, or
Noneif no valid data points exist.- Return type:
plotly.graph_objects.Figure or None
- matcha.utils.plotting.plot_classification(true_values: numpy.ndarray, pred_values: numpy.ndarray, prob_values: numpy.ndarray, plot_title: str = 'Classification performance', model: matcha.sklearn.base_sklearn_model.BaseScikitLearnModel | None = None)[source]
Create a three-panel classification plot with ROC, PR, and probability histograms.
Generates an interactive Plotly figure with ROC-AUC curve, Precision-Recall curve, and predicted probability distribution histograms for each class.
- Parameters:
true_values (numpy.ndarray) – Array of true binary labels (0 or 1).
pred_values (numpy.ndarray) – Array of predicted binary labels (0 or 1).
prob_values (numpy.ndarray) – Array of predicted probabilities for the positive class.
plot_title (str) – Title for the plot.
model (BaseScikitLearnModel or None) – Optional model instance used to encode labels via its internal label encoder.
- Returns:
A Plotly figure object, or
Noneif no valid data points exist.- Return type:
plotly.graph_objects.Figure or None