You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there are too few observations for the CV, SGLCV fails with an uninformative UnboundLocalError. This happens with groupyr 0.2.6, if I recall correctly I didn't have the problem with 0.2.4
/path/to/lib/python3.8/site-packages/sklearn/metrics/_regression.py:796: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples.
warnings.warn(msg, UndefinedMetricWarning)
[the UndefinedMetricWarning is repeated several times]
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/path/to/lib/python3.8/site-packages/groupyr/sgl.py", line 1120, in fit
self.l1_ratio_ = best_l1_ratio
UnboundLocalError: local variable 'best_l1_ratio' referenced before assignment
However, if I use less folds, it works:
model = gr.SGLCV(
l1_ratio=l1_ratio,
groups=groups,
scale_l2_by="group_length",
cv=3,
random_state=1234
).fit(X=X, y=y)
Comment
I think the error is because one fold only has 1 observation which I guess leads to a wrong R^2 metric and later on to some uncaught errors in the groupyr code. I'm not well versed with scikit-learn, so I don't know if a fix would be better in the scikit-learn code or in groupyr. However, it would be nice to get an informative error message instead of an error due to groupyr internals.
Describe the bug
When there are too few observations for the CV,
SGLCV
fails with an uninformativeUnboundLocalError
. This happens withgroupyr 0.2.6
, if I recall correctly I didn't have the problem with0.2.4
Steps/Code to Reproduce
Expected Results
A clear error message why it didn't work.
Actual Results
However, if I use less folds, it works:
Comment
I think the error is because one fold only has 1 observation which I guess leads to a wrong R^2 metric and later on to some uncaught errors in the
groupyr
code. I'm not well versed withscikit-learn
, so I don't know if a fix would be better in thescikit-learn
code or ingroupyr
. However, it would be nice to get an informative error message instead of an error due togroupyr
internals.Versions
The text was updated successfully, but these errors were encountered: