Skip to main content

A package providing functions to calculate key regression metrics: R-squared, Mean Absolute Error (MAE), Mean Squared Error (MSE), and Mean Absolute Percentage Error (MAPE).

Project description

Documentation Status

matrics_calculator

A package providing functions to calculate key regression metrics: R-squared, Mean Absolute Error (MAE), Mean Squared Error (MSE), and Mean Absolute Percentage Error (MAPE).

Python Ecosystem

matrics_calculator provides a lightweight and easy-to-use alternative for calculating key regression metrics, complementing existing libraries like scikit-learn. While scikit-learn offers a full suite of machine learning tools, matrics_calculator focuses solely on evaluation metrics, making it a useful option for quick analysis, custom workflows, or educational purposes. Its simplicity makes it accessible for users who need essential regression metrics without the overhead of a larger machine learning framework.

Features

This package consists of four functions:

  • r_squared:
    • This function calculates the R-squared of the model, which measures how well the model explains the variation in the data.
  • mean_absolute_error:
    • This function finds the average difference between predicted and actual values.
  • mean_squared_error:
    • This function calculates the average of the squared differences between predictions and actual values.
  • mean_absolute_percentage_error:
    • This function shows prediction error as a percentage, making it easy to understand.

matrics_calculator in the Python Ecosystem

matrics_calculator works alongside Python libraries like scikit-learn by providing simple implementations of regression metrics. Unlike scikit-learn’s full toolkit for modeling and evaluation, this package focuses only on metrics, making it easy to use for quick analysis or custom workflows.

Installation

To install the package, navigate to the root directory of the project and run:

$ pip install matrics_calculator

Dependencies

This package requires the following dependencies:

These dependencies are installed automatically when you install the package using:

pip install matrics_calculator

Usage

Here’s how to use the functions in this package:

  1. Import the Package
from matrics_calculator.r2 import r2_score
from matrics_calculator.MAE import mean_absolute_error
from matrics_calculator.MSE import mean_squared_error
from matrics_calculator.MAPE import mean_absolute_percentage_error
  1. Prepare Your Data Ensure you have two arrays:

    y_true: The actual target values

    y_pred: The predicted values from your regression model

    Example:

y_true = [100, 200, 300]
y_pred = [110, 190, 290]
  1. Calculate Metrics Use the functions to evaluate your model:
# Calculate MAPE
mape = mean_absolute_percentage_error(y_true, y_pred)
print(f"MAPE: {mape:.2f}%")

# Calculate MAE
mae = mean_absolute_error(y_true, y_pred)
print(f"MAE: {mae:.2f}")

# Calculate MSE
mse = mean_squared_error(y_true, y_pred)
print(f"MSE: {mse:.2f}")

# Calculate R-squared
r2 = r2_score(y_true, y_pred)
print(f"R-squared: {r2:.2f}")

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

matrics_calculator was created by Celine Habashy, Jay Mangat, Yajing Liu, Zhiwei Zhang. It is licensed under the terms of the MIT license.

Credits

matrics_calculator was created with cookiecutter and the py-pkgs-cookiecutter template.

Constributors

  • Celine Habashy
  • Jay Mangat
  • Yajing Liu
  • Zhiwei Zhang

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

matrics_calculator-3.2.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

matrics_calculator-3.2.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file matrics_calculator-3.2.2.tar.gz.

File metadata

  • Download URL: matrics_calculator-3.2.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for matrics_calculator-3.2.2.tar.gz
Algorithm Hash digest
SHA256 555cdcfbce495f2bebb8f7d390b0a40faf935323509d06d4b37b7de32037401b
MD5 c60191bef98574885a3bb19d007cc7a7
BLAKE2b-256 e108b9a3da3f8a300b7044ca46bfac403d64fe19fe3acc42e2812e5d38bd2042

See more details on using hashes here.

File details

Details for the file matrics_calculator-3.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for matrics_calculator-3.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 068638b882803b2f6b797e2b0d1af95e2e6832851b948465098f3c52fafac1d2
MD5 674fdabc4f2d601b322c60a6a6830f02
BLAKE2b-256 79661c9020aacd076d5ad5b273b589b81a3a1813f21f2f1aa13a07645be9720f

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