class_docstr: Mixin class for transformers that can handle training and test data differently.
  
  This mixin allows using a separate function for transforming training and test data.
  
  !!! warning
  
      Transformers using this class as a mixin should:
  
      - Call `super().fit` in their fit method.
      - Implement `transform_train()` method.
  
      They may also implement `transform_test()` method, if not implemented, `transform_test()` will simply return
      the untransformed data.
  
  Attributes
  ----------
  X_hash_ : hash
      The hash of the training data - used to determine whether to use `transform_train` or `transform_test`.
  n_features_in_ : int
      The number of features seen during `.fit()` in the training data.
  dim_ : int
      Deprecated, use `n_features_in_` instead.
  
  Examples
  --------
  ```py
  from sklearn.base import BaseEstimator
  from sklego.common import TrainOnlyTransformerMixin
  
  class TrainOnlyTransformer(TrainOnlyTransformerMixin, BaseEstimator):
      def fit(self, X, y):
          super().fit(X, y)
  
      def transform_train(self, X, y=None):
          '''Add random noise to the training data.'''
          return X + np.random.normal(0, 1, size=X.shape)
  
  X_train, X_test = np.random.randn(100, 4), np.random.randn(100, 4)
  y_train, y_test = np.random.randn(100), np.random.randn(100)
  
  trf = TrainOnlyTransformer()
  trf.fit(X_train, y_train)
  
  assert np.all(trf.transform(X_train) != X_train)
  assert np.all(trf.transform(X_test) == X_test)
  ```
class_docstr_tok: ["Mixin","class","for","transformers","that","can","handle","training","and","test","data","differently",".","This","mixin","allows","using","a","separate","function","for","transforming","training","and","test","data",".","!","!","!","warning","Transformers","using","this","class","as","a","mixin","should",":","-","Call","`","super","(",")",".fit","`","in","their","fit","method",".","-","Implement","`","transform_train","(",")","`","method",".","They","may","also","implement","`","transform_test","(",")","`","method",",","if","not","implemented",",","`","transform_test","(",")","`","will","simply","return","the","untransformed","data",".","Attributes","--","--","--","--","--","X_hash_",":","hash","The","hash","of","the","training","data","-","used","to","determine","whether","to","use","`","transform_train","`","or","`","transform_test","`",".","n_features_in_",":","int","The","number","of","features","seen","during","`",".fit","(",")","`","in","the","training","data",".","dim_",":","int","Deprecated",",","use","`","n_features_in_","`","instead",".","Examples","--","--","--","--","``","`","py","from","sklearn.base","import","BaseEstimator","from","sklego.common","import","TrainOnlyTransformerMixin","class","TrainOnlyTransformer","(","TrainOnlyTransformerMixin",",","BaseEstimator",")",":","def","fit","(","self",",","X",",","y",")",":","super","(",")",".fit","(","X",",","y",")","def","transform_train","(","self",",","X",",","y=None",")",":","``","'Add","random","noise","to","the","training","data",".","''","'","return","X","+","np.random.normal","(","0",",","1",",","size=X.shape",")","X_train",",","X_test","=","np.random.randn","(","100",",","4",")",",","np.random.randn","(","100",",","4",")","y_train",",","y_test","=","np.random.randn","(","100",")",",","np.random.randn","(","100",")","trf","=","TrainOnlyTransformer","(",")","trf.fit","(","X_train",",","y_train",")","assert","np.all","(","trf.transform","(","X_train",")","!","=","X_train",")","assert","np.all","(","trf.transform","(","X_test",")","==","X_test",")","``","`"]
docstr: Fit the mixin by calculating the hash of `X` and stores it in `self.X_hash_`.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features )
      The training data.
  y : array-like of shape (n_samples,) | None, default=None
      The target values.
  
  Returns
  -------
  self : TrainOnlyTransformerMixin
      The fitted transformer.
docstr_tok: ["Fit","the","mixin","by","calculating","the","hash","of","`","X","`","and","stores","it","in","`","self.X_hash_","`",".","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","The","training","data",".","y",":","array-like","of","shape","(","n_samples",",",")","|","None",",","default=None","The","target","values",".","Returns","--","--","--","-","self",":","TrainOnlyTransformerMixin","The","fitted","transformer","."]
code: def fit(self, X, y=None):
      """Fit the mixin by calculating the hash of `X` and stores it in `self.X_hash_`.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features )
          The training data.
      y : array-like of shape (n_samples,) | None, default=None
          The target values.
  
      Returns
      -------
      self : TrainOnlyTransformerMixin
          The fitted transformer.
      """
      if y is None:
          check_array(X, estimator=self)
      else:
          check_X_y(X, y, estimator=self)
      self.X_hash_ = self._hash(X)
      self.n_features_in_ = X.shape[1]
      return self
  
file_path: scikit-lego/sklego/common.py
imports: import collections
  import hashlib
  from warnings import warn
  import numpy
  import pandas
  from sklearn.base import TransformerMixin
  from sklearn.utils.validation import check_array, check_is_fitted, check_X_y
label_desc: Use image node_id 1 for calling the TrainOnlyTransformerMixin obj's underlying member method code with example usage: obj.fit(X, y) and returns: self