Implementing Multiple Linear Regression in Python

preview_player
Показать описание
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.

Рекомендации по теме
Комментарии
Автор

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 =
print(dataset.shape)
dataset.head()


Spend'], dataset['Profit'])
plt.title('Multiple Regression')
plt.xlabel('Marketing Spend')
plt.ylabel('Profit')
plt.show()

, 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()




== 'New York', 1, 0)
== 'Florida', 1, 0)
== '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
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)

improgrammer
Автор

thank you so much sir.
It is very clear explanation and helpful.

mohitnamdev
Автор

thank you so much very clear explanation very helpful.

saitarun
Автор

Good explanation. I don't know if you did not check for outliers on purpose.

christheprophet
Автор

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.

snivesz
Автор

Sir I am getting key error in creating the figure object can u please help me with this

poojardyrccertificatecade
Автор

Could u please make a video on other ai models like rbf, anfis Or rnn?

cricplay
Автор

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.

meetkcs