A package with code from my ML projects that has a potential of being reusable
Project description
ddplt
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)
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)
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 labelscv
- cross-validation generator responsible for creating k-fold splitting ofX
andy
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file ddplt-0.0.2.tar.gz
.
File metadata
- Download URL: ddplt-0.0.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42beabd961dd94cea5636c0f29d4f54948158f12972a36082849cc7856f2d428 |
|
MD5 | 331b67744dcd4013a72d2326bd533cc1 |
|
BLAKE2b-256 | 9b95053747b2b03bea75c98aa965ed32ba0c3d4d6629d9986d39c1f752aea070 |
File details
Details for the file ddplt-0.0.2-py3.6.egg
.
File metadata
- Download URL: ddplt-0.0.2-py3.6.egg
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46231d7441fc34b0efb52089925e7c4d79a25fb0c6b4dac71566c7d8b100f20d |
|
MD5 | 38306886e60b307943c91ecc7f08755a |
|
BLAKE2b-256 | e2f462b882bc3642c858bbd57e8c64d05979765168b937389541aa003ac7f280 |
File details
Details for the file ddplt-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: ddplt-0.0.2-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59e027a74fcac2e22ea98a5f3711f6f9dfdde17959e3231986eabc84aea868fe |
|
MD5 | aac1965c90dec89581e6f42770c714ae |
|
BLAKE2b-256 | 978996ef2795dd09a2518eb425dabdc96d54270dcec72407e8ca93c37b1c3c7c |