Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Implementing Logistic Regression | Section
Supervised Learning Essentials

Challenge: Implementing Logistic Regression

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

Constructor:

  • LogisticRegression(penalty = 'l2', C = 1.0)
    • penalty — regularization term. Possible values: 'l2', 'l1', 'elasticnet', None;
    • C — controls the strength of regularization. Higher C results in less regularization;

Methods:

  • fit(X, y) — Fit the training set;
  • predict(X) — Predict the class for X;
  • score(X, y) — Returns the accuracy for the X, y set.

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

logistic_regression = LogisticRegression().fit(X_train, y_train)

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.

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  23
single

single

Challenge: Implementing Logistic Regression

メニューを表示するにはスワイプしてください

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

Constructor:

  • LogisticRegression(penalty = 'l2', C = 1.0)
    • penalty — regularization term. Possible values: 'l2', 'l1', 'elasticnet', None;
    • C — controls the strength of regularization. Higher C results in less regularization;

Methods:

  • fit(X, y) — Fit the training set;
  • predict(X) — Predict the class for X;
  • score(X, y) — Returns the accuracy for the X, y set.

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

logistic_regression = LogisticRegression().fit(X_train, y_train)

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.

タスク

スワイプしてコーディングを開始

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.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  23
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt