Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Model Training | Logistic Regression Mastering
Logistic Regression Mastering
course content

Conteúdo do Curso

Logistic Regression Mastering

book
Model Training

The process of training an ML model involves providing an ML algorithm (that is, the learning algorithm) with training data to learn from. The term ML model refers to the model artifact that is created by the training process.

The training data must contain the correct answer, which is known as a target or target attribute. The learning algorithm finds patterns in the training data that map the input data attributes to the target (the answer that you want to predict), and it outputs an ML model that captures these patterns. We are going to investigate the accuracy of our model in the next section, just focus on training the model for now.

We are going to train a Logistic regression model. Formally, in binary logistic regression, there is a single binary dependent variable, coded by an indicator variable, where the two values are labeled "0" and "1", while the independent variables can each be a binary variable (two classes, coded by an indicator variable) or a continuous variable (any real value).

Methods description

  • sklearn.linear_model: This module from scikit-learn provides various linear models for classification and regression tasks;

  • LogisticRegression: This is a class within the sklearn.linear_model module used for logistic regression, a statistical method for analyzing datasets where there are one or more independent variables that determine an outcome. It's commonly used for binary classification problems;

    • .random_state: This parameter sets the random seed for reproducibility;
    • .max_iter: This parameter specifies the maximum number of iterations for the solver to converge;
  • .fit(X_train, y_train): This method trains the logistic regression model using the training data X_train and corresponding labels y_train. It adjusts the parameters of the model to minimize the loss function and fit the data as well as possible;

  • .predict(X_test): This method predicts the labels for the input data X_test using the trained logistic regression model. It returns the predicted labels based on the learned parameters from the training data.

Tarefa
test

Swipe to show code editor

  1. Import LogisticRegression from sklearn.

  2. Use the method just imported to initialize the classifier.

  3. Call .fit() and pass X_train and y_train as parameters.

  4. Predict on X_test.

Mark tasks as Completed
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 6
We're sorry to hear that something went wrong. What happened?
some-alt