A Python library for computing and visualizing classification and regression metrics, with a focus on medical and healthcare applications.
This project uses Poetry for dependency management. To install the library and its dependencies:
Ensure you have Poetry installed. If not, install it by following the instructions at https://python-poetry.org/docs/#installation
Clone this repository:
git clone https://github.com/HeartWise-AI/HeartWise_StatPlots.git
cd HeartWise_StatPlots
Install the dependencies using Poetry:
poetry install
See more examples in examples.py
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)
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)
We use pre-commit hooks to ensure code quality before committing changes. To set up pre-commit hooks:
Install pre-commit:
poetry add --group dev pre-commit
Install the git hooks:
poetry run pre-commit install
Now, the formatting and linting checks will run automatically before each commit.
Contributions are welcome! Please feel free to submit a Pull Request. Here's how you can contribute:
For any questions, please contact: