Calling predict with a sparse array raises an exception:
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Run this script:
#!/usr/bin/env python
from tpot import TPOTRegressor
import numpy as np
import scipy
lr = TPOTRegressor(config_dict='TPOT sparse', generations=1, population_size=1, random_state=1)
x = scipy.sparse.csr_matrix(np.ones((10, 10)))
y = np.zeros(10)
lr.fit(x, y)
lr.predict(x)
No exception
A type error is raised.
Reuse the _check_dataset code to check if data passed to predict is sparse before trying to impute data.
Thank you for reporting this issue. I will refine check_dataset step.
Most helpful comment
Thank you for reporting this issue. I will refine check_dataset step.