Lasso Regression with Scikit-Learn (Beginner Friendly)

Ryan & Matt Data Science โ€ข October 10, 2023
Video Thumbnail

About

No channel description available.

Video Description

๐Ÿง  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-automations-4579 Welcome to our comprehensive tutorial on Lasso Regression using the scikit-learn library in Python! In this video, we dive deep into the world of Lasso Regression, a powerful machine learning technique used for feature selection and regularization. Code: https://ryanandmattdatascience.com/lasso-regression/ ๐Ÿš€ Hire me for Data Work: https://ryanandmattdatascience.com/data-freelancing/ ๐Ÿ‘จโ€๐Ÿ’ป Mentorships: https://ryanandmattdatascience.com/mentorship/ ๐Ÿ“ง Email: [email protected] ๐ŸŒ Website & Blog: https://ryanandmattdatascience.com/ ๐Ÿ–ฅ๏ธ Discord: https://discord.com/invite/F7dxbvHUhg ๐Ÿ“š *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: https://www.youtube.com/playlist?list=PLcQVY5V2UY4LNmObS0gqNVyNdVfXnHwu8 Simple Linear Regression: https://youtu.be/ukZn2RJb7TU Ridge Regressor: https://youtu.be/GMF4Td7KtB0 Random Forest Regressor: https://youtu.be/YUsx5ZNlYWc In this video, I walk through everything you need to know about Lasso Regression (L1 regularization) in Python using scikit-learn. We start by covering the theory behind Lasso Regression and how it addresses overfitting through automatic feature selection by shrinking certain coefficients to zero. Then we dive into a hands-on coding tutorial using the California Housing dataset. I demonstrate the complete workflow including train-test splits, feature scaling with StandardScaler (which is crucial for Lasso models), fitting the basic model, and evaluating performance with metrics like mean absolute error, mean squared error, and R2 score. We then explore hyperparameter tuning using GridSearchCV to find the optimal alpha value, which controls the strength of regularization. The results show a massive improvement from an R2 score near zero to 0.6 after tuning. By the end of this tutorial, you'll understand when to use Lasso Regression, how to implement it properly in scikit-learn, why scaling is essential, and how to tune the alpha parameter for better model performance. Perfect for anyone learning machine learning regression models or working through a scikit-learn tutorial series. TIMESTAMPS 00:00 Introduction to Lasso Regression 01:32 Getting Started with Code - Importing Data 03:02 Train Test Split Explained 04:00 Standard Scaler Implementation 06:02 Importing and Fitting Lasso Model 07:18 Evaluation Metrics - Initial Results 09:02 Hyperparameter Tuning with Grid Search 11:20 Improved Model Results Comparison 12:50 Finding Best Alpha Value 14:00 Examining Coefficients and Intercept 15:13 Creating DataFrame for Feature Analysis 16:40 Final Recap and Conclusion OTHER SOCIALS: Ryanโ€™s LinkedIn: https://www.linkedin.com/in/ryan-p-nolan/ Mattโ€™s LinkedIn: https://www.linkedin.com/in/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.

You May Also Like