ray.train.sklearn.SklearnCheckpoint.from_estimator
ray.train.sklearn.SklearnCheckpoint.from_estimator#
- classmethod SklearnCheckpoint.from_estimator(estimator: sklearn.base.BaseEstimator, *, path: os.PathLike, preprocessor: Optional[Preprocessor] = None) SklearnCheckpoint[source]#
Create a
Checkpointthat stores an sklearnEstimator.- Parameters
estimator – The
Estimatorto store in the checkpoint.path – The directory where the checkpoint will be stored.
preprocessor – A fitted preprocessor to be applied before inference.
- Returns
An
SklearnCheckpointcontaining the specifiedEstimator.
Examples
>>> from ray.train.sklearn import SklearnCheckpoint >>> from sklearn.ensemble import RandomForestClassifier >>> >>> estimator = RandomForestClassifier() >>> checkpoint = SklearnCheckpoint.from_estimator(estimator, path=".")
You can use a
SklearnCheckpointto create anSklearnPredictorand preform inference.>>> from ray.train.sklearn import SklearnPredictor >>> >>> predictor = SklearnPredictor.from_checkpoint(checkpoint)