How to Transform the Target in Regression Flashcards
WHICH CLASS IN SCIKIT-LEARN IS FOR TRANSFORMING THE TARGET VARIABLE? P341
TransformedTargetRegressor
WHAT ARE TWO WAYS WE CAN SCALE THE TARGET VARIABLE? P342
Manually transform the target variable.
Automatically transform the target variable.
HOW CAN WE MANUALLY TRANSFORM THE TARGET? P342
Create the transform object, e.g. a MinMaxScaler.
Fit the transform on the training dataset.
Apply the transform to the train and test datasets.
Invert the transform on any predictions made (target_scaler.inverse_transform (y_pred)).
WHAT IS THE DOWNSIDE OF MANUALLY TRANSFORMING THE TARGET? P343
You cannot use convenience functions in scikit-learn, such as cross_val_score(), to quickly evaluate a model.
HOW DOES TransformedTargetRegressor WORK? P343
TransformedTargetRegressor object wraps a given model (or a pipeline) and a scaling object.
wrapped_model = TransformedTargetRegressor (regressor=model, transformer=MinMaxScaler())
HOW CAN WE USE TransformedTargetRegressor? P343
The TransformedTargetRegressor instance can be fit like any other model by calling the fit() function and used to make predictions by calling the predict() function.