Vulpes

Code style: black pypi version Documentation Status visitors Downloads

Vulpes: Test many classification, regression models and clustering algorithms to see which one is most suitable for your dataset.

Vulpes 🦊 is a Python package that allows you to test many models, whether you want to do classification, regression or clustering in your projects. It calculates many metrics for each model to compare them. It is highly customizable and it contains many features to save time building robust ML models.

If you like this project, please leave a star ⭐ on GitHub !

Alpha version.

Author & Maintainer: Adrien Carrel.

Installation

Using pip:

pip install vulpes

Dependencies

vulpes requires:

  • Python (>= 3.7)

  • numpy (>= 1.22)

  • pandas (>= 1.3.5)

  • scikit-learn (>= 1.0.2)

  • tqdm (>= 4.64.0)

  • xgboost (>= 1.6.1)

  • lightgbm (>= 3.3.2)

Documentation

Link to the documentation: https://vulpes.readthedocs.io/en/latest/

Examples

General case, import one of the classes Classifiers, Regressions, Clustering from vulpes.automl, add some parameters to the object (optional), fit your dataset:

from vulpes.automl import Classifiers
classifiers = Classifiers()
classifiers.fit(X, y)

More examples below and in notebooks in the folter examples.

Classification

Fit many classification algorithms on the iris dataset from scikit-learn:

import pandas as pd
from sklearn.datasets import load_iris
from vulpes.automl import Classifiers

dataset = load_iris()
X = pd.DataFrame(dataset["data"], columns=dataset["feature_names"])
y = dataset["target"]

classifiers = Classifiers(preprocessing="default")
df_models = classifiers.fit(X, y)
df_models

Analysis of each model using different metrics and repeated cross-validation by K-fold:

Here, the “default” preprocessing pipeline has been used. It consists of SimpleImputer (median strategy) with a StandardScaler for the features and a OneHotEncoder for the categorical features.

Regressions

Fit many regression algorithms:

from sklearn.datasets import make_regression
from vulpes.automl import Regressions

X, y = make_regression(
          n_samples=100, n_features=4, random_state=42, noise=4.0,
          bias=100.0)

regressions = Regressions()
df_models = regressions.fit(X, y)
df_models

Clustering

Fit many clustering algorithms on the iris dataset from scikit-learn:

import pandas as pd
from sklearn.datasets import load_iris
from vulpes.automl import Clustering

dataset = load_iris()
X = pd.DataFrame(dataset["data"], columns=dataset["feature_names"])

clustering = Clustering()
df_models = clustering.fit(X)
df_models

Fit a “best model”

We can automatically build a VotingClassifier or a VotingRegressor using the build_best_models method once the models are fitted.

df_best = classifiers.build_best_models(X, y, nb_models=3)
df_best

Model

Balanced Accuracy

Accuracy

Precision

Recall

F1 Score

Running time

Voting (3-best)

0.97508

0.974667

0.976034

0.97508

0.974447

11.82946

Check missing data

import pandas as pd
import numpy as np
df = pd.DataFrame([["a", "x"],
                   [np.nan, "y"],
                   ["a", np.nan],
                   ["b", np.nan]],
                  dtype="category",
                  columns=["feature1", "feature2"])
classifiers.missing_data(df)

Total Missing

Percentage (%)

Accuracy

feature2

2

50.0

feature1

1

25.0

Testing

If you want to submit a pull request or if you want to test in local the package, you can run some tests with the library pytest by running the following command:

pytest vulpes/tests/

Why Vulpes?

Vulpes stands for: Vector (Un)supervised Learning Program Estimation System.

Nah, I’m kidding, I just love foxes, they are cute! The most common and widespread species of fox is the red fox (Vulpes vulpes).

alt text

Acknowledgment

  • Shankar Rao Pandala (and some contributors). Their package (Lazy Predict) has been an inspiration.

License

MIT