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

Uploaded Python 3

File details

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

File metadata

  • Download URL: emreport-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6209288de7ba150ed0f768f3da70242007b5ea62e3af1c5ecc393eecc9979288
MD5 baa4a6fc9a0c00a63918c779e2354fb3
BLAKE2b-256 4617d79867a6f30055f7874461299aba381c3fbaf0c92ee1ae62bda4e52dbafe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: emreport-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3286211eb4baf92e47717edcb7c4f9d5f4e7a2296f8fe0c24754f15bedaafc7b
MD5 c42df90b53b08c7178796b6965bb015f
BLAKE2b-256 3fadb6a06b225fc613e317f71d9fab49712e115484676b17abc920e79423d954

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