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.
0 个评论
采纳的回答
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).
0 个评论
更多回答(2 个)
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.
0 个评论
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!