class_docstr: The `IntervalEncoder` transformer bends features in `X` with regards to`y`.
  
  We take each column in `X` separately and smooth it towards `y` using the strategy that is defined in `method`.
  
  Note that this allows us to make certain features strictly monotonic in your machine learning model if you follow
  this with an appropriate model.
  
  Parameters
  ----------
  n_chunks : int, default=10
      The number of cuts that makes the interval.
  span : float, default=1.0
      A hyperparameter for the interpolation method, if the method is `"normal"` it resembles the width of the radial
      basis function used to weigh the points. It is ignored if the method is `"increasing"` or `"decreasing"`.
  method : Literal["average", "normal", "increasing", "decreasing"], default="normal"
      The interpolation method used, can be either `"average"`, `"normal"`, `"increasing"` or `"decreasing"`.
  
  Attributes
  ----------
  quantiles_ : np.ndarray of shape (n_features, n_chunks)
      The quantiles that are used to cut the interval.
  heights_ : np.ndarray of shape (n_features, n_chunks)
      The heights of the quantiles that are used to cut the interval.
  n_features_in_ : int
      Number of features seen during `fit`.
  num_cols_ : int
      Deprecated, please use `n_features_in_` instead.
class_docstr_tok: ["The","`","IntervalEncoder","`","transformer","bends","features","in","`","X","`","with","regards","to","`","y","`",".","We","take","each","column","in","`","X","`","separately","and","smooth","it","towards","`","y","`","using","the","strategy","that","is","defined","in","`","method","`",".","Note","that","this","allows","us","to","make","certain","features","strictly","monotonic","in","your","machine","learning","model","if","you","follow","this","with","an","appropriate","model",".","Parameters","--","--","--","--","--","n_chunks",":","int",",","default=10","The","number","of","cuts","that","makes","the","interval",".","span",":","float",",","default=1.0","A","hyperparameter","for","the","interpolation","method",",","if","the","method","is","`","``","normal","''","`","it","resembles","the","width","of","the","radial","basis","function","used","to","weigh","the","points",".","It","is","ignored","if","the","method","is","`","``","increasing","''","`","or","`","``","decreasing","''","`",".","method",":","Literal","[","``","average","''",",","``","normal","''",",","``","increasing","''",",","``","decreasing","''","]",",","default=","''","normal","''","The","interpolation","method","used",",","can","be","either","`","``","average","''","`",",","`","``","normal","''","`",",","`","``","increasing","''","`","or","`","``","decreasing","''","`",".","Attributes","--","--","--","--","--","quantiles_",":","np.ndarray","of","shape","(","n_features",",","n_chunks",")","The","quantiles","that","are","used","to","cut","the","interval",".","heights_",":","np.ndarray","of","shape","(","n_features",",","n_chunks",")","The","heights","of","the","quantiles","that","are","used","to","cut","the","interval",".","n_features_in_",":","int","Number","of","features","seen","during","`","fit","`",".","num_cols_",":","int","Deprecated",",","please","use","`","n_features_in_","`","instead","."]
docstr: Fit the `IntervalEncoder` transformer by computing interpolation quantiles for each column of `X`.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      Training data.
  y : array-like of shape (n_samples,)
      Target values.
  
  Returns
  -------
  self : IntervalEncoder
      The fitted transformer.
  
  Raises
  ------
  ValueError
      - If `method` is not one of `"average"`, `"normal"`, `"increasing"` or `"decreasing"`.
      - If `n_chunks` is not a positive integer.
      - If `span` is not between 0 and 1.
docstr_tok: ["Fit","the","`","IntervalEncoder","`","transformer","by","computing","interpolation","quantiles","for","each","column","of","`","X","`",".","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","Training","data",".","y",":","array-like","of","shape","(","n_samples",",",")","Target","values",".","Returns","--","--","--","-","self",":","IntervalEncoder","The","fitted","transformer",".","Raises","--","--","--","ValueError","-","If","`","method","`","is","not","one","of","`","``","average","''","`",",","`","``","normal","''","`",",","`","``","increasing","''","`","or","`","``","decreasing","''","`",".","-","If","`","n_chunks","`","is","not","a","positive","integer",".","-","If","`","span","`","is","not","between","0","and","1","."]
code: def fit(self, X, y):
      """Fit the `IntervalEncoder` transformer by computing interpolation quantiles for each column of `X`.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Training data.
      y : array-like of shape (n_samples,)
          Target values.
  
      Returns
      -------
      self : IntervalEncoder
          The fitted transformer.
  
      Raises
      ------
      ValueError
          - If `method` is not one of `"average"`, `"normal"`, `"increasing"` or `"decreasing"`.
          - If `n_chunks` is not a positive integer.
          - If `span` is not between 0 and 1.
      """
  
      if self.method not in self._ALLOWED_METHODS:
          raise ValueError(
              f"`method` must be in {self._ALLOWED_METHODS}, got `{self.method}`"
          )
      if self.n_chunks <= 0:
          raise ValueError(
              f"`n_chunks` must be >= 1, received {self.n_chunks}"
          )
      if self.span > 1.0:
          raise ValueError(
              f"Error, we expect 0 <= span <= 1, received span={self.span}"
          )
      if self.span < 0.0:
          raise ValueError(
              f"Error, we expect 0 <= span <= 1, received span={self.span}"
          )
  
      # these two matrices will have shape (columns, quantiles)
      # quantiles indicate where the interval split occurs
      X, y = check_X_y(X, y, estimator=self)
      self.quantiles_ = np.zeros((X.shape[1], self.n_chunks))
      # heights indicate what heights these intervals will have
      self.heights_ = np.zeros((X.shape[1], self.n_chunks))
      self.n_features_in_ = X.shape[1]
  
      average_func = (
          _mk_average
          if self.method in ["average", "normal"]
          else _mk_monotonic_average
      )
  
      for col in range(X.shape[1]):
          self.quantiles_[col, :] = np.quantile(
              X[:, col], q=np.linspace(0, 1, self.n_chunks)
          )
          self.heights_[col, :] = average_func(
              X[:, col],
              y,
              self.quantiles_[col, :],
              span=self.span,
              method=self.method,
          )
      return self
  
file_path: scikit-lego/sklego/preprocessing/intervalencoder.py
imports: from warnings import warn
  import numpy
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils import check_array, check_X_y
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 2 for calling the IntervalEncoder obj's underlying member method code with example usage: obj.fit(X, y) and returns: self