title: How does Sklearn's Normalizer class's fit function behave?
body: <p>According to the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.Normalizer.html" rel="nofollow noreferrer">docs</a>, the <code>.fit</code> function :</p>
  <blockquote>
  <p><strong>fit(X, y=None)</strong> : Do nothing and return the estimator unchanged.</p>
  <p>This method is just there to implement the usual API and hence work in pipelines.</p>
  </blockquote>
  <p>However, when I use the fit function, the Normalizer &quot;fits&quot; to the shape of the X passed, and expects the same number of features when the transform  function is used thereafter.</p>
  <p>eg:</p>
  <pre><code>A = np.random.rand(1,7)
  B = np.random.rand(1,5)
  print(&quot;A :&quot;,A,&quot;\n&quot;,&quot;B :&quot;,B)
  
  &gt;&gt;&gt; A : [[0.56973872 0.74769087 0.81626309 0.03873601 0.71216399 0.31807755 0.96527768]] 
      B : [[0.49805279 0.73939067 0.85949423 0.79824846 0.52750957]]
  
  from sklearn.preprocessing import Normalizer
  normalizer = Normalizer()
  
  #normalizer.fit(A)
  a = normalizer.transform(A)
  b = normalizer.transform(B)
  print(&quot;a :&quot;,a,&quot;\n&quot;,&quot;b :&quot;,b)
  
  &gt;&gt;&gt; a : [[0.32403221 0.42524041 0.46424006 0.02203065 0.40503491 0.18090287
          0.54899035]] 
      b : [[0.3182623  0.47248039 0.54922815 0.5100913  0.33708558]]
  </code></pre>
  <p>However, when the fit function is called in this ValueError is raised :</p>
  <pre><code>from sklearn.preprocessing import Normalizer
  normalizer = Normalizer()
  
  normalizer.fit(A)
  a = normalizer.transform(A)
  b = normalizer.transform(B)
  print(&quot;a :&quot;,a,&quot;\n&quot;,&quot;b :&quot;,b)
  
  &gt;&gt;&gt; ---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  Input In [28], in &lt;module&gt;
        4 normalizer.fit(A)
        5 a = normalizer.transform(A)
  ----&gt; 6 b = normalizer.transform(B)
        7 print(&quot;a :&quot;,a,&quot;\n&quot;,&quot;b :&quot;,b)
  
  File ~\PycharmProjects\notebookWith_LSP\venv\lib\site-packages\sklearn\preprocessing\_data.py:1948, in Normalizer.transform(self, X, copy)
     1931 &quot;&quot;&quot;Scale each non zero row of X to unit norm.
     1932 
     1933 Parameters
     (...)
     1945     Transformed array.
     1946 &quot;&quot;&quot;
     1947 copy = copy if copy is not None else self.copy
  -&gt; 1948 X = self._validate_data(X, accept_sparse=&quot;csr&quot;, reset=False)
     1949 return normalize(X, norm=self.norm, axis=1, copy=copy)
  
  File ~\PycharmProjects\notebookWith_LSP\venv\lib\site-packages\sklearn\base.py:600, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params)
      597     out = X, y
      599 if not no_val_X and check_params.get(&quot;ensure_2d&quot;, True):
  --&gt; 600     self._check_n_features(X, reset=reset)
      602 return out
  
  File ~\PycharmProjects\notebookWith_LSP\venv\lib\site-packages\sklearn\base.py:400, in BaseEstimator._check_n_features(self, X, reset)
      397     return
      399 if n_features != self.n_features_in_:
  --&gt; 400     raise ValueError(
      401         f&quot;X has {n_features} features, but {self.__class__.__name__} &quot;
      402         f&quot;is expecting {self.n_features_in_} features as input.&quot;
      403     )
  
  ValueError: X has 5 features, but Normalizer is expecting 7 features as input.
  </code></pre>
  <p>What exactly am I missing here ?</p>