Supported Models#
OpenModels supports every scikit-learn estimator, out of the box. The library has been tested against scikit-learn versions 1.6.1, 1.7.2, 1.8.0, and 1.9.0.
scikit-learn#
All scikit-learn estimators are supported, including:
Regressors#
All scikit-learn regressors are supported, including:
LinearRegression,Ridge,Lasso,ElasticNetSVR,NuSVRKNeighborsRegressor,RadiusNeighborsRegressorGaussianProcessRegressorGradientBoostingRegressor,HistGradientBoostingRegressorPLSRegression,CCA,PLSCanonicalIsotonicRegression,TransformedTargetRegressorPoissonRegressor,GammaRegressor,TweedieRegressorAnd many more…
Classifiers#
All scikit-learn classifiers are supported, including:
LogisticRegression,RidgeClassifier,RidgeClassifierCVSVC,NuSVCKNeighborsClassifier,RadiusNeighborsClassifierGradientBoostingClassifier,HistGradientBoostingClassifierMLPClassifierStackingClassifierTunedThresholdClassifierCVDummyClassifierAnd many more…
Clustering#
All scikit-learn clustering estimators are supported, including:
KMeans,MiniBatchKMeansBisectingKMeansBirchAnd many more…
Transformers#
All scikit-learn transformers are supported, including:
PCA,KernelPCAOneHotEncoder,OrdinalEncoder,LabelBinarizerColumnTransformerSimpleImputer,KNNImputerPowerTransformer,PolynomialFeaturesTfidfVectorizerTargetEncoder,KBinsDiscretizerPatchExtractor(expects an(n_images, height, width[, n_channels])image-batch array, not standard 2D tabular data)And many more…
Other Estimators#
All other scikit-learn estimators are supported, including:
IsolationForestOneClassSVMNearestNeighborsLocalOutlierFactor(requiresnovelty=Trueforpredict()- a scikit-learn API restriction, not an openmodels one; the defaultnovelty=Falsemode isfit_predict()-only and has nopredict()to round-trip)And many more…
Every scikit-learn estimator discoverable via SklearnSerializer.all_estimators() is supported -
see Serialized Model Format for the details of what gets serialized.
Resuming Training#
A loaded model is meant for inference: predict, transform, score and the other methods
that use the fitted model give the same results as the original.
Continuing to train a loaded model - partial_fit, or warm_start=True and fit again -
works for most estimators that support it, and gives the same model as continuing on the
original. These estimators can’t resume yet, because state they only use while training isn’t
saved:
Estimator |
Can’t resume with |
|---|---|
|
|
|
|
|
|
|
|
For these, fit a new model on all the data instead. Support for resuming training on every estimator is planned for openmodels 0.3.
Custom & Third-Party Estimators#
OpenModels supports custom estimators that follow scikit-learn’s API via the
custom_estimators parameter in SklearnSerializer.
chemotools#
chemotools (>= 0.2.2) is a scikit-learn compatible
library for chemometrics preprocessing. It is fully supported via its built-in
all_estimators discovery function:
from openmodels import SerializationManager, SklearnSerializer
from chemotools.utils.discovery import all_estimators
from chemotools.derivative import SavitzkyGolay
from sklearn.cross_decomposition import PLSRegression
from sklearn.pipeline import make_pipeline
# Build and fit a pipeline with chemotools + sklearn
pipeline = make_pipeline(
SavitzkyGolay(window_size=3, polynomial_order=1, derivate_order=1),
PLSRegression(n_components=2),
)
pipeline.fit(X_train, y_train)
# Serialize with custom estimators
serializer = SklearnSerializer(custom_estimators=all_estimators)
manager = SerializationManager(serializer)
serialized = manager.serialize(pipeline)
restored = manager.deserialize(serialized)
Other Third-Party Packages#
You can pass any compatible all_estimators function, list, or dictionary to
SklearnSerializer(custom_estimators=...) to extend support for your own estimators:
manager = SerializationManager(
SklearnSerializer(custom_estimators=my_custom_estimators)
)
If you maintain a scikit-learn compatible package and would like official support, please open an issue.
Serialization Formats#
OpenModels ships with two built-in format converters:
Format |
Converter |
Human-Readable |
|---|---|---|
JSON |
|
Yes |
Pickle |
|
No |
Custom formats can be added by implementing the FormatConverter protocol and
registering with FormatRegistry. See the Getting Started guide for details.