How to Visualize Multiple Linear Regression in python
Key Takeaways
Visualizes multiple linear regression models using matplotlib for understanding relationships between variables
Full Transcript
well today we'll be seeing how we can actually create a visualization for a multiple linear regression model with the help of matplotlib previously I have already shown a lot of statements on a lot of problems or use cases on simple integration of multiple linear regression so one of the most frequent question was asked that how do we perform visualization how do we show a visualization from an equation now definitely we cannot suppose if in our dataset we have 100 times 100 different features of all that three features we cannot show those dimensions and visually but what we can do is that instead of whenever we have many number of features we can actually create a pair plot and try to steal the dimensions but for three dimension might not live has given a feature where we can see that dimension along the plane that's created from multiple linear regression so this particular problem statement is basically with respect to three features if you have three features in our data set how we can plot that three dimensional features we'll see if you have more than three three dimensions which should basically perform their plot and try to see how our data is actually distributed again it is very difficult to draw the plane for multiple dimensions but with respect to three dimension have done that so in this particular video what I'm going to do is that I'm just going to show you a simple multiple linear regression problem statement and then after creating the model we'll try to find out the test data output and then we will try to create a plane in a three dimensional so to begin with what I am going to do is that I am just going to create a simple X&Y features this is just like my 150 comma hundred roof each other I have as my dependent which I mean why I have one I'm just going to execute this tool before going ahead the output will look something like this let me just show you how the output will look like the output will look something like this where you have your plane and you can move this plane also if you want then see how our data is basically distributed and with the help of multiple linear regression I've actually created a plane which passes and the error you can see it is very very less basically what you use is basically the sum of square and it would study business for instance if you have to dimension just like a simple linear regression you can plot that by using it this is just like a damaged so let us just go ahead and see that what I have done in this particular problem statement this particular notebook file sorry this particular py file will be given will be uploaded in the link will be given in the description of this video you can download it from there and you can draw it for any number of problem statement I made it this code I generate in a generate way you just have to upload the data set and do it so here it is initially I am going to create my X and my data which is X is basically my dependent feature Y is basically my dependents each other then I am converting this into a data frame and for the X these two features I am just giving that giving the features as price and add spends like what is the price of the hat and what you got how much is the heart spend basically for that feature it's just a generate data set that I have created by my own and then my Y dataset is unbasic Elise aying it as sales so this is what I am doing for my F 2 so let me just take C to this truth each statement you can see that you can see or DF 2 and inside my DF you now you have three features price add spends and sends price and add spins are basically our independent feature sales is basically a dependency and after that what I am doing is that I am just importing madcraft lid and Here I am going to use the stock models not formula or API which will actually by using ordinary lease this is another way of applying multiple linear regression if you want use here in the formula you just have to give which are independent features like sales and always remember to give this particular symbol which indicates independent future plus expense is basically your funny scenes is basically your dependent and after the symbol you have all your dependency choose finally you just give the data set which you are stored in the end after that you just remodeled outfit and inside this parents this particular variable dot parents will basically be getting yard it is simply acquisition so as soon as I execute this you can see that there it is you can see that in and consoled you are having intercept price expense for efficient intercept is basically the point where your x-axis or y-axis this is you this is the price for efficient this is that relationship you have this the main part is the visualization stuff make sure you make this mesh great because what happens is that whenever you are drawing in 3d plot it will be expecting the x y&z value in the forest I always remember that when you are doing this much grade you provide the links where you use range space and in that you have to take the minimum price maximum price similarly minimum from nuuma max fine and maximum aspect the reason is that you are going to create a plane right so you need four corner points for that and then you will be joining those points up to that you create a data frame by using this mixer my sub which is which is the values of which is the array which is generated by instant downloads particularly and you can try to run and after that you are just doing a predict for the x value so whatever X data plane you have that you have created is predicting so once you Institute this this this is run perfectly fine then just try to convert this into an array because your math lottery will be expecting that intuitively even data friends can be provided but I am actually trying to do a reshape inside my project so because of that actually converting this into an array and finally my visualization part where I've used not dots either and inside you saw guard it dot add in the subplot this is the number of rows and columns that I want my prediction is 3d you provide this particular feature to indicate it is a 3d diagram and then you do the scatter plot of price I'd spends and sales with the Ranma and here this is for the transparency similarly you provide a dot plot under surface this is the main thing now here you have to actually give you X underscore value Y in the saucer and finally which you have converted into an array you are doing it to be shape of your Xserve which is your other features of x and y dot shape that's it and finally you give me the color if you want to give the color of something else letting me give like is for blue currently let me just give me none and then then you set up your ex label why label and Z label and finally execute this and here is the thing that has come so here you can see your 3d plot very precisely see it see the plane very nicely created you can rotate it and you can see from top bottom view however you want so this is how it looks from the top view similar you can scroll down and see from the left hand side right hand side and see it see the plane how clearly it shows you the plane from here and it is drawn between the points okay I'll let me just try to get some color if you want so I'll just give a loop and let's see here it is your blue paint plane has been really precise and showing it's good because this kind of diagrams are very interactive and you can actually visualize like how your plane has been drawn but it is very difficult to do more than three because those features are not have matplotlib so what we do is that you basically follow a pair plot and again in a two dimensional way we try to see oh this was on all about this particular medium guys I hope you like this particular video many people had asked me this person how to plot visualization for multiple linear regression so because of that I just researched a lot and I have actually come up and like this video please to subscribe this channel please share with your friends like comment and never give up keep on learning this will always help you you should always have that winning attitude I'll see you all in the next video have a great here thank you one at all plot less or
Original Description
Multiple Linear Regression is similar to simple linear regression but the major difference being that we try to establish linear relationship between one response variable and more than one predictor variables. For example suppose that a researcher is studying that how the housing prices are affected by area of the apartment and the demand supply gap in that region. The response variable is apartment price (Y) and the predictor variables are area of apartment (X1) and demand supply gap (X2).
github link: https://github.com/krishnaik06/Visualize-Multiple-Linear-Regression
You can buy my book on Finance with ML and DL using python from the below link
amazon url: https://www.amazon.in/Hands-Python-Finance-implementing-strategies/dp/1789346371/ref=sr_1_1?keywords=Krish+naik&qid=1560843206&s=gateway&sr=8-1
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Krish Naik · Krish Naik · 51 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
▶
52
53
54
55
56
57
58
59
60
Natural Language Processing|Stemming
Krish Naik
Natural Language Processing|BagofWords
Krish Naik
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
Log Normal Distribution in Statistics
Krish Naik
Covariance in Statistics
Krish Naik
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
Pedestrian Detection using OpenCV from Videos
Krish Naik
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
OpenCV Installation | OpenCV tutorial
Krish Naik
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
Using OpenFace for Face recognition in Keras
Krish Naik
OpenPose Tutorial with Tensorflow
Krish Naik
Multiple Linear Regression using python and sklearn
Krish Naik
Dimensional Reduction| Principal Component Analysis
Krish Naik
Movie Recommender System using Python
Krish Naik
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
Precision, Recall and F1-Score
Krish Naik
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
K Means Clustering Intuition
Krish Naik
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
Hierarchical Clustering intuition
Krish Naik
Implement Transfer Learning with a generic Code Template
Krish Naik
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
Unlock Your Application With Your Face using OpenCV
Krish Naik
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
Complete Life Cycle of a Data Science Project
Krish Naik
How we can apply Machine Learning in Finance
Krish Naik
Deep Learning in Medical Science
Krish Naik
How to switch your career to Data Science.
Krish Naik
Linear Regression Mathematical Intuition
Krish Naik
Handle Categorical features using Python
Krish Naik
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
Cross Validation using sklearn and python | Machine Learning
Krish Naik
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
Deploy Machine Learning Model using Flask
Krish Naik
Deployment of Deep Learning Model using Flask
Krish Naik
How to Visualize Multiple Linear Regression in python
Krish Naik
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
Predicting Heart Disease using Machine Learning
Krish Naik
Predicting Lungs Disease using Deep Learning
Krish Naik
Stock Sentiment Analysis using News Headlines
Krish Naik
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
Hyperparameter Optimization for Xgboost
Krish Naik
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik
More on: ML Maths Basics
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
I Spent Weeks Looking for a Research Gap Before I Realized I Was Searching the Wrong Way
Medium · AI
ICMI 2026 Reviews [D]
Reddit r/MachineLearning
Workshop submission for main conference paper under review [D]
Reddit r/MachineLearning
Kept context-switching between arxiv, OpenReview, GitHub, and HuggingFace for every paper, so I built this. Chrome extension + website with everything inline, plus citation graph + SPECTER2 neighbors. 3M papers, free, feedback welcome [P]
Reddit r/MachineLearning
🎓
Tutor Explanation
DeepCamp AI