Response variable should be larger or equal to 0 but some prediction values smaller than 0


#1

I use R package “xgboost” to train the model. And my response variable are species richness, and I used the trained model to predict. But there are some negative values in prediction. But actually richness should be >= 0. So is any suggestion to solve this?


#2

Try log-transforming the label (response) so that it ranges from -inf to inf. Then at prediction time, you can take the exponential function.