class_docstr: Gaussian Process Global Optimization(GPGO)
  
  This class uses Gaussian Process optimization to select
  hyperparameters. Underneath the hood it uses pyGPGO to optimize
  models. If you don't have pyGPGO installed, you won't be able to use
  this class.
  
  Note that `params_dict` has a different semantics than for
  `GridHyperparamOpt`. `param_dict[hp]` must be an int/float and is
  used as the center of a search range.
  
  Examples
  --------
  This example shows the type of constructor function expected.
  
  >>> import deepchem as dc
  >>> optimizer = dc.hyper.GaussianProcessHyperparamOpt(lambda **p: dc.models.GraphConvModel(n_tasks=1, **p))
  
  Here's a more sophisticated example that shows how to optimize only
  some parameters of a model. In this case, we have some parameters we
  want to optimize, and others which we don't. To handle this type of
  search, we create a `model_builder` which hard codes some arguments
  (in this case, `n_tasks` and `n_features` which are properties of a
  dataset and not hyperparameters to search over.)
  
  >>> import numpy as np
  >>> from sklearn.ensemble import RandomForestRegressor as RF
  >>> def model_builder(**model_params):
  ...   n_estimators = model_params['n_estimators']
  ...   min_samples_split = model_params['min_samples_split']
  ...   rf_model = RF(n_estimators=n_estimators, min_samples_split=min_samples_split)
  ...   rf_model = RF(n_estimators=n_estimators)
  ...   return dc.models.SklearnModel(rf_model)
  >>> optimizer = dc.hyper.GaussianProcessHyperparamOpt(model_builder)
  >>> params_dict = {"n_estimators":100, "min_samples_split":2}
  >>> train_dataset = dc.data.NumpyDataset(X=np.random.rand(50, 5),
  ...   y=np.random.rand(50, 1))
  >>> valid_dataset = dc.data.NumpyDataset(X=np.random.rand(20, 5),
  ...   y=np.random.rand(20, 1))
  >>> metric = dc.metrics.Metric(dc.metrics.pearson_r2_score)
  
  >> best_model, best_hyperparams, all_results =    optimizer.hyperparam_search(params_dict, train_dataset, valid_dataset, metric, max_iter=2)
  >> type(best_hyperparams)
  <class 'dict'>
  
  Parameters
  ----------
  model_builder: constructor function.
      This parameter must be constructor function which returns an
      object which is an instance of `dc.models.Model`. This function
      must accept two arguments, `model_params` of type `dict` and
      `model_dir`, a string specifying a path to a model directory.
  max_iter: int, default 20
      number of optimization trials
  search_range: int/float/Dict (default 4)
      The `search_range` specifies the range of parameter values to
      search for. If `search_range` is an int/float, it is used as the
      global search range for parameters. This creates a search
      problem on the following space:
  
      optimization on [initial value / search_range,
                      initial value * search_range]
  
      If `search_range` is a dict, it must contain the same keys as
      for `params_dict`. In this case, `search_range` specifies a
      per-parameter search range. This is useful in case some
      parameters have a larger natural range than others. For a given
      hyperparameter `hp` this would create the following search
      range:
  
      optimization on hp on [initial value[hp] / search_range[hp],
                            initial value[hp] * search_range[hp]]
  
  Notes
  -----
  This class requires pyGPGO to be installed.
class_docstr_tok: ["Gaussian","Process","Global","Optimization","(","GPGO",")","This","class","uses","Gaussian","Process","optimization","to","select","hyperparameters",".","Underneath","the","hood","it","uses","pyGPGO","to","optimize","models",".","If","you","do","n't","have","pyGPGO","installed",",","you","wo","n't","be","able","to","use","this","class",".","Note","that","`","params_dict","`","has","a","different","semantics","than","for","`","GridHyperparamOpt","`",".","`","param_dict","[","hp","]","`","must","be","an","int\/float","and","is","used","as","the","center","of","a","search","range",".","Examples","--","--","--","--","This","example","shows","the","type","of","constructor","function","expected",".",">",">",">","import","deepchem","as","dc",">",">",">","optimizer","=","dc.hyper.GaussianProcessHyperparamOpt","(","lambda","*","*","p",":","dc.models.GraphConvModel","(","n_tasks=1",",","*","*","p",")",")","Here","'s","a","more","sophisticated","example","that","shows","how","to","optimize","only","some","parameters","of","a","model",".","In","this","case",",","we","have","some","parameters","we","want","to","optimize",",","and","others","which","we","do","n't",".","To","handle","this","type","of","search",",","we","create","a","`","model_builder","`","which","hard","codes","some","arguments","(","in","this","case",",","`","n_tasks","`","and","`","n_features","`","which","are","properties","of","a","dataset","and","not","hyperparameters","to","search","over",".",")",">",">",">","import","numpy","as","np",">",">",">","from","sklearn.ensemble","import","RandomForestRegressor","as","RF",">",">",">","def","model_builder","(","*","*","model_params",")",":","...","n_estimators","=","model_params","[","'n_estimators","'","]","...","min_samples_split","=","model_params","[","'min_samples_split","'","]","...","rf_model","=","RF","(","n_estimators=n_estimators",",","min_samples_split=min_samples_split",")","...","rf_model","=","RF","(","n_estimators=n_estimators",")","...","return","dc.models.SklearnModel","(","rf_model",")",">",">",">","optimizer","=","dc.hyper.GaussianProcessHyperparamOpt","(","model_builder",")",">",">",">","params_dict","=","{","``","n_estimators","''",":100",",","``","min_samples_split","''",":2","}",">",">",">","train_dataset","=","dc.data.NumpyDataset","(","X=np.random.rand","(","50",",","5",")",",","...","y=np.random.rand","(","50",",","1",")",")",">",">",">","valid_dataset","=","dc.data.NumpyDataset","(","X=np.random.rand","(","20",",","5",")",",","...","y=np.random.rand","(","20",",","1",")",")",">",">",">","metric","=","dc.metrics.Metric","(","dc.metrics.pearson_r2_score",")",">",">","best_model",",","best_hyperparams",",","all_results","=","optimizer.hyperparam_search","(","params_dict",",","train_dataset",",","valid_dataset",",","metric",",","max_iter=2",")",">",">","type","(","best_hyperparams",")","<","class","'dict","'",">","Parameters","--","--","--","--","--","model_builder",":","constructor","function",".","This","parameter","must","be","constructor","function","which","returns","an","object","which","is","an","instance","of","`","dc.models.Model","`",".","This","function","must","accept","two","arguments",",","`","model_params","`","of","type","`","dict","`","and","`","model_dir","`",",","a","string","specifying","a","path","to","a","model","directory",".","max_iter",":","int",",","default","20","number","of","optimization","trials","search_range",":","int\/float\/Dict","(","default","4",")","The","`","search_range","`","specifies","the","range","of","parameter","values","to","search","for",".","If","`","search_range","`","is","an","int\/float",",","it","is","used","as","the","global","search","range","for","parameters",".","This","creates","a","search","problem","on","the","following","space",":","optimization","on","[","initial","value","\/","search_range",",","initial","value","*","search_range","]","If","`","search_range","`","is","a","dict",",","it","must","contain","the","same","keys","as","for","`","params_dict","`",".","In","this","case",",","`","search_range","`","specifies","a","per-parameter","search","range",".","This","is","useful","in","case","some","parameters","have","a","larger","natural","range","than","others",".","For","a","given","hyperparameter","`","hp","`","this","would","create","the","following","search","range",":","optimization","on","hp","on","[","initial","value","[","hp","]","\/","search_range","[","hp","]",",","initial","value","[","hp","]","*","search_range","[","hp","]","]","Notes","--","--","-","This","class","requires","pyGPGO","to","be","installed","."]
code: def __init__(
      self,
      model_builder: Callable[..., Model],
      max_iter: int = 20,
      search_range: Union[int, float, Dict] = 4,
  ):
      super(GaussianProcessHyperparamOpt, self).__init__(
          model_builder=model_builder
      )
      self.max_iter = max_iter
      self.search_range = search_range
  
file_path: deepchem/deepchem/hyper/gaussian_process.py
imports: import os
  import logging
  import tempfile
  from typing import Dict, List, Optional, Tuple, Union, Any, Callable
  from deepchem.data import Dataset
  from deepchem.trans import Transformer
  from deepchem.models import Model
  from deepchem.metrics import Metric
  from deepchem.hyper.base_classes import HyperparamOpt
  from deepchem.hyper.base_classes import _convert_hyperparam_dict_to_filename
label_desc: Use image node_id 1 to create a new GaussianProcessHyperparamOpt object from inherited base classes: HyperparamOpt with example: obj = GaussianProcessHyperparamOpt(model_builder, max_iter, search_range)