Reputation: 41
I've been using scikit learn, very neat. Fitting a polynomial curve through points (X-Y) is pretty easy. If I have N points, I can chose a polynomial of order N-1 and the curve will fit the points perfectly.
If my X vector has several dimension, in scikit-learn I can build a pipeline with a PolynomialFeatures and a LinearRegression. Where I am stuck is having a bit more flexibility with the numbers of features created by PolynomialFeatures (which is not an input); I'd like to be able to specify the total amount of features, with the end goal to have a polynomial that goes through all the points. E.g. in 3D (X has 3 columns), if I have 27 points (square matrix of 3X3X3); I'd like to limit the number of features to 27.
(PolynomialFeatures does have an attribute of powers_, but it can't be set. Exploring the source also does not seem to show anything specific).
Any ideas?
Cheers, N
Upvotes: 1
Views: 367
Reputation: 11424
Your question is ill defined. If you want, say, 14 features of 34 possible, which 14 should that be?
In your place, I would generate a redundant number of features and then would use a feature selection algorithm. It would be a sparse model (like Lasso
) or a feature elemination algorithm (like RFE
).
Upvotes: 1