- #1
EngWiPy
- 1,368
- 61
Hi,
I noticed that in some cases we first call fit_transform(), and afterwards we call transform(). Like in the following example:
Why? What is the difference between the two methods?
Thanks
I noticed that in some cases we first call fit_transform(), and afterwards we call transform(). Like in the following example:
Code:
from sklearn.preprocessing import PolynomialFeatures
X_train = np.array([6, 8, 10, 14, 18]).reshape(-1, 1)
X_test = np.array([6, 8, 11, 16]).reshape(-1, 1)
quadratic_featurizer = PolynomialFeatures(degree = 2)
X_train_qudratic = quadratic_featurizer.fit_transform(X_train)
X_test_qudratic = quadratic_featurizer.transform(X_test)
Why? What is the difference between the two methods?
Thanks