ÎncepețiÎncepe gratuit

Logistic regression combined with SMOTE

In this exercise, you're going to take the Logistic Regression model from the previous exercise, and combine that with a SMOTE resampling method. We'll show you how to do that efficiently by using a pipeline that combines the resampling method with the model in one go. First, you need to define the pipeline that you're going to use.

Acest exercițiu face parte din cursul

Fraud Detection in Python

Vezi cursul

Instrucțiuni pentru exercițiu

  • Import the Pipeline module from imblearn, this has been done for you.
  • Then define what you want to put into the pipeline, assign the SMOTE() method to resampling, and assign LogisticRegression() to the model.
  • Combine two steps in the Pipeline() function. You need to state you want to combine resampling with the model in the respective place in the argument. I show you how to do this.

Exercițiu interactiv practic

Încearcă acest exercițiu completând acest cod de exemplu.

# This is the pipeline module we need for this from imblearn
from imblearn.pipeline import Pipeline 

# Define which resampling method and which ML model to use in the pipeline
resampling = ____
model = ____

# Define the pipeline, tell it to combine SMOTE with the Logistic Regression model
pipeline = Pipeline([('SMOTE', resampling), ('Logistic Regression', model)])
Editează și rulează codul