Skip to main content

A comprehensive machine learning evaluation metrics library

Project description

MLScore

A comprehensive machine learning evaluation metrics library that provides a simple interface to calculate multiple evaluation metrics at once.

Installation

pip install mlscore

Usage

Basic Usage

from mlscore import score, score_c, score_r
import numpy as np

# Example 1: Classification
y_true = np.array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1])
y_pred = np.array([0, 1, 0, 0, 0, 1, 0, 1, 0, 1])

# Using score_c for classification (automatically prints results)
score_c(y_true, y_pred)

# Example 2: Regression
y_true_reg = np.array([1.2, 2.3, 3.4, 4.5])
y_pred_reg = np.array([1.1, 2.4, 3.3, 4.6])

# Using score_r for regression (automatically prints results)
score_r(y_true_reg, y_pred_reg)

# Example 3: Automatic detection
score(y_true, y_pred)  # Will automatically detect and print results

Getting Metrics Without Printing

# Get metrics dictionary without printing
metrics = score_c(y_true, y_pred, print_results=False)

# Access specific metrics
print(metrics['Accuracy'])
print(metrics['Precision'])
print(metrics['F1 Score'])

Available Functions

  1. score(y_true, y_pred, print_results=True)

    • Automatically detects if the problem is classification or regression
    • Prints results by default
    • Returns a dictionary of metrics
  2. score_c(y_true, y_pred, print_results=True)

    • Specifically for classification problems
    • Prints results by default
    • Returns a dictionary of classification metrics
  3. score_r(y_true, y_pred, print_results=True)

    • Specifically for regression problems
    • Prints results by default
    • Returns a dictionary of regression metrics

Available Metrics

Classification Metrics

  • Accuracy
  • Precision
  • Recall
  • F1 Score
  • ROC-AUC Score (for binary classification)
  • Confusion Matrix

Regression Metrics

  • Mean Squared Error (MSE)
  • Root Mean Squared Error (RMSE)
  • Mean Absolute Error (MAE)
  • R² Score
  • Adjusted R² Score

Output Format

The library provides two ways to access the metrics:

  1. Printed Output (default):
==================================================
Problem Type: Classification
==================================================
Accuracy: 0.9000
Precision: 0.9167
Recall: 0.9000
F1 Score: 0.8990
ROC-AUC: 0.9000

Confusion Matrix:
  [5, 0]
  [1, 4]
  1. Dictionary Output:
{
    'Accuracy': 0.9,
    'Precision': 0.9167,
    'Recall': 0.9,
    'F1 Score': 0.8990,
    'ROC-AUC': 0.9,
    'Confusion Matrix': [[5, 0], [1, 4]],
    'Problem Type': 'Classification'
}

Requirements

  • Python >= 3.6
  • NumPy >= 1.19.0
  • scikit-learn >= 0.24.0

License

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

mlscore-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

mlscore-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mlscore-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mlscore-0.1.0.tar.gz
Algorithm Hash digest
SHA256 660c45345af2e48b5ef434fb60c91ee1f7f9fee95e81bbdedac6ed3fe722f71b
MD5 e2286af86c8a2ad9fd1880db6770cbc9
BLAKE2b-256 d149acf865f3f5f1e42a2dd06e206302b02000433f0e1a562befacf0ed955b79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlscore-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mlscore-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e5a96283150d8dd3c855323d3e202bd4b55ce54fd66f9334abdf1ae40fa4ad
MD5 aa91982de60dbab75d31b08beebdec31
BLAKE2b-256 34a6d511a84adc1aa0f387c3c6c99051deea7e4233ccd02ea9fad5823573f2f2

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