Regularizing models with Twitter data
You will work with the Twitter data expressing customers' sentiment about airline companies. The X
matrix of features and y
vector of labels have been created for you. In addition, the training and testing split has been performed. You can work with the X_train
, X_test
, y_train
and y_test
arrays directly.
You will train regularized and a more flexible models and evaluate them using different model performance metrics.
All required packages have been imported for you.
Cet exercice fait partie du cours
Sentiment Analysis in Python
Instructions
- Train two logistic regressions: one with regularization parameter of 100 and a second of 0.1.
- Print the accuracy scores of both models.
- Print the confusion matrix of each model.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Build a logistic regression with regularizarion parameter of 100
log_reg1 = ____.____
# Build a logistic regression with regularizarion parameter of 0.1
log_reg2 = ____.____
# Predict the labels for each model
y_predict1 = log_reg1.predict(X_test)
y_predict2 = log_reg2.predict(X_test)
# Print performance metrics for each model
print('Accuracy of model 1: ', ____(____, ____))
print('Accuracy of model 2: ', ____(___, ____))
print('Confusion matrix of model 1: \n' , ____(____, ____)/len(y_test))
print('Confusion matrix of model 2: \n', ____(____, ____)/len(y_test))