I have various subclasses of statistical models in my repo that typically take similar arguments but some may require special arguments. I’m writing a function to create, train, and score each model and then compare their accuracy. That leads to two linked questions:
- What is the best data structure to use to loop through models; and
- How would I pass the specific special arguments if/when they occur? I think this is a case for kwargs but am still fairly new to implementing kwargs.
My current planned architecture is:
def compare_models(dataframe, models):
results = {}
for model in models:
model.train(dataframe, )
results.update({model: []})
return results
I can make it work but looking for most elegant solution.
rdsencap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.