1. Learn
  2. /
  3. Courses
  4. /
  5. Supervised Learning with scikit-learn

Connected

Exercise

Centering and scaling for classification

Now you will bring together scaling and model building into a pipeline for cross-validation.

Your task is to build a pipeline to scale features in the music_df dataset and perform grid search cross-validation using a logistic regression model with different values for the hyperparameter C. The target variable here is "genre", which contains binary values for rock as 1 and any other genre as 0.

StandardScaler, LogisticRegression, and GridSearchCV have all been imported for you.

Instructions

100 XP
  • Build the steps for the pipeline: a StandardScaler() object named "scaler", and a logistic regression model named "logreg".
  • Create the parameters, searching 20 equally spaced float values ranging from 0.001 to 1.0 for the logistic regression model's C hyperparameter within the pipeline.
  • Instantiate the grid search object.
  • Fit the grid search object to the training data.