Metrics
v0.1.7Evaluation metrics for every task: regression (MAE, MSE, RMSE, R2, MAPE), classification (accuracy, precision, recall, F1) and clustering (silhouette, Calinski-Harabasz, Davies-Bouldin), plus full per-class reports.
Quick Start
metrics.py
python
import synaptix as sx
df = sx.load_dataset("iris")
X, y = df.drop(columns="species"), df["species"]
model = sx.supervised.RandomForestClassifier().fit(X, y)
y_pred = model.predict(X)
# Per-class report with confusion matrix
report = sx.metrics.classification_report(y, y_pred)
print(report)
# Individual metrics
print(sx.metrics.classification_metrics(y, y_pred, average="macro"))
# Regression
print(sx.metrics.regression_metrics(y_true_reg, y_pred_reg))
# Clustering
print(sx.metrics.clustering_metrics(X, km.labels_))API Reference
regression_metrics
regression_metrics(y_true, y_pred) -> dict
dict of float
classification_metrics
classification_metrics(y_true, y_pred, average='weighted') -> dict
dict of float
clustering_metrics
clustering_metrics(X, labels) -> dict
dict of float
classification_report
classification_report(y_true, y_pred) -> dict
dict
Exporting Metrics
Every metric result is also an EvaluationResult that can be exported to a ViewX dashboard:
export.py
python
evaluation = model.evaluate(X_test, y_test)
evaluation.to_html("evaluacion.html", theme="dark_enterprise") # requires synaptix[viewx]