Multi-feature matrix regression?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ML
el 4 de Oct. de 2015
Editada: Ahmet Cecen
el 17 de Mayo de 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.
0 comentarios
Respuesta aceptada
Ahmet Cecen
el 17 de Mayo de 2016
Editada: Ahmet Cecen
el 17 de Mayo de 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).
0 comentarios
Más respuestas (2)
Walter Roberson
el 4 de Oct. de 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.
0 comentarios
Walter Roberson
el 17 de Mayo de 2016
You have indicated that you accepted the answer by mistake. Please explain further why the above did not work for you.
0 comentarios
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!