WildMeOrg / wildbook-ia

Wildbook's Image Analysis (WBIA) backend service supporting machine learning for wildlife conservation
https://wildbook.org
Apache License 2.0
76 stars 19 forks source link

Fix StratifiedGroupKFold __init__ TypeError #201

Closed karenc closed 2 years ago

karenc commented 2 years ago

The upgrade from scikit-learn 0.24.2 to 1.0 changed the arguments so we need to use keyword arguments instead:

Traceback (most recent call last):
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/web/graph_server.py", line 185, in handle
    return func(**message)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/web/graph_server.py", line 569, in resume
    user_request = actor.infr.resume()
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/graph/mixin_loops.py", line 642, in resume
    user_request = next(infr._gen)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/graph/mixin_loops.py", line 95, in main_gen
    yield from infr.hardcase_review_gen()
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/graph/mixin_loops.py", line 174, in hardcase_review_gen
    verifiers = infr.learn_evaluation_verifiers()
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/graph/mixin_matching.py", line 608, in learn_evaluation_verifiers
    pblm.setup_evaluation()
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/verif/vsone.py", line 876, in setup_evaluation
    pblm.learn_evaluation_classifiers(task_keys, clf_keys, data_keys)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/verif/clf_helpers.py", line 132, in learn_evaluation_classifiers
    pblm._ensure_evaluation_clf(task_key, data_key, clf_key)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/verif/clf_helpers.py", line 177, in _ensure_evaluation_clf
    data = pblm._train_evaluation_clf(task_key, data_key, clf_key)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/verif/clf_helpers.py", line 211, in _train_evaluation_clf
    skf_list = pblm.samples.stratified_kfold_indices(**xval_kw)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/verif/clf_helpers.py", line 1392, in stratified_kfold_indices
    splitter = sklearn_utils.StratifiedGroupKFold(**xval_kw)
  File "/home/runner/work/wildbook-ia/wildbook-ia/wbia/algo/verif/sklearn_utils.py", line 42, in __init__
    super(StratifiedGroupKFold, self).__init__(n_splits, shuffle, random_state)
TypeError: __init__() takes 2 positional arguments but 4 were given
Erotemic commented 2 years ago

FWIW: This is the current version of that file I've been using: https://github.com/Kitware/kwcoco/blob/master/kwcoco/util/util_sklearn.py

bluemellophone commented 2 years ago

Thank you, @Erotemic, for the copy you are using. I've merged your implementation with our code (albeit I substituted kwarray for utool's version). Hopefully, the tests pass now.

@karenc I've merged in fix-tests-2 into this fix to peg the version number. We can keep that fixed version for now and also incorporate JC's fixes. Luckily, this change only impacts CLF and the VAMP models, so this failing test has a limited impact outside of the GraphID and LCA implementations (and for limited species)