## Question

How to combine multiple models for final submission

Dr. Ballings,

Let's say that we have two models we would like to use for our predictions:

- First one is something like KNN where all computations are done in "predict()" part

- Second is random forest where we ca easily put in "modelbuilding()" function.

What would you advice on approaching this? In the past, my group would assign equal weights of predictions from each model and compute the

combination period.

However, since we need to turn in only two functions, we are not sure how we can do that.

Thank you!

## Answers and follow-up questions

** Answer or follow-up question 1**Dear student,

I'm not sure I understand your question.

Here is a stab at an answer to what I think you are asking.

If you have two models in your modelbuilding() function you simply return both in a list. If you have a KNN you don't have a model to

return. In that case you would only return the random forest.

In the predict function you would simply make two predictions, one for the random forest and one for the knn. You then take the (weighted)

average per instance and return that average.

Let me know if you have any remaining questions and if that answered your question.

Michel Ballings

** Answer or follow-up question 2** Dr. Balling,

Yes, that was my question. And your answer makes sense. Thanks!

Sign in to be able to add an answer or mark this question as resolved.