lindermanlab / ssm

Bayesian learning and inference for state space models
MIT License
559 stars 197 forks source link

Regularization of GLM weights for input driven observations and transitions #149

Open sarathnayar opened 2 years ago

sarathnayar commented 2 years ago

I see that for InputDrivenObservations, there are parameters prior_mean and prior_sigma which governs strength of the prior on GLM weights. Does this act as an L2 regularization? Otherwise, if I were to add an L1 or L2 penalty or a custom regularizer on the GLM weights, should I add the regularization term only in the calculation of log_prior or also in the _objective, _gradient, and _hess functions?

slinderman commented 1 year ago

Looking at the code, it doesn't look like prior_mean actually gets used in the M step! It only gets used in the calculation of log_prior(), which is used for tracking convergence of EM. On the other hand, prior_sigma does get used, and it specifies the scale of the L2 regularization though. If you wanted to add L1 regularization you'd have to make the change in all of the functions you listed. However, there are better optimization methods for mixed L1/L2 regularization than the trust_ncg method used in this implementation. It could be a lot of work... it might be better to call into an off-the-shelf optimizer like cvxpy.