I have a function that will create multiple ML models compare them and return an ensemble of the top n model results. I want the user to have the option to pass in parameters for each model individually but otherwise enter default parameters. I want to make it so the entering parameters is intuitive and easy.
Here is what my code looks like:
def buildModel(X, y, n, rfParams, knnParams, SVCParams, lrParams, lgbParams, xgbParams):
mod1 = rf(**rfParams)
mod2 = Pipeline([('scaler', StandardScaler()), ('clf', knn(**knnParams))])
mod3 = Pipeline([('scaler', StandardScaler()), ('clf', SVC(**SVCParams))])
mod4 = Pipeline([('scaler', StandardScaler()), ('clf', lr(**lrParams))])
mod5 = lgb.LGBMClassifier(**lgbParams)
mod6 = xgb.XGBClassifier(**xgbParams)
mods = [mod1, mod2, mod3, mod4, mod5, mod6]
mod = ensemble(mods, n)
return mod
I want to make any parameter other than X, y and n to be an optional input (i.e. the user can call buildModel(X, y, n)). I also want it to be that the function infers what model the parameter is for without it being explicit/hard coded. I understand you can use *args or **kwargs but I am a bit unfamiliar and I want to avoid a massive if elif statement which is why I am hesitant for dictionaries and I want to make this robust.
Is this achievable and what is the best solution?