ds-utils-metrics
Machine learning model evaluation, classification diagnostics, threshold tuning, and error slicing. Use for confusion matrices, interactive ROC/PR curves with…
от idanmoradarthas★ 37 звёзд на GitHub
Установить ds-utils-metrics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
ds-utils-metrics
Comprehensive model evaluation, interactive threshold tuning, probability calibration inspection, and error slicing workflows.
Purpose
ds_utils.metrics provides diagnostic visualizations and error analysis tools for evaluating predictive models. It bridges standard metric calculation with practical decision-making: finding optimal operational thresholds, detecting probability miscalibration, identifying underperforming data slices, and quantifying regression error profiles.
- When to use: Model validation, comparing competing candidate classifiers, selecting probability decision thresholds, diagnosing error concentrations across feature sub-populations, or forecasting trend directional accuracy.
- When NOT to use: For data exploration prior to training (use ds-utils-preprocess), tree interpretability diagrams (use ds-utils-xai), or clustering evaluation (use ds-utils-unsupervised).
Prerequisites
- Python 3.11 or higher.
- data-science-utils package installed (pip install data-science-utils).
- Core dependencies: numpy, pandas, scikit-learn, matplotlib, seaborn, plotly.
- Trained scikit-learn compatible estimator or prediction arrays (y_true, y_pred, y_proba).
Instructions
Task-to-Approach Map
| Evaluation Goal | Function | Engine | Input Requirements |
|---|---|---|---|
| Per-class errors & summary rates (FPR, FNR) | plot_confusion_matrix |
Matplotlib | y_true, y_pred, labels=[0, 1] list |
| Optimal decision threshold tuning (ROC) | plot_roc_curve_with_thresholds_annotations |
Plotly | y_true, {name: proba[:, positive_class_idx]} |
| Precision-recall balance on imbalanced data | plot_precision_recall_curve_with_thresholds_annotations |
Plotly | y_true, {name: proba[:, positive_class_idx]} |
| Coarse probability overconfidence check | visualize_accuracy_grouped_by_probability |
Matplotlib | y_true, labeled_class, 1D probability array |
| Data-size sensitivity & sample efficiency | plot_metric_growth_per_labeled_instances |
Matplotlib | X_tr, y_tr, X_te, y_te, {name: unfitted_model} |
| Probability distribution by error type (FP/FN) | plot_error_analysis_chart |
Matplotlib | y_true, y_pred, y_proba |
| Systematic error slicing across feature cohorts | generate_error_analysis_report |
Pandas DataFrame | X, y_true, y_pred |
| Regression tolerance error curve & AOC | plot_rec_curve_with_annotations, regression_auc_score |
Plotly & Scalar | y_true, {name: y_pred} (continuous) |
| Time-series directional change / trend bias | directional_accuracy_score, directional_bias_score |
Scalar | y_true, y_pred (continuous sequences) |
Exhaustive signatures, parameter defaults, and common pitfalls are in references/api_reference.md.
End-to-End Evaluation Workflow
Choose the evaluation branch matching your model task:
Model Predictions Available
│
┌────────────────┴────────────────┐
▼ ▼
Classification Regression / Forecasting
│ │
Confusion Matrix Regression AOC & REC Curve
(plot_confusion_matrix) (plot_rec_curve_with_annotations)
│ │
Threshold Tuning Directional Metrics
(plot_roc / plot_precision_recall) (directional_accuracy / bias)
│
Probability Calibration
(visualize_accuracy_grouped_by_prob)
│
Feature Error Slicing
(plot_error_analysis_chart & report)
│
Learning Curve Analysis
(plot_metric_growth_per_labeled_instances)
Inputs you need
The steps below assume you have partitioned your data and fitted your models:
- Classification: a fitted classifier
clf, test feature matrix or DataFrameX_test, ground-truth labelsy_test, plus training splitsX_train,y_trainfor learning curves. - Regression: a fitted regressor
reg, test featuresX_test, ground truthy_test. - Forecasting: continuous arrays
y_true_seriesandy_pred_seriesordered chronologically.
import numpy as np
import pandas as pd
# Load your evaluation data (replace with your data)
df = pd.read_csv("your_dataset")
# X_train, X_test, y_train, y_test = train_test_split(...)
# clf = LogisticRegression().fit(X_train, y_train)
Classification Branch
Step 1: Overall Classification Performance (plot_confusion_matrix)
Question: where are the classification errors concentrated between false positives and false negatives?
import matplotlib.pyplot as plt
from ds_utils.metrics.confusion_matrix import plot_confusion_matrix
# Predictions on your held-out test data
y_true = y_test
y_pred = clf.predict(X_test)
ax = plot_confusion_matrix(
y_true, y_pred, labels=[0, 1]
) # 0/1 assumed - replace with your class labels /
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/api_reference.md
FAQ
Что делает скилл ds-utils-metrics?
Machine learning model evaluation, classification diagnostics, threshold tuning, and error slicing. Use for confusion matrices, interactive ROC/PR curves with threshold annotations, probability calibration analysis, error reports, and time-series directional metrics. Do NOT use for data preprocessing or clustering.
Как установить скилл ds-utils-metrics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ds-utils-metrics запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…