(Sorry if there’s an obvious response, I’m completely new to R.)
I’m using the zip file submission approach and it says to NOT modify the Predict.r script.
Let’s say I have two trained models, a glm and a random forest.
Can I modify the code to something like:
claims = predict_expected_claim(trained_model_glm, trained_model_rf, Xraw) ?
(in order to pass two trained models?)
Hi @michael_bordeleau and welcome to the challenge
You cannot alter the predict files that way as when we call it we don’t pass two models.
However, you can train two models in your
fit_model function and return a vector (or list) with the models.
Then that vector gets saved and loaded and you will then have to write the logic within your
predict_premium functions to expand the vector and make the predictions accordingly.
Why cannot we alter the prediction file codes?
Are we also not allowed to modify the number of arguments we can pass to any other function (in model file)?
It is more a curiosity if those are kind of restrictions we have.
The only functions you are allowed to change in terms of number of arguments given are:
- Any preprocessing functions you write
The reason you cannot alter the prediction files is because our servers call on those functions directly to generate predictions by feeding them 2 arguments (your model and the data). Hence if you alter the number of required arguments your code will not be able to run.
A note on the remaining code files if you are using
R and want to use something other than an
.RData file to save your models:
predict.R. You will have to alter the
train.R. Similarly you will have to alter the
We are going to push an update that fixes the R issue soon!
Thank you so much for you answer, precise as always.
But are you sure it doesn’t work? I did a submission with more than one model modifying both the function in model file and the call in predict and it went good.
Did i do something “illegal”?
I can give you the number of submission if you need.
That’s why we’re here
It might work, but there would be no guarantee that it will continue to do so if we change some minor details in the backend. That’s why it’s safer not to.
And yes, that would be helpful, what is the submission number?
Aah okay, so in case I want to use them in the future it would be more safe to not modify but to use a list or a vector.
Here it is the submission that worked with more than one model:
Ah I see. Thanks for bringing this to our attention.
Yes please refrain from doing it this way because the moment we change something in the backend this might not run properly.
But the solution should be easy enough as a list correct? Or do you think that raises other issues that we should account for?
Ok thank you, I will try to use a list then.
I will let you know if some new problems come out.