LFD Book Forum  

Go Back   LFD Book Forum > General > General Discussion of Machine Learning

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2012, 10:59 PM
Daniel Daniel is offline
Junior Member
 
Join Date: Jun 2012
Posts: 4
Default Polynomial regression

I'm curious about using polynomial regression with multiple features. I understand how to use polynomial hypotheses with univariate regression, but I'm unsure how to extend this to multiple features. Let's say I want to use a cubic polynomial. Do I introduce three terms in the hypothesis for each feature x^1 and x^2 and x^3 ?? So in effect, I'm tripling the number of features (or terms in the hypothesis equation)?

Thank you.

Daniel
Reply With Quote
  #2  
Old 09-19-2012, 04:49 PM
magdon's Avatar
magdon magdon is offline
RPI
 
Join Date: Aug 2009
Location: Troy, NY, USA.
Posts: 595
Default Re: Polynomial regression

You can certainly implement your suggestion, but it is technically not the 3rd order polynomial transform, although it is a form of polynomial transform. You would introduce every term that is at most 3rd order to get the full 3rd order polynomial transform. Here are those terms:

1

x_1,\ x_2,\ x_3

x_1^2,\ x_1x_2,\ x_1x_3,\ x_2^2,\ x_2x_3,\ x_2^3

x_1^3,\ x_1^2x_2,\ x_1^2x_3,\ x_1x_2^2,\ x_1x_3^2,\ x_1x_2x_3,\ x_2^3,\ x_2^2x_3,\ x_2x_3^2,\ x_3^3

If you have d variables and you want the Q-order polynomial transform, there are quick algorithms to generate these terms. As you can see, the number of terms rises very quickly. In this example you have done much worse than tripling. In general, for the Q-order polynomial transform with d variables, the number of terms is

\left(\begin{array}{c}d+Q\\Q\end{array}\right)=\frac{(d+Q)!}{d!Q!}.

Quote:
Originally Posted by Daniel View Post
I'm curious about using polynomial regression with multiple features. I understand how to use polynomial hypotheses with univariate regression, but I'm unsure how to extend this to multiple features. Let's say I want to use a cubic polynomial. Do I introduce three terms in the hypothesis for each feature x^1 and x^2 and x^3 ?? So in effect, I'm tripling the number of features (or terms in the hypothesis equation)?

Thank you.

Daniel
__________________
Have faith in probability
Reply With Quote
  #3  
Old 09-27-2012, 09:00 PM
Daniel Daniel is offline
Junior Member
 
Join Date: Jun 2012
Posts: 4
Default Re: Polynomial regression

Dear Dr. Magdon,

Thank you so much for the informative reply. Of course, your solution makes perfect sense. It just wasn't obvious to me. I shall experiment with this.

Cheers,

Daniel
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:30 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
The contents of this forum are to be used ONLY by readers of the Learning From Data book by Yaser S. Abu-Mostafa, Malik Magdon-Ismail, and Hsuan-Tien Lin, and participants in the Learning From Data MOOC by Yaser S. Abu-Mostafa. No part of these contents is to be communicated or made accessible to ANY other person or entity.