Login using Social Account
     Continue with GoogleLogin using your credentials
Let us now train the Softmax Regression (Logistic Regression - multi_class-multinomial). We will be doing the following as part of this exercise:
Please follow the below steps:
Import LogisticRegression from SKLearn
from <<your code comes here>> import LogisticRegression
Create an instance of LogisticRegression by passing parameters - multi_class="multinomial", solver="lbfgs", C=10 and random_state=42 to the constructor and store this created instance in a variable called 'log_clf'.
# using Softmax Regression (multi-class classification problem)
log_clf = LogisticRegression(<<your code comes here>>)
# 'C' is hyprparameter for regularizing L2
# 'lbfgs' is Byoden-Fletcher-Goldfarb-Shanno(BFGS) algorithm
Now, train the model on 'scaled' training dataset
log_clf.<<your code comes here>>(X_train_scaled, <<your code comes here>>)
Make prediction on an instance from the training dataset (say instance at index '0' i.e. X_train[0]) using the above trained model 'log_clf', and store the predicted value in a variable called y_train_predict
y_train_predict = log_clf.<<your code comes here>>(X_train[0].reshape(1, -1))
Let us compare the actual value to the predicted value of the label. You can use showImage() function to see the image.
y_train[0]
y_train_predict[0]
showImage(X_train[0])
Make the predictions on the complete training dataset X_train_scaled using the above trained model 'log_clf' and save the result in variable 'y_train_predict'
y_train_predict = log_clf.<<your code comes here>>(X_train_scaled)
Calculate the various metrics scores like - accuracy, precision, recall, F1 score - using the actual and the predicted values and relevant functions, - and store them in respective variables - log_accuracy, log_precision, log_recall and log_f1_score.
log_accuracy = <<your code comes here>>(y_train, <<your code comes here>>)
log_precision = <<your code comes here>>(y_train, <<your code comes here>>, average='weighted')
log_recall = <<your code comes here>>(y_train, <<your code comes here>>, average='weighted')
log_f1_score = <<your code comes here>>(y_train, <<your code comes here>>, average='weighted')
You can print the above metrics values (accuracy, etc.) using the print() function
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...