The quickest and easiest way to go from analysis...
๐ฆ From
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:
venv
pipenv
) to Avoid Conflicts.base
โ it's prone to conflicts.# (conda or mamba) Create New Env and install ``scikit-plots``
# Create a new environment and install Python 3.11 with IPython kernel support
mamba create -n py311 python=3.11 ipykernel -y
# Activate the environment
conda activate py311
pypi
:
# Now Install scikit-plots (via pip, conda, or local source)
pip install scikit-plots
pypi.anaconda.org
(with
required runtime dependencies
):## (Optionally) Install the lost packages "Runtime dependencies"
## 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 versionGITHUB
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]
๐ From Source
Installation by
Archive
or
GIT Clone
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.scikit-plots
directly from the GitHub Source Code Repository
to access the latest updates..tar.gz
)
are also available for direct installation via PyPI (sdist)
, if applicable..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
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
.
## Forked repo: https://github.com/scikit-plots/scikit-plots.git
git clone https://github.com/YOUR-USER-NAME/scikit-plots.git
cd scikit-plots
## (Optionally) Add safe directories for git
# bash docker/script/safe_dirs.sh
git config --global --add safe.directory '*'
## download submodules
git submodule update --init
# pip install -r ./requirements/all.txt
pip install -r ./requirements/build.txt
## Install development version
pip install --no-cache-dir -e . -v
๐ง๐ง It is also possible to include optional dependencies:
## https://github.com/celik-muhammed/scikit-plots/tree/main/requirements
## (Optionally) Try Development [build,dev,test,doc]
## For More in Doc: https://scikit-plots.github.io/
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.