Skip to main content

A package for EDA and Sci-Kit Learn visualisations and utilities

Project description

modelviz - Python package to make visualizations a breeze

image

GitHub Actions PyPI version Python 3.9 Python 3.10 Python 3.11 Python 3.12

modelviz is a Python package designed for comprehensive and customizable data visualization and model evaluation. With modules for visualizing relationships, confusion matrices, ROC curves, data distributions, and handling missing values, modelviz simplifies exploratory data analysis (EDA) and model performance evaluation.

Installation

Install modelviz via pip:

pip install modelviz

Features

1. Confusion Matrix (confusion_matrix.py)

  • Visualize Confusion Matrices:
    • Supports both binary and multi-class confusion matrices.
    • Displays proportions, TP, FP, FN, and TN labels.
    • Includes detailed metrics like Accuracy, Precision, Recall, F1 Score, MCC, and Cohen's Kappa.
    • Option to normalize the confusion matrix.

Example Usage:

from modelviz.confusion_matrix import plot_confusion_matrix
import numpy as np

cm = np.array([[50, 10], [5, 35]])  # Binary confusion matrix
classes = ["Negative", "Positive"]
plot_confusion_matrix(cm, classes, "Logistic Regression")

2. Histogram (histogram.py)

  • Feature Histograms:
    • Automatically generate histograms for all numeric columns in a pandas DataFrame.
    • Skip binary columns for cleaner visualizations.
    • Customize bins, colors, and titles.

Example Usage:

from modelviz.histogram import plot_feature_histograms
import pandas as pd

df = pd.DataFrame({
    'Age': [25, 30, 35, 40],
    'Income': [40000, 50000, 60000, 70000],
    'Gender': [0, 1, 0, 1]
})
plot_feature_histograms(df, exclude_binary=True, bins=10, color='blue')

3. ROC Curve (roc.py)

  • ROC Curve Visualization:
    • Plot Receiver Operating Characteristic (ROC) curves.
    • Highlight thresholds like Youden's J and adjusted thresholds.
    • Display key metrics like AUC (Area Under Curve).

Example Usage:

from modelviz.roc import plot_roc_curve_with_youdens_thresholds

fpr = [0.0, 0.1, 0.2, 0.3]
tpr = [0.0, 0.4, 0.6, 1.0]
thresholds = [1.0, 0.8, 0.5, 0.2]
plot_roc_curve_with_youdens_thresholds(fpr, tpr, thresholds, roc_auc=0.85, model_name="My Model")

4. Relationships (relationships.py)

  • Correlation Matrix:
    • Generate and visualize correlation matrices for numeric features.
    • Customize heatmaps with annotations, colormap, and figure size.

Example Usage:

from modelviz.relationships import plot_correlation_matrix
import pandas as pd

df = pd.DataFrame({
    'A': [1, 2, 3, 4],
    'B': [4, 3, 2, 1],
    'C': [5, 6, 7, 8]
})
plot_correlation_matrix(df, method='pearson')

5. K-Fold Visualization (kfold.py)

  • Visualize K-Fold Splits:
    • Display data distribution across training and validation sets for K-Fold Cross-Validation.
    • Easy visualization for understanding fold assignments.

6. Handling Missing Values (missvals.py)

  • Missing Value Analysis:
    • Visualize missing data in a DataFrame.
    • Quickly identify patterns and percentage of missing values.

7. Model Evaluation (model_eval.py)

  • Aggregate Model Metrics:
    • Summarize key evaluation metrics for multiple models.
    • Compare performance across models.

Importing the Package

Each module in the package is designed to be imported separately. For example:

from modelviz.confusion_matrix import plot_confusion_matrix
from modelviz.histogram import plot_feature_histograms
from modelviz.roc import plot_roc_curve_with_youdens_thresholds

Contributing

Contributions are welcome! If you have suggestions or new feature ideas, feel free to open an issue or create a pull request on GitHub.

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

modelviz-2.0.5.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

modelviz-2.0.5-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file modelviz-2.0.5.tar.gz.

File metadata

  • Download URL: modelviz-2.0.5.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for modelviz-2.0.5.tar.gz
Algorithm Hash digest
SHA256 b4b7cb9e6a924db3d85d80ba71ba00914c665397b49ce3bcfbf9019ebf397e41
MD5 dd926f488908ef71cddd98ddc6fa2e23
BLAKE2b-256 9c173a1fe4a0bc98f1ab0f3bd3f9968720ea33e22ef41deff9dcca413c3a4e66

See more details on using hashes here.

File details

Details for the file modelviz-2.0.5-py3-none-any.whl.

File metadata

  • Download URL: modelviz-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for modelviz-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8e8c34f04d88df95bbc10bca2973b2424195571e0f7c951d1f7afdb1be7e1457
MD5 e21325542b43e9ce42320508d7f1ac24
BLAKE2b-256 e2afbd1796cdfa6d23db2919f501d5a2ca6cd55dab5ab36472efd30394463f3e

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