Got it

How to train a Polynomial Regression Model

Latest reply: Dec 18, 2021 16:22:39 684 19 5 0 0

How to train a Polynomial Regression Model

Polynomial Regression is a supervised learning model outputting a continuous numeric value. Different from the classical linear regression, it helps to fit to nonlinear data. While linear regression fit just a linear line to the data.

Tools/libraries

            Usage

Jupyter Notebook

It’s a client-server web app build with IPython.

All our coding will be done here.

We choose to use it because it’s based on   interactive Python.

Matplotlib

It’s a python library used for Data Visualisation

Seaborn

It’s a python library used for Data Visualisation   build on Matplotlib

Pandas

It’s a famous python library used for data   manipulation and analysis

NumPy

Also, famous python library used for numerical   computing

Scikit-learn

One of the mostly used Machine learning library   based on python.

It contains a lot of models ready to use.

 

Scenario:

As a data science engineer, we were asked by an advertising company  to build a model which will predict the sales given the spend in ad campaign. The latter include (TV, newspaper and Radio).

The dataset looks like this:



data_set_polynomial_regression


The ad data is stored inside a pandas DataFrame .It has 200 rows.

To be able to build our polynomial regression model we will need these tools and libraries:

 

To build our model we will follow these steps:

1.     Read our data set;

In general, the data set gathered for the purpose of ML is stored in csv files. So, to be able to work with we must store them inside a Pandas Data Frame.

2.     Separate features from labels;

We’re dealing with a supervised learning problem, so the data already contains the output. Hence, we must separate them from features for further use.

3.     Transform the features into polyfeatures;

To be able to fit the non-linear data, we must create polyfeatures based on the existing features.

4.     Split the data set;

This is a general machine learning step: divide the data set into training set test set and validation set.

The purpose of the training set is to find the best parameters that fit to the model we’re building (here polynomial regression).

The test set here, is to evaluate, measure the performances of our model on the data it has never seen.

5.     Find the right degree for our model;

To be able to fit a non linear data, we must create polyfeatures as we already said but, for the purpose of creating polyfeatures we must choose the right degree so as to avoid overfitting and underfitting.

6.     Train the model with the chosen degree;

After chosen the right degree, we just need to train our model on it.

7.     Test it with the training set.

 

 


  • x
  • convention:

LilStylz237
Moderator Created Jul 18, 2021 11:53:58

very good dear
View more
  • x
  • convention:

Irshadhussain
Irshadhussain Created Jul 18, 2021 17:47:33 (0) (0)
yes  
Irshadhussain
Irshadhussain Created Jul 18, 2021 17:47:39 (0) (0)
 
Vlada85
MVE Author Created Jul 18, 2021 17:45:17

Well done!
View more
  • x
  • convention:

Irshadhussain
Created Jul 18, 2021 17:47:19

Well done!
View more
  • x
  • convention:

chantha
chantha Created Jul 19, 2021 02:04:19 (0) (0)
 
Irshadhussain
Created Jul 18, 2021 17:47:26

Thanks for sharing
View more
  • x
  • convention:

chantha
chantha Created Jul 19, 2021 02:04:26 (0) (0)
 
olive.zhao
Admin Created Jul 19, 2021 01:54:17

Nice!
View more
  • x
  • convention:

kunthea
kunthea Created Jul 19, 2021 02:30:46 (0) (0)
 
chantha
Created Jul 19, 2021 02:04:01

Good one
View more
  • x
  • convention:

NTan33
Created Jul 19, 2021 02:08:28

An interesting topic indeed.
View more
  • x
  • convention:

kunthea
kunthea Created Jul 19, 2021 02:30:51 (0) (0)
 
csk99
csk99 Created Jul 20, 2021 07:35:44 (0) (0)
 
Unicef
MVE Created Jul 19, 2021 13:44:24

great
View more
  • x
  • convention:

csk99
csk99 Created Jul 20, 2021 07:35:32 (0) (0)
 
Anno7
Moderator Author Created Aug 26, 2021 11:51:59

great
View more
  • x
  • convention:

12
Back to list

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.
Information Protection Guide
Thanks for using Huawei Enterprise Support Community! We will help you learn how we collect, use, store and share your personal information and the rights you have in accordance with Privacy Policy and User Agreement.