class_docstr: Wrapper class that wraps scikit-learn models as DeepChem models.
  
  When you're working with scikit-learn and DeepChem, at times it can
  be useful to wrap a scikit-learn model as a DeepChem model. The
  reason for this might be that you want to do an apples-to-apples
  comparison of a scikit-learn model to another DeepChem model, or
  perhaps you want to use the hyperparameter tuning capabilities in
  `dc.hyper`. The `SklearnModel` class provides a wrapper around scikit-learn
  models that allows scikit-learn models to be trained on `Dataset` objects
  and evaluated with the same metrics as other DeepChem models.
  
  Example
  ------
  >>> import deepchem as dc
  >>> import numpy as np
  >>> from sklearn.linear_model import LinearRegression
  >>> # Generating a random data and creating a dataset
  >>> X, y = np.random.randn(5, 1), np.random.randn(5)
  >>> dataset = dc.data.NumpyDataset(X, y)
  >>> # Wrapping a Sklearn Linear Regression model using DeepChem models API
  >>> sklearn_model = LinearRegression()
  >>> dc_model = dc.models.SklearnModel(sklearn_model)
  >>> dc_model.fit(dataset)  # fitting dataset
  
  Notes
  -----
  All `SklearnModels` perform learning solely in memory. This means that it
  may not be possible to train `SklearnModel` on large `Dataset`s.
class_docstr_tok: ["Wrapper","class","that","wraps","scikit-learn","models","as","DeepChem","models",".","When","you","'re","working","with","scikit-learn","and","DeepChem",",","at","times","it","can","be","useful","to","wrap","a","scikit-learn","model","as","a","DeepChem","model",".","The","reason","for","this","might","be","that","you","want","to","do","an","apples-to-apples","comparison","of","a","scikit-learn","model","to","another","DeepChem","model",",","or","perhaps","you","want","to","use","the","hyperparameter","tuning","capabilities","in","`","dc.hyper","`",".","The","`","SklearnModel","`","class","provides","a","wrapper","around","scikit-learn","models","that","allows","scikit-learn","models","to","be","trained","on","`","Dataset","`","objects","and","evaluated","with","the","same","metrics","as","other","DeepChem","models",".","Example","--","--","--",">",">",">","import","deepchem","as","dc",">",">",">","import","numpy","as","np",">",">",">","from","sklearn.linear_model","import","LinearRegression",">",">",">","#","Generating","a","random","data","and","creating","a","dataset",">",">",">","X",",","y","=","np.random.randn","(","5",",","1",")",",","np.random.randn","(","5",")",">",">",">","dataset","=","dc.data.NumpyDataset","(","X",",","y",")",">",">",">","#","Wrapping","a","Sklearn","Linear","Regression","model","using","DeepChem","models","API",">",">",">","sklearn_model","=","LinearRegression","(",")",">",">",">","dc_model","=","dc.models.SklearnModel","(","sklearn_model",")",">",">",">","dc_model.fit","(","dataset",")","#","fitting","dataset","Notes","--","--","-","All","`","SklearnModels","`","perform","learning","solely","in","memory",".","This","means","that","it","may","not","be","possible","to","train","`","SklearnModel","`","on","large","`","Dataset","`","s","."]
docstr: Parameters
  ----------
  model: BaseEstimator
      The model instance which inherits a scikit-learn `BaseEstimator` Class.
  model_dir: str, optional (default None)
      If specified the model will be stored in this directory. Else, a
      temporary directory will be used.
  model_instance: BaseEstimator (DEPRECATED)
      The model instance which inherits a scikit-learn `BaseEstimator` Class.
  kwargs: dict
      kwargs['use_weights'] is a bool which determines if we pass weights into
      self.model.fit().
docstr_tok: ["Parameters","--","--","--","--","--","model",":","BaseEstimator","The","model","instance","which","inherits","a","scikit-learn","`","BaseEstimator","`","Class",".","model_dir",":","str",",","optional","(","default","None",")","If","specified","the","model","will","be","stored","in","this","directory",".","Else",",","a","temporary","directory","will","be","used",".","model_instance",":","BaseEstimator","(","DEPRECATED",")","The","model","instance","which","inherits","a","scikit-learn","`","BaseEstimator","`","Class",".","kwargs",":","dict","kwargs","[","'use_weights","'","]","is","a","bool","which","determines","if","we","pass","weights","into","self.model.fit","(",")","."]
code: def __init__(
      self,
      model: BaseEstimator,
      model_dir: Optional[str] = None,
      **kwargs,
  ):
      """
      Parameters
      ----------
      model: BaseEstimator
          The model instance which inherits a scikit-learn `BaseEstimator` Class.
      model_dir: str, optional (default None)
          If specified the model will be stored in this directory. Else, a
          temporary directory will be used.
      model_instance: BaseEstimator (DEPRECATED)
          The model instance which inherits a scikit-learn `BaseEstimator` Class.
      kwargs: dict
          kwargs['use_weights'] is a bool which determines if we pass weights into
          self.model.fit().
      """
      if "model_instance" in kwargs:
          model_instance = kwargs["model_instance"]
          if model is not None:
              raise ValueError(
                  "Can not use both model and model_instance argument at the same time."
              )
          logger.warning(
              "model_instance argument is deprecated and will be removed in a future version of DeepChem."
              "Use model argument instead."
          )
          model = model_instance
  
      super(SklearnModel, self).__init__(model, model_dir, **kwargs)
      if "use_weights" in kwargs:
          self.use_weights = kwargs["use_weights"]
      else:
          self.use_weights = True
  
      if self.use_weights and self.model is not None:
          # model is None when reloading a model
          if (
              "sample_weight"
              not in inspect.getfullargspec(self.model.fit).args
          ):
              self.use_weights = False
              logger.info(
                  "The model does not support training with weights."
                  "Hence, not using weight of datapoint for training"
              )
  
file_path: deepchem/deepchem/models/sklearn_models/sklearn_model.py
imports: import inspect
  import logging
  from typing import List, Optional
  import numpy
  from sklearn.base import BaseEstimator
  from deepchem.models import Model
  from deepchem.data import Dataset
  from deepchem.trans import Transformer
  from deepchem.utils.data_utils import load_from_disk, save_to_disk
  from deepchem.utils.typing import OneOrMany
label_desc: Use image node_id 1 to create a new SklearnModel object from inherited base classes: Model with example: obj = SklearnModel(model, model_dir)