jbms / beancount-import

Web UI for semi-automatically importing external data into beancount
GNU General Public License v2.0
393 stars 103 forks source link

Crashing bug with SKLearn DictVectorizer #181

Closed jeffrey-ng closed 1 year ago

jeffrey-ng commented 1 year ago

Running manually_entered example data. After handling the initial data, re-rerunning beancount-import triggers crashing bug.

Listening at http://127.0.0.1:8101
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/webserver.py", line 525, in _handle_reconciler_loaded
    self.get_next_candidates(new_pending=True)
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/webserver.py", line 547, in get_next_candidates
    self.next_candidates, index, self.skip_ids = loaded_reconciler.get_next_candidates(
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py", line 878, in get_next_candidates
    return self._make_candidates_from_import_result(
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py", line 835, in _make_candidates_from_import_result
    predicted_accounts = self._get_unknown_account_predictions(
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py", line 733, in _get_unknown_account_predictions
    group_predictions = [
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py", line 734, in <listcomp>
    self.predict_account(prediction_input)
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py", line 700, in predict_account
    explanation = get_prediction_explanation(self.classifier, features)
  File "/opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py", line 139, in get_prediction_explanation
    feature_names = classifier._vectorizer.get_feature_names()
AttributeError: 'DictVectorizer' object has no attribute 'get_feature_names'. Did you mean: 'get_feature_names_out'?
> /opt/homebrew/lib/python3.10/site-packages/beancount_import/reconcile.py(139)get_prediction_explanation()
-> feature_names = classifier._vectorizer.get_feature_names()
lsnow99 commented 1 year ago

I am also seeing this bug

moritzj29 commented 1 year ago

fix is discussed over here: #180 related to some breaking changes in scikit-learn took me some time as well to connect this...

Zburatorul commented 1 year ago

Fixed in #180