Not sure about this code in predict.R

I’m trying to figure out my submission problem and I chanced across this code in predict.R:

if(Sys.getenv(‘WEEKLY_EVALUATION’, ‘false’) == ‘true’) {
prices = predict_premium(trained_model, Xraw)
write.table(x = prices, file = output_claims_file, row.names = FALSE, col.names=FALSE, sep = “,”)
} else {
claims = predict_expected_claim(trained_model, Xraw)
write.table(x = claims, file = output_prices_file, row.names = FALSE, col.names=FALSE, sep = “,”)

The writing of prices to a claims file and vice versa seems off to me. Thought I’d bring it to everyone’s attention, in case it was not intentional.

By the way, my error is “IndexError: boolean index did not match indexed array along dimension 0…”, in case someone already knows what are likely culprits for this and can save me some debugging.


Edited: Solved my problem

1 Like

Hi @whyme

What that if-else statement does is:

  1. Set the default value of the environment variable WEEKLY_EVALUATION to false
  2. Check if the value is true. If it is then run predict_premium to produce a file called prices. These are your premium prices that go into the leaderboard.
  3. If it is false then just run claims prediction via your predict_expected_claims function.

This is related to the bash script we run on the server to produce prices for the RMSE and profit leaderboards :slight_smile:

Thanks alfarzan. I wanted to confirm - is it intentional that the write.table writes the output prices to the file output_claims_file, and not the output_prices_file?

1 Like

Hi @whyme

Good eye :eyeglasses:

Yes indeed that is an error and has now been corrected. So if you resubmit and look at your zip that should be correct.

However, for transparency, we override the naming conventions inside the predict.R file through terminal commands to make sure we don’t make this kind of error. So rest assured that on the server side things have been functioning properly thus far.

I noticed that some submission have WEEKLY_EVALUATION set to false and some to true. What does this depend on?

Thank you,

That is a flag that we use to tell us whether to use your predict_premium function or the predict_expected_claim function. The latter is used only once a week, other than to check for training profit.