Tpot: predict method fails for sparse inputs

Created on 22 Jul 2018  路  1Comment  路  Source: EpistasisLab/tpot

Context of the issue

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''

Process to reproduce the issue

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)

Expected result

No exception

Current result

A type error is raised.

Possible fix

Reuse the _check_dataset code to check if data passed to predict is sparse before trying to impute data.

enhancement

Most helpful comment

Thank you for reporting this issue. I will refine check_dataset step.

>All comments

Thank you for reporting this issue. I will refine check_dataset step.

Was this page helpful?
0 / 5 - 0 ratings