# Multi-feature matrix regression?

2 views (last 30 days)
ML on 4 Oct 2015
Edited: Ahmet Cecen on 17 May 2016
Hi, can anyone help to get the following regression done?
X is the input multi-dimension matrix (e.g. 90 rows * 20 columns). Y is the target one dimension vector (e.g. 90 rows * 1 column).
How the polynomial regression e.g. polytool can be applied for inputs with more than one feature (I need to test the model by different poly degrees)? What about the K-fold cross validation? how it can be formulated?
Thanks.

Ahmet Cecen on 17 May 2016
Edited: Ahmet Cecen on 17 May 2016
Use the function I created expressly for this purpose. And you are in luck, a lightning fast Leave One Out Cross Validation is already embedded in to the core functionality: http://www.mathworks.com/matlabcentral/fileexchange/34918-multivariate-polynomial-regression
All you have to do is MultiPolyRegress(X(:,selectcolumnvectors),Y,POWEROFPOLYNOMIAL,'figure').
Keep in mind the number of polynomial terms follow a pascal triangle, so don't create billion term polynomials. The code wasn't written with memory in mind. Below is a start (blue is number of feature vectors/columns, red is power of polynomial). Walter Roberson on 4 Oct 2015
It does not sound to me as if you are trying for a polynomial: it sounds to me as if you need a multinomial.
Construct a matrix of all of the various combinations you want, such as
A = [x(:,1), x(:,1).^2, x(:,1).^3, x(:,2), x(:,2).^2, x(:,1).*x(:,2), x(:,3), x(:,4), x(:,5).*x(:,6).*x(:,7) ..]
meaning (for example) c1*x1 + c2*x1^2 + c3*x1^3 + c4*x2 + c5*x2^2 + c5*x1*x2 + c6*x3 + c7*x4 + c8*x5*x6*x7 + ...
Then,
A\Y
will give the coefficients c1, c2, c3, ...
To use different degrees or a different mix of the various features, construct a different A matrix.

Walter Roberson on 17 May 2016
You have indicated that you accepted the answer by mistake. Please explain further why the above did not work for you.