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 EMReport

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.2.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.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: emreport-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 1b2e3612ad6644eaa2873171bead56bf7ad927055e17db3c6242bf0cb13fa950
MD5 9fbc1076c544f0f05326613986ed0f06
BLAKE2b-256 531d63768052c619131b16de1202f125775ca480d58f055b30af31f13dffabe1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: emreport-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 becc3d56c53150cb01d253361390f9df76b67a077173278ba1a6851b6764efac
MD5 ac563de5a630b13ecebdb74683a0b0ad
BLAKE2b-256 de1c9f4ae01719af07f43f53395a81fe292396daa9f7428b51b611f4347b92fb

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