# Polynomial Linear Regression

In this ML Algorithms course tutorial, we are going to learn “Polynomial Linear Regression in detail. we covered it by practically and theoretical intuition.

- What is a Linear Regression?
- What is Multiple Linear Regression?
- What is Polynomial Linear Regression?
- What is the R^2 score?
- Why need to use it?
- How to implement Polynomial Regression in python?

```
# Business Problem - Predict the Price of Bangalore House
#Using Linear Regression - Supervised Machine Learning Algorithm
### Load Libraries
import pandas as pd
import numpy as np
"""### Load Data"""
path = r"https://drive.google.com/uc?export=download&id=1xxDtrZKfuWQfl-6KA9XEd_eatitNPnkB"
df = pd.read_csv(path)
df.head()
"""### Split Data"""
X = df.drop('price', axis=1)
y = df['price']
print('Shape of X = ', X.shape)
print('Shape of y = ', y.shape)
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=51)
print('Shape of X_train = ', X_train.shape)
print('Shape of y_train = ', y_train.shape)
print('Shape of X_test = ', X_test.shape)
print('Shape of y_test = ', y_test.shape)
"""### Feature Scaling"""
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
sc.fit(X_train)
X_train = sc.transform(X_train)
X_test = sc.transform(X_test)
"""## Polynomial Linear Regression - ML Model Training"""
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
poly_reg = PolynomialFeatures(degree=2)
poly_reg.fit(X_train)
X_train_poly = poly_reg.transform(X_train)
X_test_poly = poly_reg.transform(X_test)
X_train_poly.shape, X_test_poly.shape
lr = LinearRegression()
lr.fit(X_train_poly, y_train)
lr.score(X_test_poly, y_test,)
lr.predict([X_test_poly[0,:]])
y_pred = lr.predict(X_test_poly)
y_pred
y_test
from sklearn.metrics import mean_squared_error
mse = mean_squared_error(y_test, y_pred)
rmse = np.sqrt(mse)
mse, rmse
"""Ab milenge next tutorial me,Tab tak ke liye SIKHATE SIKHATE kuch IMPLEMENT karte raho,\nThank You.....-:)"""
```

sir kindly preprocessing real time project step by step NAN values ko kesay handle kren plz is pay video banen

Please go through the channel Playlist: Machine Learning & Data Science – Beginner to Professional Hands-on Python Course in Hindi

I have explained all things.

sir please make a seprate video that how to do feature scaling for any kind of data.

I have made already, please follow the course playlist on https://www.youtube.com/indianaiproduction