Hands-On Machine Learning: Logistic Regression with Python and Scikit-Learn

Published: 19 August 2023
on channel: Ryan & Matt Data Science
34,196
863

🧠 Don’t miss out! Get FREE access to my Skool community — packed with resources, tools, and support to help you with Data, Machine Learning, and AI Automations! 📈 https://www.skool.com/data-and-ai-aut...

Whether you're a beginner or looking to refresh your knowledge, this machine learning tutorial has got you covered. We'll take you step by step through the concept of Logistic Regression, its mathematical foundation, and its practical applications.

After we take a look at how you can use scikit-learn to code the logistic regression and evaluate the model.

Code: https://ryanandmattdatascience.com/lo...

🚀 Hire me for Data Work: https://ryanandmattdatascience.com/da...
👨‍💻 Mentorships: https://ryanandmattdatascience.com/me...
📧 Email: ryannolandata@gmail.com
🌐 Website & Blog: https://ryanandmattdatascience.com/
🖥️ Discord:   / discord  
📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan
📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg

🍿 WATCH NEXT
Scikit-Learn and Machine Learning Playlist:    • Scikit-Learn Tutorials - Master Machine Le...  
Extra Trees Classifier:    • Extra Trees Classifier in Scikit-Learn: An...  
KNN Classifier:    • How to Build Your First KNN Python Model i...  
Support Vector Machine:    • Mastering Support Vector Machines with Pyt...  

In this machine learning tutorial, I walk you through building a logistic regression model in Python using scikit-learn (sklearn). We start by explaining the difference between linear regression and logistic regression, focusing on how logistic regression uses a sigmoid curve to make binary predictions (yes/no, 0/1).

I demonstrate the complete workflow using a real example with ultra marathon runner data, where we predict whether runners will complete a 50-mile race based on their average weekly training mileage. You'll learn how to handle categorical data using ordinal encoding, visualize your data with matplotlib and seaborn, split your dataset with train_test_split, fit the logistic regression model, and evaluate performance using confusion matrices and classification reports.

By the end of this tutorial, you'll understand exactly when to use **logistic regression**, how to implement it in Python, and how to interpret your model's accuracy using precision, recall, and F1 scores. All code is available in the description below so you can follow along and practice building your own logistic regression models.

TIMESTAMPS
00:00 Introduction to Logistic Regression
01:42 Logistic vs Linear Regression Explained
03:02 Setting Up the Code Environment
05:17 Encoding Categorical Data
07:32 Visualizing the Data with Plots
09:12 Train Test Split Setup
11:22 Building the Logistic Regression Model
13:27 Evaluating Model Performance
15:17 Final Review and Recap

OTHER SOCIALS:
Ryan’s LinkedIn:   / ryan-p-nolan  
Matt’s LinkedIn:   / matt-payne-ceo  
Twitter/X: https://x.com/RyanMattDS

Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.

Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.

*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.


On this page of the site you can watch the video online Hands-On Machine Learning: Logistic Regression with Python and Scikit-Learn with a duration of hours minute second in good quality, which was uploaded by the user Ryan & Matt Data Science 19 August 2023, share the link with friends and acquaintances, this video has already been watched 34,196 times on youtube and it was liked by 863 viewers. Enjoy your viewing!