Multi-feature matrix regression?

1 次查看(过去 30 天)
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
Ahmet Cecen 2016-5-17
编辑:Ahmet Cecen 2016-5-17
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).

更多回答(2 个)

Walter Roberson
Walter Roberson 2015-10-4
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
Walter Roberson 2016-5-17
You have indicated that you accepted the answer by mistake. Please explain further why the above did not work for you.

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by