Want to share your content on python-bloggers? click here.
Version v0.15.0
of nnetsauce
is now available on your favorite platforms: PyPI, conda and GitHub for Python; R universe and GitHub for R.
The changes in this version are mostly related to Automated Machine learning (AutoML):
- lazy prediction for classification and regression: see this post for more details on the subject (and remember to use
pip install nnetsauce
directly, instead of installing from a GitHub branch namedlazy-predict
) - lazy prediction for multivariate time series (MTS): see this post for more details on the subject (and remember to use
pip install nnetsauce
directly, instead of installing from a GitHub branch namedlazy-predict
) - lazy prediction with deep quasi-randomized nnetworks will be described in this post
Note that in the example below, for the offically released version (v0.15.0), Gradient boosting classifiers are available. This doesn’t change the best model chosen by the algorithm (which is never Gradient boosting, because the deep model is already doing “too much”). Not sure if Gradient boosting will be kept as a default model here because, in this context, it’s relatively slow.
To finish, for Windows users, if you run into issues when trying to install nnetsauce
(but you shouldn’t): remember that you can use the Windows Subsystem for Linux (WSL).
Contents
- 0 – Install and import packages
- 1 – breast cancer data
- 2 – iris data
- 3 – wine data
- 4 – digits data
- 5 – R examples
Here is a jupyter notebook allowing you to reproduce these results. Do not hesitate
to modify these examples by choosing – in LazyDeepClassifier
– a different number of layers n_layers
, or the number of
engineered features per layer, n_hidden_features
.
0 – Install and import packages
!pip install nnetsauce --upgrade
import os import nnetsauce as ns import matplotlib.pyplot as plt from sklearn.datasets import load_breast_cancer, load_iris, load_wine, load_digits from sklearn.model_selection import train_test_split from sklearn.metrics import classification_report, ConfusionMatrixDisplay from time import time
1 – breast cancer data
data = load_breast_cancer() X = data.data y= data.target X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = .2, random_state = 123) clf = ns.LazyDeepClassifier(n_layers=3, verbose=0, ignore_warnings=True) start = time() models, predictions = clf.fit(X_train, X_test, y_train, y_test) print(f"\n\n Elapsed: {time()-start} seconds \n") model_dictionary = clf.provide_models(X_train, X_test, y_train, y_test) display(models)
100%|██████████| 27/27 [00:44<00:00, 1.65s/it] Elapsed: 44.49836850166321 seconds
Accuracy | Balanced Accuracy | ROC AUC | F1 Score | Time Taken | |
---|---|---|---|---|---|
Model | |||||
Perceptron | 0.99 | 0.99 | 0.99 | 0.99 | 2.15 |
SGDClassifier | 0.98 | 0.98 | 0.98 | 0.98 | 1.99 |
RandomForestClassifier | 0.98 | 0.98 | 0.98 | 0.98 | 2.76 |
PassiveAggressiveClassifier | 0.98 | 0.98 | 0.98 | 0.98 | 1.89 |
LogisticRegression | 0.98 | 0.98 | 0.98 | 0.98 | 1.14 |
ExtraTreesClassifier | 0.98 | 0.98 | 0.98 | 0.98 | 3.13 |
BaggingClassifier | 0.97 | 0.97 | 0.97 | 0.97 | 1.62 |
LabelPropagation | 0.97 | 0.97 | 0.97 | 0.97 | 1.69 |
LabelSpreading | 0.97 | 0.97 | 0.97 | 0.97 | 1.08 |
AdaBoostClassifier | 0.97 | 0.97 | 0.97 | 0.97 | 3.42 |
LinearSVC | 0.97 | 0.97 | 0.97 | 0.97 | 1.65 |
KNeighborsClassifier | 0.97 | 0.97 | 0.97 | 0.97 | 1.07 |
SVC | 0.97 | 0.96 | 0.96 | 0.97 | 1.07 |
CalibratedClassifierCV | 0.97 | 0.96 | 0.96 | 0.97 | 1.82 |
DecisionTreeClassifier | 0.96 | 0.96 | 0.96 | 0.96 | 1.50 |
QuadraticDiscriminantAnalysis | 0.96 | 0.95 | 0.95 | 0.96 | 1.16 |
LinearDiscriminantAnalysis | 0.96 | 0.95 | 0.95 | 0.96 | 1.39 |
ExtraTreeClassifier | 0.96 | 0.94 | 0.94 | 0.96 | 0.83 |
RidgeClassifier | 0.96 | 0.94 | 0.94 | 0.96 | 3.15 |
RidgeClassifierCV | 0.96 | 0.94 | 0.94 | 0.96 | 1.51 |
GaussianNB | 0.93 | 0.90 | 0.90 | 0.93 | 1.50 |
NearestCentroid | 0.93 | 0.90 | 0.90 | 0.93 | 3.00 |
NuSVC | 0.93 | 0.90 | 0.90 | 0.93 | 1.27 |
BernoulliNB | 0.91 | 0.89 | 0.89 | 0.91 | 1.15 |
DummyClassifier | 0.64 | 0.50 | 0.50 | 0.50 | 0.96 |
model_dictionary["Perceptron"]
CustomClassifier(obj=CustomClassifier(obj=CustomClassifier(obj=Perceptron(random_state=42))))
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.