stanfordmlgroup / ngboost

Natural Gradient Boosting for Probabilistic Prediction
Apache License 2.0
1.64k stars 214 forks source link

Using other regressors #159

Closed ishitadaga closed 4 years ago

ishitadaga commented 4 years ago

I am new to ngboost, and was trying to use KNeighborsRegressor as my base learner, but it gives me this error: TypeError: fit() got an unexpected keyword argument 'sample_weight'. How do I solve this, and also what all other base regressors can I use other than DecisionTreeRegressor.

ryan-wolbeck commented 4 years ago

@ishitadaga sample_weight isn't a parameter for KNeighborsRegressor, see the docs here: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsRegressor.html#sklearn.neighbors.KNeighborsRegressor.fit Generally ngboost can use any of the base models in sklearn, you'll need to setup params specific to the base model you'd like to try. Sklearn base models : https://scikit-learn.org/stable/supervised_learning.html#supervised-learning

alejandroschuler commented 4 years ago

@ishitadaga I would consider asking the sklearn people to implement sample_weight for knn regression. It should be trivial to take a weighted average of outcomes among the nearest neighbors instead of an unweighted average. Or to make a neighbor with weight 5 count as all 5 neighbors, etc. I'm sure others have thought about this.