Skip to main content

ddplt

PyPI version

A package with code from my ML projects that has a potential of being reusable.

Installation

The package installation is simple, since the repo is available on PyPi:

pip install ddplt

Confusion matrix

Draw a confusion matrix for classification results:

import numpy as np
from ddplt.heatmaps import draw_confusion_heatmap

# generate some data 
y_test = np.array([0, 0, 1, 1, 2, 0])
y_pred = np.array([0, 1, 1, 2, 2, 0])
class_names = np.array(['hip', 'hop', 'pop'])
ax, cm = draw_confusion_heatmap(y_test, y_pred, class_names)

conf_matrix

Cross-validated receiver operating characteristic and precision-recall curves

Draw receiver operating characteristic (ROC) and precision-recall (PR) curves using k-fold cross-validation:

from ddplt.classification import draw_roc_prc_cv

from sklearn.datasets import make_moons
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import KFold

X, y = make_moons(500, noise=.2, random_state=123)
estimator = LogisticRegression()
cv = KFold(n_splits=5, shuffle=True, random_state=123)

draw_roc_prc_cv(estimator, X, y, cv)

roc_prc_cv

The function draw_roc_prc_cv accepts the following parameters:

  • estimator - Scikit-learn's estimator with set hyperparameters. The estimator does not have to be fitted.
  • X - array-like with shape (n_instances,n_features)
  • y - array-like with shape (n_instances,) with instance labels
  • cv - cross-validation generator responsible for creating k-fold splitting of X and y

see the docs for info regarding the optional parameters

In each CV iteration, the estimator is fitted on training fold and class probabilities are predicted for instances within the test fold. Then, ROC and PR curves are generated from the probabilities.

The figure consists of:

  • individual ROC/PR curves
  • mean ROC/PR curve
  • shaded region denoting +-1 std. dev.

Areas under ROC and PR curves are reported in the legend.

Note: Use the functions draw_roc_cv or draw_prc_cv to draw ROC or PR curves only

Learning curve

TODO - not yet implemented

Create plot showing performance evaluation for different sizes of training data. The method should accept:

  • existing Axes
  • performance measure (e.g. accuracy, MSE, precision, recall, etc.)
  • ...

Correlation heatmap

TODO - not yet implemented

Grid where each square has a color denoting strength of a correlation between predictors. You can choose between Pearson and Spearman correlation coefficient, the result is shown inside the square.

Metadata

Release files for ddplt 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ddplt 0.0.2
File Size Uploaded
ddplt-0.0.2.tar.gz 7.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ddplt 0.0.2
File Interpreter ABI Platform
ddplt-0.0.2-py3.6.egg Legacy Egg format - - Details
ddplt-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 37.2 kB

Release files / ddplt-0.0.2.tar.gz

Download URL ddplt-0.0.2.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
42beabd961dd94cea5636c0f29d4f54948158f12972a36082849cc7856f2d428
BLAKE2b-256 checksum
How to use checksums
9b95053747b2b03bea75c98aa965ed32ba0c3d4d6629d9986d39c1f752aea070
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

Release files / ddplt-0.0.2-py3.6.egg

Download URL ddplt-0.0.2-py3.6.egg
Size 8.8 kB
Tags Egg
SHA-256 checksum
How to use checksums
46231d7441fc34b0efb52089925e7c4d79a25fb0c6b4dac71566c7d8b100f20d
BLAKE2b-256 checksum
How to use checksums
e2f462b882bc3642c858bbd57e8c64d05979765168b937389541aa003ac7f280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

Release files / ddplt-0.0.2-py3-none-any.whl

Download URL ddplt-0.0.2-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59e027a74fcac2e22ea98a5f3711f6f9dfdde17959e3231986eabc84aea868fe
BLAKE2b-256 checksum
How to use checksums
978996ef2795dd09a2518eb425dabdc96d54270dcec72407e8ca93c37b1c3c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.0.2 This release

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page