pycsamt.ai.plot.diagnostics#
Diagnostic plots for AI/ML model evaluation.
All functions follow the EMStyle
publication conventions and accept an optional ax parameter for
embedding in composite figures.
Functions
|
Plot a confusion matrix for a classification model. |
|
Horizontal bar chart of feature importances. |
|
Per-layer mean absolute error bar chart. |
|
Scatter plots of predicted vs. true for each model parameter. |
|
1-D prediction curve with uncertainty bands. |
- pycsamt.ai.plot.diagnostics.plot_confusion_matrix(y_true, y_pred, *, class_names=None, normalise=True, cmap='Blues', title='Confusion Matrix', figsize=None, ax=None, style=True)[source]#
Plot a confusion matrix for a classification model.
- Parameters:
y_true (int ndarray (n_samples,)) – Ground-truth class labels.
y_pred (int ndarray (n_samples,)) – Predicted class labels.
class_names (list of str or None) – Display labels for each class. Defaults to
['1-D','2-D','3-D']for three-class problems.normalise (bool) – Show row-normalised (recall) fractions.
cmap (str) – Matplotlib colormap.
title (see
plot_section().)figsize (see
plot_section().)ax (see
plot_section().)style (see
plot_section().)
- Returns:
fig
- Return type:
Figure
- pycsamt.ai.plot.diagnostics.plot_residuals(y_true, y_pred, *, param_names=None, n_cols=4, figsize_per_panel=(2.5, 2.5), style=True)[source]#
Scatter plots of predicted vs. true for each model parameter.
Each panel shows the 1:1 line, coloured scatter, and per-parameter R² annotation.
- pycsamt.ai.plot.diagnostics.plot_layer_errors(y_true, y_pred, n_layers, *, log_rho=True, ax=None, figsize=None, style=True)[source]#
Per-layer mean absolute error bar chart.
- pycsamt.ai.plot.diagnostics.plot_uncertainty_bands(x, y_pred, y_upper, y_lower, y_true=None, *, ax=None, xlabel='', ylabel='', title='Prediction with Uncertainty', figsize=None, style=True)[source]#
1-D prediction curve with uncertainty bands.
Suitable for showing per-site model parameter predictions (e.g. resistivity vs. depth) with ±1σ or 10/90 percentile bands.
- Parameters:
x (ndarray (n_points,)) – X-axis values (e.g. depth or frequency).
y_pred (ndarray (n_points,)) – Central prediction.
y_upper (ndarray (n_points,)) – Upper and lower uncertainty bounds.
y_lower (ndarray (n_points,)) – Upper and lower uncertainty bounds.
y_true (ndarray (n_points,) or None) – Ground-truth values to overlay.
ax (Axes or None)
xlabel (str)
ylabel (str)
title (str)
style (bool)
- Returns:
fig
- Return type:
Figure
- pycsamt.ai.plot.diagnostics.plot_feature_importance(importances, feature_names=None, *, top_n=20, horizontal=True, ax=None, figsize=None, title='Feature Importance', style=True)[source]#
Horizontal bar chart of feature importances.
Compatible with scikit-learn
feature_importances_arrays and any non-negative importance measure.- Parameters:
- Returns:
fig
- Return type:
Figure