ComeçarComece de graça

Fit logistic regression model

Logistic regression is a simple yet very powerful classification model that is used in many different use cases. You will now fit a logistic regression on the training part of the telecom churn dataset, and then predict labels on the unseen test set. Afterwards, you will calculate the accuracy of your model predictions.

The accuracy_score function has been imported, and a LogisticRegression instance from sklearn has been initialized as logreg. The training and testing datasets that you've built previously have been loaded as train_X and test_X for features, and train_Y and test_Y for target variables.

Este exercício faz parte do curso

Machine Learning for Marketing in Python

Ver curso

Instruções do exercício

  • Fit a logistic regression on the training data.
  • Predict churn labels for the test data.
  • Calculate the accuracy score on the testing data.
  • Print the test accuracy rounded to 4 decimals.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Fit logistic regression on training data
logreg.___(train_X, train_Y)

# Predict churn labels on testing data
pred_test_Y = ___.predict(test_X)

# Calculate accuracy score on testing data
test_accuracy = ___(test_Y, pred_test_Y)

# Print test accuracy score rounded to 4 decimals
print('Test accuracy:', ___(test_accuracy, 4))
Editar e executar o código