2
$\begingroup$

I am working on a regression problem. The data contains 13 features (after performing feature selection). to some of these features, I have applied log transformation and box-cox to fix the skewness. For some features, I have also used standard scaling.

So my question is that should I also apply these transformations to the test data as well. As the model is trained on the transformed features, it makes sense to apply these transformations to test data as well.

If the answer is yes, then how should I apply the transformation?

for instance on train data the code looks something like this

    scaler = StandardScaler()
    
    scaler.fit(np.reshape(train_data["cont1"])
    scaler.transform(train_data["cont1"])

should I use the same StandardScaler object for test data as well or I am allowed to create a new instance of the StandardScaler object and use that for transformation?

$\endgroup$
1
$\begingroup$

You need to apply the same transformations to the test data and use the fitted values/object on training data to transform the test data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.