title: Python: create a polynomial of degree n
body: <p>I have a feature set</p>
  
  <pre><code>[x1,x2....xm]
  </code></pre>
  
  <p>Now I want to create polynomial feature set
  What that means is that if degree is two, then I have the feature set</p>
  
  <pre><code>[x1.... xm,x1^2,x2^2...xm^2, x1x2, x1x3....x1,xm......xm-1x1....xm-1xm]
  </code></pre>
  
  <p>So it contains terms of only of order 2..
  same is if order is three.. then you will have cubic terms as well..</p>
  
  <p>How to do this?</p>
  
  <p>Edit 1: I am working on a machine learning project where I have close to 7 features... and a non-linear regression on this linear features are giving ok result...Hence I thought that to get more number in features I can map these features to a higher dimension..
  So one way is to consider polynomial order of the feature vector... 
  Also generating x1*x1 is easy.. :) but getting the rest of the combinations are a bit tricky..</p>
  
  <p>Can combinations give me x1x2x3 result if the order is 3?</p>