whokaryote
whokaryote copied to clipboard
Handling empty feature table
Hi,
Thank you for your work on whokaryote.
I have encountered a bug when whokaryote is run on very small MAGs without any valid features identified. A bit of an edge case I know.
The error arrises from predict_class.py
: line 90
The features
DataFrame is empty, which causes a ValueError to be returned by predictions = loaded_rf.predict(features)
.
ValueError: Found array with 0 sample(s) (shape=(0, 9)) while a minimum of 1 is required.
A work around for this problem is to replace line 90 with the following.
predictions = []
if not features.empty:
predictions = loaded_rf.predict(features)
I believe that it should preserve the normal behavior of whokaryote.
Thanks, Tim.