class_docstr: A :py:class:`~ray.train.Checkpoint` with sklearn-specific functionality.
class_docstr_tok: ["A",":","py",":","class",":","`","~ray.train.Checkpoint","`","with","sklearn-specific","functionality","."]
docstr: Create a :py:class:`~ray.train.Checkpoint` that stores an sklearn
  ``Estimator``.
  
  Args:
      estimator: The ``Estimator`` to store in the checkpoint.
      path: The directory where the checkpoint will be stored.
          Defaults to a temporary directory.
      preprocessor: A fitted preprocessor to be applied before inference.
  
  Returns:
      An :py:class:`SklearnCheckpoint` containing the specified ``Estimator``.
  
  Examples:
      >>> from ray.train.sklearn import SklearnCheckpoint
      >>> from sklearn.ensemble import RandomForestClassifier
      >>>
      >>> estimator = RandomForestClassifier()
      >>> checkpoint = SklearnCheckpoint.from_estimator(estimator, path=".")
docstr_tok: ["Create","a",":","py",":","class",":","`","~ray.train.Checkpoint","`","that","stores","an","sklearn","``","Estimator","``",".","Args",":","estimator",":","The","``","Estimator","``","to","store","in","the","checkpoint",".","path",":","The","directory","where","the","checkpoint","will","be","stored",".","Defaults","to","a","temporary","directory",".","preprocessor",":","A","fitted","preprocessor","to","be","applied","before","inference",".","Returns",":","An",":","py",":","class",":","`","SklearnCheckpoint","`","containing","the","specified","``","Estimator","``",".","Examples",":",">",">",">","from","ray.train.sklearn","import","SklearnCheckpoint",">",">",">","from","sklearn.ensemble","import","RandomForestClassifier",">",">",">",">",">",">","estimator","=","RandomForestClassifier","(",")",">",">",">","checkpoint","=","SklearnCheckpoint.from_estimator","(","estimator",",","path=","''",".","''",")"]
code: def from_estimator(
      cls,
      estimator: BaseEstimator,
      *,
      path: Union[str, os.PathLike] = None,
      preprocessor: Optional["Preprocessor"] = None,
  ) -> "SklearnCheckpoint":
      """Create a :py:class:`~ray.train.Checkpoint` that stores an sklearn
      ``Estimator``.
  
      Args:
          estimator: The ``Estimator`` to store in the checkpoint.
          path: The directory where the checkpoint will be stored.
              Defaults to a temporary directory.
          preprocessor: A fitted preprocessor to be applied before inference.
  
      Returns:
          An :py:class:`SklearnCheckpoint` containing the specified ``Estimator``.
  
      Examples:
          >>> from ray.train.sklearn import SklearnCheckpoint
          >>> from sklearn.ensemble import RandomForestClassifier
          >>>
          >>> estimator = RandomForestClassifier()
          >>> checkpoint = SklearnCheckpoint.from_estimator(estimator, path=".")
      """
      path = path or tempfile.mkdtemp()
  
      with open(os.path.join(path, cls.MODEL_FILENAME), "wb") as f:
          cpickle.dump(estimator, f)
  
      checkpoint = cls.from_directory(path)
      if preprocessor:
          checkpoint.set_preprocessor(preprocessor)
  
      return checkpoint
  
file_path: ray/python/ray/train/sklearn/sklearn_checkpoint.py
imports: import os
  import tempfile
  from typing import TYPE_CHECKING, Optional, Union
  from sklearn.base import BaseEstimator
  import ray.cloudpickle
  from ray.train._internal.framework_checkpoint import FrameworkCheckpoint
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 1 for calling the SklearnCheckpoint obj's underlying member method code with example usage: obj.from_estimator(cls, estimator) and returns: checkpoint