Does any1 know how modify mapFeature to work with any number of X input features?
I have it working for 2 features and I suppose I could hardwire it for my problem I just want to create a dynamic function that can handle any number of X.
Am 01.12.11 19:00, schrieb Michael Taylor:
> Does any1 know how modify mapFeature to work with any number of X input
> features?
If I understand you right then you want to create polynomial features.
> I have it working for 2 features and I suppose I could hardwire it for
> my problem I just want to create a dynamic function that can handle any
> number of X.
>
> degree = 2;
> out = ones(size(X1(:,1)));
> for i = 1:degree
> for j = 0:i
> out(:, end+1) = (X1.^(i-j)).*(X2.^j);
> end
> end
> I have this so far it works with a second order polynomial but nothing else
> http://pastebin.com/puD0MRQR
> I was wondering if some 1 could give me some pointers with this I am
> making "progress" but my solutions make me want to barf.
In order to create polynomial features from a given 1D feature vector
you can use the following octave/matlab function:
https://gist.github.com/1418711
Hopefully this helps you!
Cheers,
Herbert
--
=================================================================
Herbert Muehlburger Software Development and Business Management
Graz University of Technology
www.muehlburger.at www.twitter.com/hmuehlburger
=================================================================