Pass a dict to scikit learn estimator

I got it. Used setattr like this.

for k,v in params.items():
   setattr(lr,k,v)

The best solution to initialise your estimator with the right parameters would be to unpack your dictionary:

lr = LinearRegression(**params)

If for some reason you need to set some parameters afterwards, you could use:

lr.set_params(**params)

This has an advantage over using setattr in that it allows Scikit learn to perform some validation checks on the parameters.