class_docstr: This class takes the function to optimize as well as the parameters bounds
  in order to find which values for the parameters yield the maximum value
  using bayesian optimization.
  
  Parameters
  ----------
  fun: function
      Constraint function. If multiple constraints are handled, this should
      return a numpy.ndarray of appropriate size.
  
  lb: numeric or numpy.ndarray
      Upper limit(s) for the constraints. The return value of `fun` should
      have exactly this shape.
  
  ub: numeric or numpy.ndarray
      Upper limit(s) for the constraints. The return value of `fun` should
      have exactly this shape.
  
  random_state: int or numpy.random.RandomState, optional(default=None)
      If the value is an integer, it is used as the seed for creating a
      numpy.random.RandomState. Otherwise the random state provided is used.
      When set to None, an unseeded random state is generated.
  
  Note
  ----
  In case of multiple constraints, this model assumes conditional
  independence. This means that for each constraint, the probability of
  fulfillment is the cdf of a univariate Gaussian. The overall probability
  is a simply the product of the individual probabilities.
class_docstr_tok: ["This","class","takes","the","function","to","optimize","as","well","as","the","parameters","bounds","in","order","to","find","which","values","for","the","parameters","yield","the","maximum","value","using","bayesian","optimization",".","Parameters","--","--","--","--","--","fun",":","function","Constraint","function",".","If","multiple","constraints","are","handled",",","this","should","return","a","numpy.ndarray","of","appropriate","size",".","lb",":","numeric","or","numpy.ndarray","Upper","limit","(","s",")","for","the","constraints",".","The","return","value","of","`","fun","`","should","have","exactly","this","shape",".","ub",":","numeric","or","numpy.ndarray","Upper","limit","(","s",")","for","the","constraints",".","The","return","value","of","`","fun","`","should","have","exactly","this","shape",".","random_state",":","int","or","numpy.random.RandomState",",","optional","(","default=None",")","If","the","value","is","an","integer",",","it","is","used","as","the","seed","for","creating","a","numpy.random.RandomState",".","Otherwise","the","random","state","provided","is","used",".","When","set","to","None",",","an","unseeded","random","state","is","generated",".","Note","--","--","In","case","of","multiple","constraints",",","this","model","assumes","conditional","independence",".","This","means","that","for","each","constraint",",","the","probability","of","fulfillment","is","the","cdf","of","a","univariate","Gaussian",".","The","overall","probability","is","a","simply","the","product","of","the","individual","probabilities","."]
docstr: Returns the probability that the constraint is fulfilled at `X` based
  on the internal Gaussian Process Regressors.
  
  Note that this does not try to approximate the values of the constraint
  function, but probability that the constraint function is fulfilled.
  For the former, see `ConstraintModel.approx()`.
docstr_tok: ["Returns","the","probability","that","the","constraint","is","fulfilled","at","`","X","`","based","on","the","internal","Gaussian","Process","Regressors",".","Note","that","this","does","not","try","to","approximate","the","values","of","the","constraint","function",",","but","probability","that","the","constraint","function","is","fulfilled",".","For","the","former",",","see","`","ConstraintModel.approx","(",")","`","."]
code: def predict(self, X):
      """
      Returns the probability that the constraint is fulfilled at `X` based
      on the internal Gaussian Process Regressors.
  
      Note that this does not try to approximate the values of the constraint
      function, but probability that the constraint function is fulfilled.
      For the former, see `ConstraintModel.approx()`.
      """
      X_shape = X.shape
      X = X.reshape((-1, self._model[0].n_features_in_))
      if len(self._model) == 1:
          y_mean, y_std = self._model[0].predict(X, return_std=True)
  
          p_lower = (
              norm(loc=y_mean, scale=y_std).cdf(self._lb[0])
              if self._lb[0] != -np.inf
              else np.array([0])
          )
          p_upper = (
              norm(loc=y_mean, scale=y_std).cdf(self._ub[0])
              if self._lb[0] != np.inf
              else np.array([1])
          )
          result = p_upper - p_lower
          return result.reshape(X_shape[:-1])
      else:
          result = np.ones(X.shape[0])
          for j, gp in enumerate(self._model):
              y_mean, y_std = gp.predict(X, return_std=True)
              p_lower = (
                  norm(loc=y_mean, scale=y_std).cdf(self._lb[j])
                  if self._lb[j] != -np.inf
                  else np.array([0])
              )
              p_upper = (
                  norm(loc=y_mean, scale=y_std).cdf(self._ub[j])
                  if self._lb[j] != np.inf
                  else np.array([1])
              )
              result = result * (p_upper - p_lower)
          return result.reshape(X_shape[:-1])
  
file_path: BayesianOptimization/bayes_opt/constraint.py
imports: import numpy
  from sklearn.gaussian_process.kernels import Matern
  from sklearn.gaussian_process import GaussianProcessRegressor
  from scipy.stats import norm
label_desc: Use image node_id 7 for calling the ConstraintModel obj's underlying member method code with example usage: obj.predict(X) and returns: result, result