API Reference
This page is auto-generated from Python docstrings.
ml_vizkit
ML VizKit public API.
Reusable visualizations for inspecting, comparing, and explaining trained machine-learning models.
compare_models
compare_models(
scores: Mapping[str, float],
*,
ax: Axes | None = None,
metric_name: str = 'Score',
title: str = 'Model Comparison',
) -> Axes
Compare evaluation scores from already-completed model experiments.
WHY: A consistent visual basis helps analysts compare models evaluated with the same metric and experimental conditions.
NOTE: This function assumes the caller has already established that the supplied scores are meaningfully comparable.
Source code in src/ml_vizkit/comparison.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
compare_splits
compare_splits(
splits: Sequence[SplitView],
) -> tuple[Axes, ...]
Create one train/test visualization per completed split.
WHY: Comparing several partitions makes sampling variability visible.
This function does not create splits or train models. Each visualization is created in its own figure, and all Axes are returned to the caller.
Source code in src/ml_vizkit/comparison.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
show_actual_vs_predicted
show_actual_vs_predicted(
y_true: Numeric1D,
y_pred: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Actual vs. Predicted',
) -> Axes
Show actual versus predicted regression values.
WHY: Good predictions should generally fall near the identity line.
The implementation delegates to scikit-learn's PredictionErrorDisplay.
Source code in src/ml_vizkit/regression.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
show_class_distribution
show_class_distribution(
y: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Class Distribution',
x_label: str = 'Class',
) -> Axes
Show the number of observations in each target class.
WHY: Class imbalance can affect training, evaluation, and interpretation.
Source code in src/ml_vizkit/classification.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
show_confusion_matrix
show_confusion_matrix(
y_true: Numeric1D,
y_pred: Numeric1D,
*,
labels: Sequence[Any] | None = None,
normalize: str | None = None,
ax: Axes | None = None,
title: str = 'Confusion Matrix',
) -> Axes
Show a confusion matrix from completed classification predictions.
WHY: Overall accuracy can hide which classes are being confused.
This function delegates the matrix visualization to scikit-learn and returns the Matplotlib Axes.
Source code in src/ml_vizkit/classification.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
show_decision_boundary
show_decision_boundary(
model: Any,
X: DataFrame,
y: Sequence[Any] | None = None,
*,
ax: Axes | None = None,
response_method: str = 'auto',
plot_method: str = 'contourf',
title: str = 'Decision Boundary',
alpha: float = 0.25,
) -> Axes
Show the decision boundary for an already-trained classifier.
WHY: A decision boundary makes the classifier's learned separation of feature space visible.
REQ: X must contain exactly two numeric features. REQ: model must already be fitted.
The implementation delegates boundary construction to scikit-learn's DecisionBoundaryDisplay and returns the Matplotlib Axes to the caller.
Source code in src/ml_vizkit/classification.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
show_feature_importance
show_feature_importance(
model: Any,
feature_names: Sequence[str],
*,
ax: Axes | None = None,
title: str = 'Feature Importance',
) -> Axes
Show model-provided feature importance values.
WHY: Importance values can help analysts investigate which features most influenced a fitted model.
REQ: The model must already expose feature_importances_.
Source code in src/ml_vizkit/inspection.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
show_prediction_errors
show_prediction_errors(
X: DataFrame,
y_true: Numeric1D,
y_pred: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Classification Prediction Errors',
) -> Axes
Show correct and incorrect classifications in two-feature space.
WHY: Looking directly at mistakes can reveal overlap, unusual observations, and regions where a classifier struggles.
REQ: X must contain exactly two numeric features.
Source code in src/ml_vizkit/classification.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
show_residuals
show_residuals(
y_true: Numeric1D,
y_pred: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Residuals vs. Predicted',
) -> Axes
Show regression residuals against predicted values.
WHY: Residual plots can reveal systematic error patterns, changing variance, and unusual observations.
The implementation delegates to scikit-learn's PredictionErrorDisplay.
Source code in src/ml_vizkit/regression.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
show_train_test_split
show_train_test_split(
X_train: DataFrame,
X_test: DataFrame,
*,
ax: Axes | None = None,
title: str = 'Train/Test Split',
) -> Axes
Show which observations were assigned to training and testing.
WHY: Seeing the actual partition makes random splitting concrete instead of treating the random seed as unexplained boilerplate.
REQ: Both frames must contain the same two numeric features.
Source code in src/ml_vizkit/splits.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
classification
Classification visualizations.
These functions visualize trained classifiers and completed predictions. They do not fit models or choose analytical settings.
show_class_distribution
show_class_distribution(
y: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Class Distribution',
x_label: str = 'Class',
) -> Axes
Show the number of observations in each target class.
WHY: Class imbalance can affect training, evaluation, and interpretation.
Source code in src/ml_vizkit/classification.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
show_confusion_matrix
show_confusion_matrix(
y_true: Numeric1D,
y_pred: Numeric1D,
*,
labels: Sequence[Any] | None = None,
normalize: str | None = None,
ax: Axes | None = None,
title: str = 'Confusion Matrix',
) -> Axes
Show a confusion matrix from completed classification predictions.
WHY: Overall accuracy can hide which classes are being confused.
This function delegates the matrix visualization to scikit-learn and returns the Matplotlib Axes.
Source code in src/ml_vizkit/classification.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
show_decision_boundary
show_decision_boundary(
model: Any,
X: DataFrame,
y: Sequence[Any] | None = None,
*,
ax: Axes | None = None,
response_method: str = 'auto',
plot_method: str = 'contourf',
title: str = 'Decision Boundary',
alpha: float = 0.25,
) -> Axes
Show the decision boundary for an already-trained classifier.
WHY: A decision boundary makes the classifier's learned separation of feature space visible.
REQ: X must contain exactly two numeric features. REQ: model must already be fitted.
The implementation delegates boundary construction to scikit-learn's DecisionBoundaryDisplay and returns the Matplotlib Axes to the caller.
Source code in src/ml_vizkit/classification.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
show_prediction_errors
show_prediction_errors(
X: DataFrame,
y_true: Numeric1D,
y_pred: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Classification Prediction Errors',
) -> Axes
Show correct and incorrect classifications in two-feature space.
WHY: Looking directly at mistakes can reveal overlap, unusual observations, and regions where a classifier struggles.
REQ: X must contain exactly two numeric features.
Source code in src/ml_vizkit/classification.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
comparison
Higher-level visual comparisons of completed ML experiments.
SplitView
dataclass
Data needed to visualize one already-created train/test split.
Source code in src/ml_vizkit/comparison.py
13 14 15 16 17 18 19 20 | |
compare_models
compare_models(
scores: Mapping[str, float],
*,
ax: Axes | None = None,
metric_name: str = 'Score',
title: str = 'Model Comparison',
) -> Axes
Compare evaluation scores from already-completed model experiments.
WHY: A consistent visual basis helps analysts compare models evaluated with the same metric and experimental conditions.
NOTE: This function assumes the caller has already established that the supplied scores are meaningfully comparable.
Source code in src/ml_vizkit/comparison.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
compare_splits
compare_splits(
splits: Sequence[SplitView],
) -> tuple[Axes, ...]
Create one train/test visualization per completed split.
WHY: Comparing several partitions makes sampling variability visible.
This function does not create splits or train models. Each visualization is created in its own figure, and all Axes are returned to the caller.
Source code in src/ml_vizkit/comparison.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
inspection
Visual inspection of already-trained model characteristics.
show_feature_importance
show_feature_importance(
model: Any,
feature_names: Sequence[str],
*,
ax: Axes | None = None,
title: str = 'Feature Importance',
) -> Axes
Show model-provided feature importance values.
WHY: Importance values can help analysts investigate which features most influenced a fitted model.
REQ: The model must already expose feature_importances_.
Source code in src/ml_vizkit/inspection.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
regression
Regression visualizations for completed predictions.
show_actual_vs_predicted
show_actual_vs_predicted(
y_true: Numeric1D,
y_pred: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Actual vs. Predicted',
) -> Axes
Show actual versus predicted regression values.
WHY: Good predictions should generally fall near the identity line.
The implementation delegates to scikit-learn's PredictionErrorDisplay.
Source code in src/ml_vizkit/regression.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
show_residuals
show_residuals(
y_true: Numeric1D,
y_pred: Numeric1D,
*,
ax: Axes | None = None,
title: str = 'Residuals vs. Predicted',
) -> Axes
Show regression residuals against predicted values.
WHY: Residual plots can reveal systematic error patterns, changing variance, and unusual observations.
The implementation delegates to scikit-learn's PredictionErrorDisplay.
Source code in src/ml_vizkit/regression.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
splits
Visualizations for already-created train/test partitions.
show_train_test_split
show_train_test_split(
X_train: DataFrame,
X_test: DataFrame,
*,
ax: Axes | None = None,
title: str = 'Train/Test Split',
) -> Axes
Show which observations were assigned to training and testing.
WHY: Seeing the actual partition makes random splitting concrete instead of treating the random seed as unexplained boilerplate.
REQ: Both frames must contain the same two numeric features.
Source code in src/ml_vizkit/splits.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |