Implementing Multiple Linear Regression in Python
Вставка
- Опубліковано 4 лип 2020
- In this lecture, we talk about how to implement Linear Regression in Python.
We provide a plethora of courses ranging from Python to Essential Maths to Machine Learning and Deep Learning with industry relevant Capstone Projects. We also strive to help our students get high paying jobs in the field of Data Science through Resume Preparation, Mock Interviews and our connections with various HR Partners.
For more information, materials and Jupyter notebooks, please visit our website floatint.thinkific.com
thank you so much very clear explanation very helpful.
thank you so much sir.
It is very clear explanation and helpful.
Awesome Video ...very helpful.
Thank you. What is the purpose of scaling the exogenous variables before regression? It’s my understanding that that will only change the scale of the betas but not the significance of them.
Thanks that's really helpful
Good explanation. I don't know if you did not check for outliers on purpose.
Here is the full working code of this video, Use jupyter notebook for understanding.
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
import math
dataset = pd.read_csv("50_Startups.csv")
print(dataset.shape)
dataset.head()
plt.scatter(dataset['Marketing Spend'] , dataset['Profit'])
plt.title('Multiple Regression')
plt.xlabel('Marketing Spend')
plt.ylabel('Profit')
plt.show()
plt.scatter(dataset['Administration'] , dataset['Profit'])
plt.title('Multiple Regression')
plt.xlabel('Administration')
plt.ylabel('Profit')
plt.show()
plt.scatter(dataset['R&D Spend'] , dataset['Profit'])
plt.title('Multiple Regression')
plt.xlabel('R & D Spend')
plt.ylabel('Profit')
plt.show()
dataset['newyork']=np.where(dataset['State'] == 'New York' , 1, 0)
dataset['florida']=np.where(dataset['State'] == 'Florida' , 1, 0)
dataset['California']=np.where(dataset['State'] == 'California' , 1, 0)
dataset['profit'] = dataset['Profit']
dataset.drop(columns=['State'], axis=1,inplace=True)
dataset.drop(columns=['Profit'], axis=1,inplace=True)
print(dataset.head())
X=dataset.iloc[:,:6]
y=dataset.iloc[:,6:]
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0, test_size = 0.25)
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
X_train =scaler.fit_transform(X_train)
X_test = scaler.fit_transform(X_test)
X_train[0:5]
model = LinearRegression()
model.fit(X_train , y_train)
ypred = model.predict(X_test)
print(ypred)
math.sqrt(mean_squared_error(y_test, ypred))
r2_score(y_test, ypred)
i need to perform stepwise regression will you help me
Thank you 🙏
can i plot regression line on this?
Sir I am getting key error in creating the figure object can u please help me with this
Could u please make a video on other ai models like rbf, anfis Or rnn?
where i can download the dataset???
Excellent very simple way explained.
Thank you for the KT.
Can u plz share the dataset and code...I ll practice at my end once.
Some error come how solve
App or website name please
can u plz send whatsapp
hn aap pardhan ji ho