HeartWise-AI / HeartWise_StatPlots

0 stars 1 forks source link

HeartWise StatPlots Metrics Library

A Python library for computing and visualizing classification and regression metrics, with a focus on medical and healthcare applications.

Table of Contents

πŸš€ Features

Classification Metrics

Regression Metrics

πŸ› οΈ Installation

This project uses Poetry for dependency management. To install the library and its dependencies:

  1. Ensure you have Poetry installed. If not, install it by following the instructions at https://python-poetry.org/docs/#installation

  2. Clone this repository:

    git clone https://github.com/HeartWise-AI/HeartWise_StatPlots.git
    cd HeartWise_StatPlots
  3. Install the dependencies using Poetry:

    poetry install

πŸ“„ Usage

See more examples in examples.py

Classification Example

import numpy as np
from metrics_library.metrics import MetricsComputer, ClassificationMetrics

# Classification example
y_true = np.array([0, 1, 1, 0, 1], dtype=np.int64)
y_pred = np.array([0.1, 0.9, 0.4, 0.3, 0.8], dtype=np.float64)

metrics = [ClassificationMetrics.AUC, ClassificationMetrics.SENSITIVITY, ClassificationMetrics.SPECIFICITY]
results = MetricsComputer.compute_classification_metrics(y_true, y_pred, metrics=metrics, bootstrap=True, n_iterations=1000)
print("Classification Metrics:", results)

Regression Example

import numpy as np
from metrics_library.metrics import MetricsComputer, RegressionMetrics

# Regression example
y_true = np.array([1.0, 2.0, 3.0, 4.0, 5.0], dtype=np.int64)
y_pred = np.array([1.1, 2.2, 2.9, 3.8, 5.2], dtype=np.float64)

metrics = [RegressionMetrics.MAE, RegressionMetrics.MSE, RegressionMetrics.PEARSON_CORRELATION]
results = MetricsComputer.compute_regression_metrics(y_true, y_pred, metrics=metrics, bootstrap=True, n_iterations=1000)
print("Regression Metrics:", results)

πŸ”§ Pre-commit Hooks

We use pre-commit hooks to ensure code quality before committing changes. To set up pre-commit hooks:

  1. Install pre-commit:

    poetry add --group dev pre-commit
  2. Install the git hooks:

    poetry run pre-commit install

Now, the formatting and linting checks will run automatically before each commit.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Here's how you can contribute:

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Add tests for your changes
  4. Make your changes and commit them with clear, descriptive messages
  5. Push your changes to your fork
  6. Submit a pull request to the main repository

πŸ“ž Contact

For any questions, please contact: