Загрузка страницы

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
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
3 апреля 2021 г. 21:19:37
00:15:12
Другие видео канала
Trial and Error (Ep.2): Python Import Error from Saving Filename same as Python Module Name #ShortsTrial and Error (Ep.2): Python Import Error from Saving Filename same as Python Module Name #ShortsHow to build your own Wolfram Alpha — Math Equation Visualization with Tkinter and wolframalpha APIHow to build your own Wolfram Alpha — Math Equation Visualization with Tkinter and wolframalpha APISmart Fan PresentationSmart Fan PresentationWine Quality Prediction with Machine Learning (part 1) — Data preprocessing and Feature CorrelationWine Quality Prediction with Machine Learning (part 1) — Data preprocessing and Feature CorrelationSet webhook and message handlers — Creating a CRM distribution Telegram bot with Notion API (EP.2)Set webhook and message handlers — Creating a CRM distribution Telegram bot with Notion API (EP.2)Scripting Audio Conversations (part 2) - User Files Upload with Google SpeechToText and Python DashScripting Audio Conversations (part 2) - User Files Upload with Google SpeechToText and Python DashSONAS - Speech to Text App for the Hearing ImpairedSONAS - Speech to Text App for the Hearing ImpairedHow to build an Interactive Ad-scraping Keyword Analysis Web App with Streamlit Python & ScraperAPIHow to build an Interactive Ad-scraping Keyword Analysis Web App with Streamlit Python & ScraperAPIHow to Schedule CronJobs to Send Email Notifications — Python Task Automation with CronJobs (part 2)How to Schedule CronJobs to Send Email Notifications — Python Task Automation with CronJobs (part 2)Finding the correlation coefficients between two variables --- Data Analysis with Python and PandasFinding the correlation coefficients between two variables --- Data Analysis with Python and PandasHow to plot moving race bars animation — Data Visualisation with Python and PandasHow to plot moving race bars animation — Data Visualisation with Python and PandasFinding the Most Profitable Keywords by Plotting Competitor Analysis Graphs — with Python StreamlitFinding the Most Profitable Keywords by Plotting Competitor Analysis Graphs — with Python StreamlitBuild and deploy a simple bot — Creating a CRM distribution Telegram bot with Notion API (EP.1)Build and deploy a simple bot — Creating a CRM distribution Telegram bot with Notion API (EP.1)Create a Simple Programming Joke Generator that look like a Tweet -with HTML, CSS and JavascriptCreate a Simple Programming Joke Generator that look like a Tweet -with HTML, CSS and JavascriptFirst steps to approach a dataset — Introduction to Data analysis with Pandas and PythonFirst steps to approach a dataset — Introduction to Data analysis with Pandas and PythonUser authentication and customized messages — Creating a CRM Telegram bot with Notion API (EP.3)User authentication and customized messages — Creating a CRM Telegram bot with Notion API (EP.3)Sending documents and updating customer status — Creating a CRM Telegram bot with Notion API (EP.4)Sending documents and updating customer status — Creating a CRM Telegram bot with Notion API (EP.4)How to Automate Web Scraping Task with BeautifulSoup — Python Task Automation with CronJobs (part 1)How to Automate Web Scraping Task with BeautifulSoup — Python Task Automation with CronJobs (part 1)Targeted Keyword and Competitor Analysis with Google Ads — Python Web Scraping Task AutomationTargeted Keyword and Competitor Analysis with Google Ads — Python Web Scraping Task AutomationAnimating HTML Ranking Table with Javascript & JQuery — Realtime Crypto Prices Changes LeaderboardAnimating HTML Ranking Table with Javascript & JQuery — Realtime Crypto Prices Changes Leaderboard
Яндекс.Метрика