- This topic has 1 reply, 2 voices, and was last updated 2 years, 9 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forums › Fórum Machine Learning e Data Science com Python de A à Z › função toarray() não é reconhecida
TypeError Traceback (most recent call last)
<ipython-input-223-18a2c3afda0e> in <module>
—-> 1 x_census = onehotencoder_census.fit_transform(x_census).toarray()
17 frames
/usr/local/lib/python3.8/dist-packages/sklearn/utils/validation.py in _ensure_sparse_format(spmatrix, accept_sparse, dtype, copy, force_all_finite, accept_large_sparse)
438
439 if accept_sparse is False:
–> 440 raise TypeError(
441 “A sparse matrix was passed, but dense ”
442 “data is required. Use X.toarray() to ”
TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array.
Olá Rafael, verifique se alguma linha ficou sem execução. Consegue fazer um novo teste?
Fabio