ankane/xgboost-ruby

How to pass importance_type to booster.score

Closed this issue · 3 comments

Thanks so much for making this gem!

How do I pass "importance_type" to booster.score? I kept getting an error "wrong number of arguments (given 2, expected 0)"
https://github.com/ruby-ml/xgboost-ruby/blob/master/lib/xgboost/booster.rb

Also I saw 'feature_importances' inside Xgboost::model but I can't figure out how to call that feature_weights. Though sounds like using 'score' is probably better anyways per https://datascience.stackexchange.com/questions/34209/xgboost-quantifying-feature-importances#:~:text=In%20xgboost%200.7.post3%3A%20XGBRegressor.feature_importances_%20returns%20weights%20that%20sum,here%2C%20features%20with%200%20importance%20will%20be%20excluded.

ankane commented

Hi @inspire22, you should be able to use booster.score(importance_type: "..."). Can you paste the stack trace of the error?

ankane commented

From the message, it seems like you're using positional arguments instead of keyword.

Indeed that worked, thanks!