Session Ready
Exercise

Training a model

With split data in hand, you're only a few lines away from training a model.

In this exercise, you will import the logistic regression and one versus rest classifiers in order to fit a multi-class logistic regression model to the NUMERIC_COLUMNS of your feature data.

Then you'll test and print the accuracy with the .score() method to see the results of training.

Before you train! Remember, we're ultimately going to be using logloss to score our model, so don't worry too much about the accuracy here. Keep in mind that you're throwing away all of the text data in the dataset - that's by far most of the data! So don't get your hopes up for a killer performance just yet. We're just interested in getting things up and running at the moment.

All data necessary to call multilabel_train_test_split() has been loaded into the workspace.

Instructions
100 XP
  • Import LogisticRegression from sklearn.linear_model and OneVsRestClassifier from sklearn.multiclass.
  • Instantiate the classifier clf by placing LogisticRegression() inside OneVsRestClassifier().
  • Fit the classifier to the training data X_train and y_train.
  • Compute and print the accuracy of the classifier using its .score() method, which accepts two arguments: X_test and y_test.