class_docstr: Abstract implementation of the surrogate model.
  
  Note
  ----
  The input dimensionality of Y for training and the output dimensions of all predictions depend on the concrete
  implementation of this abstract class.
  
  Parameters
  ----------
  configspace : ConfigurationSpace
  instance_features : dict[str, list[int | float]] | None, defaults to None
      Features (list of int or floats) of the instances (str). The features are incorporated into the X data,
      on which the model is trained on.
  pca_components : float, defaults to 7
      Number of components to keep when using PCA to reduce dimensionality of instance features.
  seed : int
class_docstr_tok: ["Abstract","implementation","of","the","surrogate","model",".","Note","--","--","The","input","dimensionality","of","Y","for","training","and","the","output","dimensions","of","all","predictions","depend","on","the","concrete","implementation","of","this","abstract","class",".","Parameters","--","--","--","--","--","configspace",":","ConfigurationSpace","instance_features",":","dict","[","str",",","list","[","int","|","float","]","]","|","None",",","defaults","to","None","Features","(","list","of","int","or","floats",")","of","the","instances","(","str",")",".","The","features","are","incorporated","into","the","X","data",",","on","which","the","model","is","trained","on",".","pca_components",":","float",",","defaults","to","7","Number","of","components","to","keep","when","using","PCA","to","reduce","dimensionality","of","instance","features",".","seed",":","int"]
docstr: Trains the random forest on X and Y. Internally, calls the method `_train`.
  
  Parameters
  ----------
  X : np.ndarray [#samples, #hyperparameters + #features]
      Input data points.
  Y : np.ndarray [#samples, #objectives]
      The corresponding target values.
  
  Returns
  -------
  self : AbstractModel
docstr_tok: ["Trains","the","random","forest","on","X","and","Y.","Internally",",","calls","the","method","`","_train","`",".","Parameters","--","--","--","--","--","X",":","np.ndarray","[","#","samples",",","#","hyperparameters","+","#","features","]","Input","data","points",".","Y",":","np.ndarray","[","#","samples",",","#","objectives","]","The","corresponding","target","values",".","Returns","--","--","--","-","self",":","AbstractModel"]
code: def train(self: Self, X: np.ndarray, Y: np.ndarray) -> Self:
      """Trains the random forest on X and Y. Internally, calls the method `_train`.
  
      Parameters
      ----------
      X : np.ndarray [#samples, #hyperparameters + #features]
          Input data points.
      Y : np.ndarray [#samples, #objectives]
          The corresponding target values.
  
      Returns
      -------
      self : AbstractModel
      """
      if len(X.shape) != 2:
          raise ValueError(
              "Expected 2d array, got %dd array!" % len(X.shape)
          )
  
      if X.shape[1] != self._n_hps + self._n_features:
          raise ValueError(
              f"Feature mismatch: X should have {self._n_hps} hyperparameters + {self._n_features} features, "
              f"but has {X.shape[1]} in total."
          )
  
      if X.shape[0] != Y.shape[0]:
          raise ValueError(
              "X.shape[0] ({}) != y.shape[0] ({})".format(
                  X.shape[0], Y.shape[0]
              )
          )
  
      # Reduce dimensionality of features if larger than PCA_DIM
      if (
          self._pca_components is not None
          and X.shape[0] > self._pca.n_components
          and self._n_features >= self._pca_components
      ):
          X_feats = X[:, -self._n_features :]
  
          # Scale features
          X_feats = self._scaler.fit_transform(X_feats)
          X_feats = np.nan_to_num(
              X_feats
          )  # if features with max == min
  
          # PCA
          X_feats = self._pca.fit_transform(X_feats)
          X = np.hstack((X[:, : self._n_hps], X_feats))
  
          if hasattr(self, "_types"):
              # For RF, adapt types list
              # if X_feats.shape[0] < self._pca, X_feats.shape[1] == X_feats.shape[0]
              self._types = np.array(
                  np.hstack(
                      (
                          self._types[: self._n_hps],
                          np.zeros(X_feats.shape[1]),
                      )
                  ),
                  dtype=np.uint,
              )  # type: ignore
  
          self._apply_pca = True
      else:
          self._apply_pca = False
  
          if hasattr(self, "_types"):
              self._types = copy.deepcopy(self._initial_types)
  
      return self._train(X, Y)
  
imports: from __future__ import annotations
  from abc import abstractmethod
  from typing import Any, TypeVar
  import copy
  import warnings
  import numpy
  from ConfigSpace import ConfigurationSpace
  from sklearn.decomposition import PCA
  from sklearn.exceptions import NotFittedError
  from sklearn.preprocessing import MinMaxScaler
  from smac.constants import VERY_SMALL_NUMBER
  from smac.utils.configspace import get_types
  from smac.utils.logging import get_logger
label_desc: Use image node_id 3 for calling the AbstractModel obj's underlying member method code with example usage: obj.train(X, Y) and returns: self