I am trying to solve the regression task. I found out that 3 models are working nicely for different subsets of data: LassoLARS, SVR and Gradient Tree Boosting. I noticed that when I make predictions using all these 3 models and then make a table of 'true output' and outputs of my 3 models I see that each time at least one of the models is really close to the true output, though 2 others could be relatively far away.
When I compute minimal possible error (if I take prediction from 'best' predictor for each test example) I get a error which is much smaller than error of any model alone. So I thought about trying to combine predictions from these 3 diffent models into some kind of ensemble. Question is, how to do this properly? All my 3 models are build and tuned using scikit-learn, does it provide some kind of a method which could be used to pack models into ensemble? The problem here is that I don't want to just average predictions from all three models, I want to do this with weighting, where weighting should be determined based on properties of specific example.
Even if scikit-learn not provides such functionality, it would be nice if someone knows how to property address this task - of figuring out the weighting of each model for each example in data. I think that it might be done by a separate regressor built on top of all these 3 models, which will try output optimal weights for each of 3 models, but I am not sure if this is the best way of doing this.
model.named_steps['lin_regr'].coef_) will give you some insights into how much each model in an ensemble contributes to the final solution. – constt Nov 07 '17 at 12:00X, y = make_regression(n_features=10, n_targets=1)it gives dimension error. can anyone please explain what to do? – Mohit Yadav Apr 12 '19 at 21:36model.fit(X_train, y_train)this line gives me error, when i make data set like thisX, y = make_regression(n_features=10, n_targets=1). – Mohit Yadav Apr 13 '19 at 13:47n_targets=1(or, do not specify it), I get an error:ValueError: Expected 2D array, got 1D array instead... Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.Well, I did the suggested reshape to both X and y, separately as well as both together, but the error does not go away. Furthermore, when I didX = np.array(X), I got aWin 32 PermissionError. How do I fix these errors when my target has only 1 column? – Kristada673 Aug 20 '19 at 03:06transformmethods, now the model works for1Dtraining data. – constt Jun 12 '20 at 12:23model.fit(X_train, y_train), even with small number of samples, and it produces deprecated warningsDeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.. – shahar_m Jul 19 '20 at 14:51