Master Linear Regression in Python: Step-by-Step Tutorial πŸ“Š

Learn how to perform linear regression prediction with Python using pandas, scikit-learn, and more. Perfect for data science enthusiasts and coders looking to enhance their skills!

Master Linear Regression in Python: Step-by-Step Tutorial πŸ“Š
AC
27.6K views β€’ Apr 10, 2023
Master Linear Regression in Python: Step-by-Step Tutorial πŸ“Š

About this video

#Coded by Andrew C

import pandas as pd
import numpy as np
from sklearn import datasets
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

wine_dataset = datasets.load_wine()

wine = pd.DataFrame(wine_dataset.data, columns=wine_dataset.feature_names)

X = wine[['ash']]
Y = wine['alcohol']

X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.3, random_state=1)
model = LinearRegression()
model.fit(X_train, Y_train)

new_RM = np.array([2.5]).reshape(-1,1)

print("Prediction: " + str(model.predict(new_RM)))

Video Information

Views

27.6K

Likes

224

Duration

0:06

Published

Apr 10, 2023

User Reviews

4.3
(5)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.

Trending Now