I have a dataframe d
and one of the columns is price
(Numerical) having 109248 rows. I divided the data into two parts d_train
and d_test
. d_train
has 73196 values and d_test
has 36052 values. Now to normalize d_train['price']
and d_test['price']
i did something like this..
price_scalar = Normalizer()
X_train_price = price_scalar.fit_transform(d_train['price'].values.reshape(1, -1)
X_test_price = price_scalar.transform(d_test['price'].values.reshape(1, -1))
Now I'm having this issue
ValueError Traceback (most recent call last)
<ipython-input-20-ba623ca7bafa> in <module>()
3 X_train_price = price_scalar.fit_transform(X_train['price'].values.reshape(1, -1))
----> 4 X_test_price = price_scalar.transform(X_test['price'].values.reshape(1, -1))
/usr/local/lib/python3.7/dist-packages/sklearn/base.py in _check_n_features(self, X, reset)
394 if n_features != self.n_features_in_:
395 raise ValueError(
397 f"is expecting {self.n_features_in_} features as input."
398 )
ValueError: X has 36052 features, but Normalizer is expecting 73196 features as input.
Doing change: reshape(-1,1)
instead of reshape(1,-1)
runs ok but makes all row values of price
to 1.