Creating a LASSO regressor
You'll be working on the numeric ANSUR body measurements dataset to predict a persons Body Mass Index (BMI) using the pre-imported Lasso() regressor. BMI is a metric derived from body height and weight but those two features have been removed from the dataset to give the model a challenge.
You'll standardize the data first using the StandardScaler() that has been instantiated for you as scaler to make sure all coefficients face a comparable regularizing force trying to bring them down.
All necessary functions and classes plus the input datasets X and y have been pre-loaded.
Este exercício faz parte do curso
Dimensionality Reduction in Python
Instruções do exercício
- Set the test size to 30% to get a 70-30% train test split.
- Fit the scaler on the training features and transform these in one go.
- Create the Lasso model.
- Fit it to the scaled training data.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Set the test size to 30% to get a 70-30% train test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=____, random_state=0)
# Fit the scaler on the training features and transform these in one go
X_train_std = scaler.____
# Create the Lasso model
la = ____()
# Fit it to the standardized training data
la.____