Skip to content

Commit

Permalink
Catch AttributeError for newer versions of TPOT
Browse files Browse the repository at this point in the history
  • Loading branch information
PGijsbers committed Jun 17, 2023
1 parent e1b1cd7 commit be6d6bb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frameworks/TPOT/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def infer(data):
if is_classification:
try:
return tpot.predict_proba(data)
except RuntimeError:
except (RuntimeError, AttributeError):
return tpot.predict(data)
return tpot.predict(data)

Expand All @@ -94,8 +94,9 @@ def infer(data):

try:
probabilities = tpot.predict_proba(X_test) if is_classification else None
except RuntimeError:
# TPOT throws a RuntimeError if the optimized pipeline does not support `predict_proba`.
except (RuntimeError, AttributeError):
# TPOT throws a RuntimeError or AttributeError if the optimized pipeline
# does not support `predict_proba` (which one depends on the version).
probabilities = "predictions" # encoding is handled by caller in `__init__.py`

save_artifacts(tpot, config)
Expand Down

0 comments on commit be6d6bb

Please sign in to comment.