Skip to main content

A Python library for evaluating machine learning models with comprehensive reports for regression, classification, and clustering tasks.

Project description

EMReport

A lightweight Python utility for generating clean, readable evaluation reports for Regression, Classification, and Clustering machine learning models — all in one place.


Features

  • Regression Report — MAE, MSE, RMSE, and R²
  • Classification Report — Accuracy, Precision, Recall, F1 Score, and Confusion Matrix
  • Clustering Report — Silhouette Score, Davies-Bouldin Index, and Calinski-Harabasz Index

Requirements

  • Python 3.7+
  • numpy
  • scikit-learn

Install dependencies with:

pip install numpy scikit-learn

Usage

Import the functions you need directly from EMReport.py:

from EMReport import EMReport_Regression, EMReport_Classification, EMReport_Clustering

🔹 Regression

from EMReport import EMReport_Regression

y_true = [3.0, 5.0, 2.5, 7.0]
y_pred = [2.8, 4.9, 2.7, 6.8]

EMReport_Regression(y_true, y_pred)

Output:

--------------------------------------------------
            REGRESSION EVALUATION REPORT
--------------------------------------------------
Mean Absolute Error (MAE):       0.1500
Mean Squared Error (MSE):        0.0250
Root Mean Squared Error (RMSE):  0.1581
R-squared (R2):                  0.9921
--------------------------------------------------

🔹 Classification

from EMReport import EMReport_Classification

y_true = [0, 1, 2, 1, 0]
y_pred = [0, 1, 1, 1, 0]

EMReport_Classification(y_true, y_pred)

Output:

--------------------------------------------------
            CLASSIFICATION EVALUATION REPORT
--------------------------------------------------
Accuracy:                        0.8000
Precision:                       0.8000
Recall:                          0.8000
F1 Score:                        0.8000
--------------------------------------------------
Confusion Matrix:
 [[2 0 0]
  [0 2 0]
  [0 1 0]]
--------------------------------------------------

🔹 Clustering

from EMReport import EMReport_Clustering
import numpy as np

X = np.array([[1, 2], [1, 4], [1, 0],
              [10, 2], [10, 4], [10, 0]])
labels = [0, 0, 0, 1, 1, 1]

EMReport_Clustering(X, labels)

Output:

--------------------------------------------------
          CLUSTERING EVALUATION REPORT
--------------------------------------------------
Number of Clusters:        2
Silhouette Score:          0.8571 (Closer to 1 is better)
Davies-Bouldin Index:      0.2041 (Lower is better)
Calinski-Harabasz Index:   90.0000 (Higher is better)
--------------------------------------------------

Note: The clustering report requires at least 2 distinct clusters and fewer clusters than total samples. An error message will be shown if this condition is not met.


API Reference

EMReport_Regression(y_true, y_pred)

Parameter Type Description
y_true array-like Ground truth target values
y_pred array-like Estimated target values from the model

EMReport_Classification(y_true, y_pred)

Parameter Type Description
y_true array-like Ground truth class labels
y_pred array-like Predicted class labels from the model

Uses weighted averaging for Precision, Recall, and F1 Score to handle class imbalance.


EMReport_Clustering(X, labels)

Parameter Type Description
X array-like of shape (n_samples, n_features) Input feature matrix used for clustering
labels array-like Cluster labels assigned to each sample

Metrics Explained

Metric Task Interpretation
MAE Regression Average absolute difference between predictions and actuals
MSE Regression Average squared difference; penalises large errors more
RMSE Regression Square root of MSE; same unit as target variable
Regression Proportion of variance explained (1.0 = perfect fit)
Accuracy Classification Fraction of correctly classified samples
Precision Classification Of all positive predictions, how many were correct
Recall Classification Of all actual positives, how many were found
F1 Score Classification Harmonic mean of Precision and Recall
Silhouette Score Clustering Measures how similar a point is to its own cluster vs. others (-1 to 1)
Davies-Bouldin Index Clustering Average similarity between clusters; lower = better separation
Calinski-Harabasz Index Clustering Ratio of between-cluster to within-cluster dispersion; higher = better

License

This project is open-source and available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emreport-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emreport-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file emreport-0.1.0.tar.gz.

File metadata

  • Download URL: emreport-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for emreport-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7cc4b0d32d426de5404979fb5ebab0e01a84d88608d9c8d5559104655aaaede0
MD5 10eee938398cff26716bc2814494585e
BLAKE2b-256 0b144b089758e2e7942b0d11ab230de5da22fc89ed525aeee3d2e0eb2abb3d13

See more details on using hashes here.

File details

Details for the file emreport-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: emreport-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for emreport-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 215ba835684610723f3f17b9d0e1ff6a1df026d93a77f45cd9b93a941b39318f
MD5 42f5676248c840b86440ecb3ab678080
BLAKE2b-256 a84f51cf103c0f0cd99f8ed788ff261828963e383ec21510952889bb1e340117

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page