Wine Quality Prediction with Machine Learning (part 2) — Train Test Split & Linear Regression Plots
Hello Everyone! My name is Andrew Fung, in this video, I will be showing you how to create a Wine Quality Prediction Project as a part of the Machine Learning series. I will be walking you through different processes and steps to take to slowly train and enhance the performance of your models, such as data preprocessing, features selection, feature correlation , classification and hyper parameters tuning. Hope you enjoy this tutorial ;)
#python #linearregression #machinelearning #traintestsplit
Installation and Setup!
Installing Jupyter Notebook: https://jupyter.readthedocs.io/en/lat...
Sklearn linear regression doc: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html
Check out my Github!
https://github.com/Andrew-FungKinHo
Timestamps
0:00 | Introduction
0:32 | Train Test Data Split
3:55 | Linear Regression Plot
14:31 | Out tro
Full code:
———————————————————————————————
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt
# use the train test split submodule in scikit-learn to split the data in train.csv, with 80% for training and 20% for validation.
X_train, X_valid, y_train, y_valid = train_test_split(df_train.iloc[:,:10],
df_train.iloc[:,10:],
train_size=0.8,
random_state=69)
# For each specified x attribute, create a linear regression model against DENSITY and compute the r2 scores
columns_concerned = ['fixed acidity', 'residual sugar', 'chlorides', 'free sulfur dioxide', 'total sulfur dioxide', 'alcohol']
y_density = df_train.loc[:,df_train.columns == 'density']
for i in range(len(columns_concerned)):
x_lin = df_train.loc[:,df_train.columns== columns_concerned[I]]
X_train, X_valid, y_train, y_valid = train_test_split(x_lin,
y_density,
test_size= 0.2,
random_state=69)
# create a linear Regression model
model_1 = LinearRegression()
model_1.fit(X_train,y_train)
y_predict = model_1.predict(X_valid)
r2 = r2_score(y_valid,y_predict)
# print(f'{columns_concerned[i]} : {r2}')
# Plot the linear regression graphs
plt.figure(figsize=(12,10))
plt.subplot(3,2,i+1)
plt.title(f'Desnsity vs {columns_concerned[i]} \n (R^2 = {r2})')
plt.scatter(X_valid,y_valid,color='black')
plt.plot(X_valid,y_predict,color='red',linewidth=3)
plt.tight_layout()
plt.show()
———————————————————————————————
Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!
Видео Wine Quality Prediction with Machine Learning (part 2) — Train Test Split & Linear Regression Plots канала Andrew Fung
#python #linearregression #machinelearning #traintestsplit
Installation and Setup!
Installing Jupyter Notebook: https://jupyter.readthedocs.io/en/lat...
Sklearn linear regression doc: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html
Check out my Github!
https://github.com/Andrew-FungKinHo
Timestamps
0:00 | Introduction
0:32 | Train Test Data Split
3:55 | Linear Regression Plot
14:31 | Out tro
Full code:
———————————————————————————————
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt
# use the train test split submodule in scikit-learn to split the data in train.csv, with 80% for training and 20% for validation.
X_train, X_valid, y_train, y_valid = train_test_split(df_train.iloc[:,:10],
df_train.iloc[:,10:],
train_size=0.8,
random_state=69)
# For each specified x attribute, create a linear regression model against DENSITY and compute the r2 scores
columns_concerned = ['fixed acidity', 'residual sugar', 'chlorides', 'free sulfur dioxide', 'total sulfur dioxide', 'alcohol']
y_density = df_train.loc[:,df_train.columns == 'density']
for i in range(len(columns_concerned)):
x_lin = df_train.loc[:,df_train.columns== columns_concerned[I]]
X_train, X_valid, y_train, y_valid = train_test_split(x_lin,
y_density,
test_size= 0.2,
random_state=69)
# create a linear Regression model
model_1 = LinearRegression()
model_1.fit(X_train,y_train)
y_predict = model_1.predict(X_valid)
r2 = r2_score(y_valid,y_predict)
# print(f'{columns_concerned[i]} : {r2}')
# Plot the linear regression graphs
plt.figure(figsize=(12,10))
plt.subplot(3,2,i+1)
plt.title(f'Desnsity vs {columns_concerned[i]} \n (R^2 = {r2})')
plt.scatter(X_valid,y_valid,color='black')
plt.plot(X_valid,y_predict,color='red',linewidth=3)
plt.tight_layout()
plt.show()
———————————————————————————————
Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!
Видео Wine Quality Prediction with Machine Learning (part 2) — Train Test Split & Linear Regression Plots канала Andrew Fung
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Trial and Error (Ep.2): Python Import Error from Saving Filename same as Python Module Name #Shorts](https://i.ytimg.com/vi/tE28XAz4pP0/default.jpg)
![How to build your own Wolfram Alpha — Math Equation Visualization with Tkinter and wolframalpha API](https://i.ytimg.com/vi/74MBv4rN9NA/default.jpg)
![Smart Fan Presentation](https://i.ytimg.com/vi/Tg3nHFNGaO8/default.jpg)
![Wine Quality Prediction with Machine Learning (part 1) — Data preprocessing and Feature Correlation](https://i.ytimg.com/vi/vXL2eDnih0I/default.jpg)
![Set webhook and message handlers — Creating a CRM distribution Telegram bot with Notion API (EP.2)](https://i.ytimg.com/vi/HsugJwBuH-Q/default.jpg)
![Scripting Audio Conversations (part 2) - User Files Upload with Google SpeechToText and Python Dash](https://i.ytimg.com/vi/mOMZmY3VgHA/default.jpg)
![SONAS - Speech to Text App for the Hearing Impaired](https://i.ytimg.com/vi/qhEXHAxdqno/default.jpg)
![How to build an Interactive Ad-scraping Keyword Analysis Web App with Streamlit Python & ScraperAPI](https://i.ytimg.com/vi/yb1OF33pNTQ/default.jpg)
![How to Schedule CronJobs to Send Email Notifications — Python Task Automation with CronJobs (part 2)](https://i.ytimg.com/vi/vscDphDAcQM/default.jpg)
![Finding the correlation coefficients between two variables --- Data Analysis with Python and Pandas](https://i.ytimg.com/vi/VB9tFoX4icw/default.jpg)
![How to plot moving race bars animation — Data Visualisation with Python and Pandas](https://i.ytimg.com/vi/ZkgoJk6-3o4/default.jpg)
![Finding the Most Profitable Keywords by Plotting Competitor Analysis Graphs — with Python Streamlit](https://i.ytimg.com/vi/3YVUe6uGieI/default.jpg)
![Build and deploy a simple bot — Creating a CRM distribution Telegram bot with Notion API (EP.1)](https://i.ytimg.com/vi/sfCkKnBhULs/default.jpg)
![Create a Simple Programming Joke Generator that look like a Tweet -with HTML, CSS and Javascript](https://i.ytimg.com/vi/RpFI0kSwlYI/default.jpg)
![First steps to approach a dataset — Introduction to Data analysis with Pandas and Python](https://i.ytimg.com/vi/uZVK-WtimTk/default.jpg)
![User authentication and customized messages — Creating a CRM Telegram bot with Notion API (EP.3)](https://i.ytimg.com/vi/un30EJ9NVsA/default.jpg)
![Sending documents and updating customer status — Creating a CRM Telegram bot with Notion API (EP.4)](https://i.ytimg.com/vi/xuxtnFG9CxQ/default.jpg)
![How to Automate Web Scraping Task with BeautifulSoup — Python Task Automation with CronJobs (part 1)](https://i.ytimg.com/vi/Z4OBn83Rmj8/default.jpg)
![Targeted Keyword and Competitor Analysis with Google Ads — Python Web Scraping Task Automation](https://i.ytimg.com/vi/DXju-2RF4jw/default.jpg)
![Animating HTML Ranking Table with Javascript & JQuery — Realtime Crypto Prices Changes Leaderboard](https://i.ytimg.com/vi/bppuXpcJUvk/default.jpg)