The quickest and easiest way to go from analysis...
Explore the full features of Scikit-plots: https://scikit-plots.github.io/dev/devel/index.html
β οΈ Partially support Python 3.8 3.9 without some packages in cexternals, externals due to externals lib dep (e.g., astropy.stats, arrat-api-compat, arrat-api-extra)
π Run the latest scikit-plots container β with full or partial preinstallation β interactively:
## docker run -it --rm scikitplot/scikit-plots:latest
docker run -it --rm scikitplot/scikit-plots:latest -i -c "scikitplot -V"
## docker run -it scikitplot/scikit-plots:latest
docker run -it -v "$(pwd):/work/notebooks:delegated" -p 8891:8891 scikitplot/scikit-plots:latest
venv
pipenv
) to Avoid Conflicts.base
β it's prone to conflicts.See Also: conda-environment-guidelines
## (conda, mamba or micromamba) Create New Env and install ``scikit-plots``
## Create a new environment and install Python 3.11 with IPython kernel support
# conda create -n py311 python=3.11 ipykernel -y
micromamba create -n py311 python=3.11 ipykernel -y
## (conda, mamba or micromamba) Activate the environment
# conda activate py311
micromamba activate py311
## (conda, mamba or micromamba) Install scikit-plots (Upcoming)
# conda install --yes -c conda-forge scikit-plots
micromamba install --yes -c conda-forge scikit-plots
See Also: pipenv-environment-guidelines
## (Optionally) Pipenv dep for Python 3.11
## wget https://raw.githubusercontent.com/scikit-plots/scikit-plots/main/docker/env_pipenv/Pipfile
curl -O https://raw.githubusercontent.com/scikit-plots/scikit-plots/main/docker/env_pipenv/py311/Pipfile
curl -O https://raw.githubusercontent.com/scikit-plots/scikit-plots/main/docker/env_pipenv/py311/Pipfile.lock
pip install pipenv && pipenv install
## (Optionally) Pipenv Activate the environment
pipenv shell
PIP
Installation by
pypi
,
pypi.anaconda.org
or
GITHUB
The easiest way to set up scikit-plots is to install it using pip with the following command:
pypi
:
## Now Install scikit-plots (via pip, conda, or local source)
# pip index versions scikit-plots
pip install scikit-plots
pypi.anaconda.org
(with
required runtime dependencies
):
## (Optionally) Install the lost packages "Runtime dependencies" or use `pipenv`
## https://github.com/celik-muhammed/scikit-plots/tree/main/requirements
## wget https://raw.githubusercontent.com/scikit-plots/scikit-plots/main/requirements/default.txt
curl -O https://raw.githubusercontent.com/scikit-plots/scikit-plots/main/requirements/default.txt
pip install -r default.txt
## Try After Ensure all "Runtime dependencies" installed
pip install -U -i https://pypi.anaconda.org/scikit-plots-wheels-staging-nightly/simple scikit-plots
GITHUB
:
@<branch>
,
@<tag>
or
Source Code Archive URLs
to specify a version
GITHUB
Branches:
@<branch>
## pip install git+https://github.com/scikit-plots/scikit-plots.git@<branches>
## Latest in Development
pip install git+https://github.com/scikit-plots/scikit-plots.git@main
##
## (Added C, Cpp, Fortran Support) Works with standard Python (CPython)
pip install git+https://github.com/scikit-plots/scikit-plots.git@maintenance/0.4.x
##
## (Works with PyPy interpreter) Works with standard Python (CPython)
pip install git+https://github.com/scikit-plots/scikit-plots.git@maintenance/0.3.x
pip install git+https://github.com/scikit-plots/scikit-plots.git@maintenance/0.3.7
GITHUB
Tags:
@<tag>
## pip install git+https://github.com/scikit-plots/scikit-plots.git@<tags>
pip install git+https://github.com/scikit-plots/[email protected]
pip install git+https://github.com/scikit-plots/[email protected]
pip install git+https://github.com/scikit-plots/[email protected]
Archive (.tar.gz)
or
GIT Clone
.tar.gz
) (e.g., GitHub Source Code Archive
, PyPI Source Code Archive
, pypi.anaconda Source Code Archive
)GitHub Source Code Archives
(.zip
or .tar.gz
)
by specifying a branch
, tag
, or a specific commit ID
.GitHub Source Code Archive
(similar to cloning), remember require to run git submodule update
to initialize submodules, If Needed..tar.gz
)
are also available for direct installation via PyPI (sdist)
, if applicable..tar.gz
)
are also available for direct installation via pypi.anaconda (sdist)
, if applicable.scikit-plots
directly from the GitHub Source Code Repository
to access the latest updates..tar.gz
)
(with/without
required build dependencies
)
## pip install package Installs wheel (.whl) if available, else source
## pip install --no-binary=package package # Forces source installation only the specified package
pip install --no-binary=scikit-plots scikit-plots
## pip install --no-binary=:all: package # Forces source installation for Package + all dependencies
## This forces scikit-plots and all its dependencies to be installed from source (from .tar.gz).
pip install --no-binary=:all: scikit-plots
## (Optionally) Install offline downloaded a source distribution (.tar.gz) of scikit-plots
## pip install --require-hashes -r requirements.txt
## sha256sum scikit_plots-0.4.0.post3.tar.gz
## shasum -a 256 scikit_plots-0.4.0.post3.tar.gz
## Get-FileHash scikit_plots-0.4.0.post3.tar.gz -Algorithm SHA256
## scikit-plots==0.4.0.post3 --hash=sha256:<your-computed-hash-here>
## wget https://files.pythonhosted.org/packages/bd/a0/f0d8ee33124071f93c84eeae8aa729978ca5db9b34998437effd1ead344b/scikit_plots-0.4.0.post3.tar.gz
curl -O https://files.pythonhosted.org/packages/bd/a0/f0d8ee33124071f93c84eeae8aa729978ca5db9b34998437effd1ead344b/scikit_plots-0.4.0.post3.tar.gz
pip install ./scikit_plots-0.4.0.post3.tar.gz
GITHUB Source Code
:
(with
required build dependencies
)
GITHUB Source Code Archive URLs
:
( .zip
or .tar.gz
)
(with
required build dependencies
)
Source code archives are available at specific URLs for each repository.
For example, consider the repository
scikit-plots/scikit-plots
.
GitHub Source Code Repository Cloned
:
(with
required build dependencies
)
## Forked repo: https://github.com/scikit-plots/scikit-plots.git
git clone https://github.com/YOUR-USER-NAME/scikit-plots.git
cd scikit-plots
## (if Necessary) Add safe directories for git
# bash docker/script/safe_dirs.sh
git config --global --add safe.directory '*'
## (Optionally) Git Submodules Clone/Download/Initialize Configs, Not Needed Every Time.
# git submodule update --init --recursive
## (Recommended) Ensure venv (e.g. conda, venv, pipenv)
# pip install -r ./requirements/all.txt
pip install -r ./requirements/build.txt
## Install the package in the current directory, ignore pipβs cache, and show detailed logs of the installation process.
pip install --no-cache-dir . -v
## (Optionally) Install the current package in editable mode, using the current environment for building, and ignore cached builds
pip install --no-cache-dir --no-build-isolation -e . -v
## (Optionally) Install the current package in editable mode, using the current environment for building, and ignore cached builds
## https://github.com/celik-muhammed/scikit-plots/tree/main/requirements
## For More in Doc: https://scikit-plots.github.io/dev/devel/guide_qu_contribute.html
python -m pip install --no-cache-dir --no-build-isolation -e .[build,dev,test,doc] -v
## https://github.com/celik-muhammed/scikit-plots/tree/main/requirements
## [cpu] refer tensorflow-cpu, transformers, tf-keras
## [gpu] refer Cupy tensorflow lib require NVIDIA CUDA support
pip install "scikit-plots[cpu]"
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Scikit-plots is the result of an unartistic data scientist's dreadful realization that visualization is one of the most crucial components in the data science process, not just a mere afterthought.
Gaining insights is simply a lot easier when you're looking at a colored heatmap of a confusion matrix complete with class labels rather than a single-line dump of numbers enclosed in brackets. Besides, if you ever need to present your results to someone (virtually any time anybody hires you to do data science), you show them visualizations, not a bunch of numbers in Excel.
That said, there are a number of visualizations that frequently pop up in machine learning. Scikit-plots is a humble attempt to provide aesthetically-challenged programmers (such as myself) the opportunity to generate quick and beautiful graphs and plots with as little boilerplate as possible.
Say we use Keras Classifier in multi-class classification and decide we want to visualize the results of a common classification metric, such as sklearn's classification report with a confusion matrix.
Letβs start with a basic example where we use a Keras classifier to evaluate the digits dataset provided by Scikit-learn.
# Before tf {'0':'All', '1':'Warnings+', '2':'Errors+', '3':'Fatal Only'} if any
import os; os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
# Disable GPU and force TensorFlow to use CPU
import os; os.environ['CUDA_VISIBLE_DEVICES'] = ''
import tensorflow as tf
# Set TensorFlow's logging level to Fatal
import logging; tf.get_logger().setLevel(logging.CRITICAL)
import numpy as np
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
# Loading the dataset
X, y = load_digits(
return_X_y=True,
)
# Split the dataset into training and validation sets
X_train, X_val, y_train, y_val = train_test_split(
X, y, test_size=0.33, random_state=0
)
# Convert labels to one-hot encoding
Y_train = tf.keras.utils.to_categorical(y_train)
Y_val = tf.keras.utils.to_categorical(y_val)
# Define a simple TensorFlow model
tf.keras.backend.clear_session()
model = tf.keras.Sequential([
# tf.keras.layers.Input(shape=(X_train.shape[1],)), # Input (Functional API)
tf.keras.layers.InputLayer(shape=(X_train.shape[1],)),
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
# Compile the model
model.compile(
optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'],
)
# Train the model
model.fit(
X_train, Y_train,
batch_size=32,
epochs=2,
validation_data=(X_val, Y_val),
verbose=0
)
# Predict probabilities on the validation set
y_probas = model.predict(X_val)
# Plot the data
import matplotlib.pyplot as plt
import scikitplot as sp
# sp.get_logger().setLevel(sp.sp_logging.WARNING)
sp.logger.setLevel(sp.logger.INFO) # default WARNING
# Plot precision-recall curves
sp.metrics.plot_precision_recall(
y_val, y_probas,
)
Pretty.
Although Scikit-plot is loosely based around the scikit-learn interface, you don't actually need scikit-learn objects to use the available functions. As long as you provide the functions what they're asking for, they'll happily draw the plots for you.
The possibilities are endless.
See the changelog for a history of notable changes to scikit-plots.
Reporting a bug? Suggesting a feature? Want to add your own plot to the library? Visit our.
The Scikit-plots Project is made both by and for its users, so we welcome and encourage contributions of many kinds. Our goal is to keep this a positive, inclusive, successful, and growing community that abides by the Scikit-plots Community Code of Conduct.
For guidance on contributing to or submitting feedback for the Scikit-plots Project,
see the contributions page.
For contributing code specifically, the developer docs have a
guide with a quickstart
.
There's also a summary of contribution guidelines.
GitHub Codespaces is a cloud development environment using Visual Studio Code in your browser. This is a convenient way to start developing Scikit-plots, using our dev container configured with the required packages. For help, see the GitHub Codespaces docs.
See the Acknowledgement, Citation Guide and the CITATION.bib, CITATION.cff file.
scikit-plots, βscikit-plots: vlatestβ. Zenodo, Aug. 23, 2024. DOI: 10.5281/zenodo.13367000.
scikit-plots, βscikit-plots: v0.3.8dev0β. Zenodo, Aug. 23, 2024. DOI: 10.5281/zenodo.13367001.
NumFOCUS, a 501(c)(3) nonprofit in the United States.
Scikit-plots is licensed under a 3-clause BSD style license - see the LICENSE file, and LICENSES files.