cobra icon indicating copy to clipboard operation
cobra copied to clipboard

Allow more tuning of the model hyperparameters.

Open sandervh14 opened this issue 2 years ago • 0 comments

Allow more tuning of the model hyperparameters.

While working on #126, I noticed that in the constructor of LogisticRegressionModel, a few hyperparameters are chosen as follows:

def __init__(self):
    self.logit = LogisticRegression(fit_intercept=True, C=1e9,
                                    solver='liblinear', random_state=42)     

When trying to optimize for the best model performance, one might want to try tuning the regularization hyperparameter C. In some cases, one might want to set fit_intercept to False as well, if the client sees no point in having it, per his business knowledge... Also, in text-book approaches, even trying different random_states is advised, to counter against lucky shot models or to verify model variance. And in case speed is of the essence, one might want to play around with different solvers.

This is now impossible. With the intent on a certain company case to maximally tune, I thought it could be a good idea to make this a possibility.

Task Description

To do so, the constructor of the LogisticRegressionModel must be adapted to take overrides of the default arguments, if the data scientist wants to pass that. It might be good to do this too for LinearRegressionModel, again for fit_intercept for example:

def __init__(self, *, fit_intercept=True, normalize=False, copy_X=True,
                 n_jobs=None, positive=False):

On the other hand, the case for normalize, n_jobs and positive is weak though, since we take care of that already internally in Cobra:

  • normalize: our preprocessing takes care of the features, not sure if normalizing upfront would have effect, but one might try, if we allow it now..
  • n_jobs: only has an effect when having multiple targets per the scikit-learn docs, we don't support that yet in Cobra
  • positive: we take care of that in Cobra already. But let's not "forbid" any tuning and make it possible for this as well. Even if it's just to allow someone to block the use of fit_intercept.

sandervh14 avatar Apr 08 '22 08:04 sandervh14