Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Implementing Logistic Regression | Logistic Regression
Classification with Python
course content

Contenido del Curso

Classification with Python

Classification with Python

1. k-NN Classifier
2. Logistic Regression
3. Decision Tree
4. Random Forest
5. Comparing Models

book
Challenge: Implementing Logistic Regression

To implement Logistic Regression in Python, the LogisticRegression class is used:

For now, you can stick with the default parameters. Creating and fitting the model can be done in a single line:

python

The dataset for this chapter comes from a Portuguese banking institution and contains information from marketing campaigns conducted via phone calls. The goal is to predict whether a client will subscribe to a term deposit, based on their personal, financial, and contact-related details, as well as outcomes of previous marketing interactions.

The data is already preprocessed and ready to be fed to the model.

Tarea

Swipe to start coding

You are given a Portuguese bank marketing dataset stored as a DataFrame in the df variable.

  • Split the dataset into training and test sets, allocating 80% for the training data. Set random_state=42, and store the resulting sets in the X_train, X_test, y_train, y_test variables.
  • Initialize and fit a Logistic Regression model on the training set, storing the fitted model in the lr variable.
  • Calculate the accuracy on the test set and store the result in the test_accuracy variable.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
toggle bottom row

book
Challenge: Implementing Logistic Regression

To implement Logistic Regression in Python, the LogisticRegression class is used:

For now, you can stick with the default parameters. Creating and fitting the model can be done in a single line:

python

The dataset for this chapter comes from a Portuguese banking institution and contains information from marketing campaigns conducted via phone calls. The goal is to predict whether a client will subscribe to a term deposit, based on their personal, financial, and contact-related details, as well as outcomes of previous marketing interactions.

The data is already preprocessed and ready to be fed to the model.

Tarea

Swipe to start coding

You are given a Portuguese bank marketing dataset stored as a DataFrame in the df variable.

  • Split the dataset into training and test sets, allocating 80% for the training data. Set random_state=42, and store the resulting sets in the X_train, X_test, y_train, y_test variables.
  • Initialize and fit a Logistic Regression model on the training set, storing the fitted model in the lr variable.
  • Calculate the accuracy on the test set and store the result in the test_accuracy variable.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Lamentamos que algo salió mal. ¿Qué pasó?
some-alt