Problems with the input of a linear regression function in python (Input contains NaN, infinity or a value too large for dtype('float64').)

Viewed 62

I'm trying to analyze a dataset and I need to feed it to a linear regression function. When I try to do that this error comes out:

Input contains NaN, infinity or a value too large for dtype('float64').

I've searched for NaN values doing:

dataset.isnull().sum()

And also

dataset.isna().sum()

Since some values in a feature in the dataset were NaN, i've provided to delete those elements with:

dataset=dataset.dropna(axis=0, how='any', thresh=None, subset=['Flow Bytes/s'], inplace=False)

It worked, but didn't resolve the problem. I've tried so to convert every possible infinity value to NaN with:

dataset.replace([np.inf, -np.inf], np.nan)

and then again I removed the NaN elements.

Even so, trying to use the linear regression i still obtain the same error. Do you have any idea why?

0 Answers
Related