pysindy icon indicating copy to clipboard operation
pysindy copied to clipboard

Optimizer parameters validation improvement

Open himkwtn opened this issue 1 year ago • 1 comments

Right now, parameters validation is done in the constructor as follows https://github.com/dynamicslab/pysindy/blob/3e8a4455fd4de046225344dda9b516d0d013ee36/pysindy/optimizers/sr3.py#L138-L163

According to the scikit-learn documents, validations should be done in the fit method because if we call set_params, it will bypass the validation in the constructor.

Reproducing code example:

from pysindy.optimizers import SR3
opt = SR3(threshold=-1)
# raises "ValueError: threshold cannot be negative"
from pysindy.optimizers import SR3
opt = SR3()
opt.set_params(threshold=-1)
# no error

himkwtn avatar Aug 07 '24 19:08 himkwtn