class_docstr: A metric that trains and evaluates an sklearn model.
  
  The evaluation metric is the k-fold "score". The scoring function
  depends on the model type and task type (e.g. classification/regression),
  but higher scores are better.
  
  See sklearn documentation for supported parameters.
  
  In addition, this metric supports tuning the hidden_layer_size
  and the number of hidden layers (num_hidden_layers) of a NN model.
class_docstr_tok: ["A","metric","that","trains","and","evaluates","an","sklearn","model",".","The","evaluation","metric","is","the","k-fold","``","score","''",".","The","scoring","function","depends","on","the","model","type","and","task","type","(","e.g",".","classification\/regression",")",",","but","higher","scores","are","better",".","See","sklearn","documentation","for","supported","parameters",".","In","addition",",","this","metric","supports","tuning","the","hidden_layer_size","and","the","number","of","hidden","layers","(","num_hidden_layers",")","of","a","NN","model","."]
docstr: Initialize metric.
  
  Args:
      name: Name of the metric.
      lower_is_better: Flag for metrics which should be minimized.
      model_type: Sklearn model type
      dataset: Sklearn Dataset for training/evaluating the model
      observed_noise: A boolean indicating whether to return the SE
          of the mean k-fold cross-validation score.
      num_folds: The number of cross-validation folds.
docstr_tok: ["Initialize","metric",".","Args",":","name",":","Name","of","the","metric",".","lower_is_better",":","Flag","for","metrics","which","should","be","minimized",".","model_type",":","Sklearn","model","type","dataset",":","Sklearn","Dataset","for","training\/evaluating","the","model","observed_noise",":","A","boolean","indicating","whether","to","return","the","SE","of","the","mean","k-fold","cross-validation","score",".","num_folds",":","The","number","of","cross-validation","folds","."]
code: def __init__(
      self,
      name: str,
      lower_is_better: bool = False,
      model_type: SklearnModelType = SklearnModelType.RF,
      dataset: SklearnDataset = SklearnDataset.DIGITS,
      observed_noise: bool = False,
      num_folds: int = 5,
  ) -> None:
      """Initialize metric.
  
      Args:
          name: Name of the metric.
          lower_is_better: Flag for metrics which should be minimized.
          model_type: Sklearn model type
          dataset: Sklearn Dataset for training/evaluating the model
          observed_noise: A boolean indicating whether to return the SE
              of the mean k-fold cross-validation score.
          num_folds: The number of cross-validation folds.
      """
      super().__init__(name=name, lower_is_better=lower_is_better)
      self.dataset = dataset
      self.model_type = model_type
      self.num_folds = num_folds
      self.observed_noise = observed_noise
      if self.dataset is SklearnDataset.DIGITS:
          regression = False
      elif self.dataset is SklearnDataset.BOSTON:
          regression = True
      elif self.dataset is SklearnDataset.CANCER:
          regression = False
      else:
          raise NotImplementedError(
              f"{self.dataset.value} is not a currently supported {dataset.name}."
          )
      if model_type is SklearnModelType.NN:
          if regression:
              # pyre-fixme[4]: Attribute must be annotated.
              self._model_cls = MLPRegressor
          else:
              self._model_cls = MLPClassifier
      elif model_type is SklearnModelType.RF:
          if regression:
              self._model_cls = RandomForestRegressor
          else:
              self._model_cls = RandomForestClassifier
      else:
          raise NotImplementedError(
              f"{model_type.value} is not a currently supported {model_type.name}."
          )
  
imports: from __future__ import annotations
  from copy import deepcopy
  from enum import Enum
  from functools import lru_cache
  from math import sqrt
  from typing import Any, Dict, Tuple
  import numpy
  import pandas
  from ax.core.arm import Arm
  from ax.core.base_trial import BaseTrial
  from ax.core.data import Data
  from ax.core.metric import Metric, MetricFetchE, MetricFetchResult
  from ax.utils.common.result import Err, Ok
  from ax.utils.common.typeutils import checked_cast
  from sklearn import datasets
  from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
  from sklearn.model_selection import cross_val_score
  from sklearn.neural_network import MLPClassifier, MLPRegressor
label_desc: Use image node_id 1 to create a new SklearnMetric object from inherited base classes: Metric with example: obj = SklearnMetric(name, lower_is_better, model_type, dataset, observed_noise, num_folds)