A Step by Step Guide to Logistic Regression Model Building using Python | Machine learning

In the field of Machine Learning, logistic regression is still the top choice for classification problems. It is simple yet efficient algorithm which produces accurate models in most of the cases. In its basic form, it uses the logistic function to calculate the probability score which helps to classify the binary dependent variable to its respective class. Logistic regression is the transformed form of the linear regression. In this post I have explained the end to end step involved in the classification machine learning problems using the logistic regression and also performed the detailed analysis of the model output with various performance parameters.

This post is more of practical exercise using python, hence if you want to brush-up the theoretical concept on logistic regression, then please refer my post on logistic regression using the link below.

What is Logistic Regression?

Key Takeaways from this Post:

Problem: Predict whether the client will subscribe for the term deposit or not

  1. Exploratory Data Analysis on Banking Data
  2. Visualization
  3. Data Preprocessing:
    • Handling Categorical Variable
    • Oversampling using SMOTE
    • Random Feature Elimination – RFE
  4. Model Building
  5. Understanding model Output
  6. Confusion Matrix
  7. ROC curve
import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import seaborn as sns
sns.set(style="whitegrid",color_codes = True)
data = pd.read_csv("banking.csv")

Exploratory Data Analysis

Logistic Regression Model Building

This is all for now. Hope you enjoyed reading.

Thank You, Happy Learning !!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.