Trying to do linear regression in python on array's and I keep getting the error 'array must not contain infs or NaNs'. There are no infs or NaNs

Viewed 80

I'm relatively new to python so please bear with me. I created two datasets, x1 and x2 with values between 0 and 1 and a decision tree to give me the dataset Y. I then converted to arrays and rounded for simplicity's sake.

x1array = np.array(x1).reshape((-1,1))
np.around(x1array, 3)

Now I am trying to run a linear regression but I keep getting the error 'array must not contain any infs or NaNs'. I checked for both using

np.isnan(x1).any()
np.isinf(x1).any()

for x1, x2, and Y. All came back false. Not sure how to proceed and if this is a bug in the library or something wrong with my code. (I am using Spyder as my IDE in case that is relevant)

1 Answers

Try checking your variable 'x1array', instead of 'x1', since that seems to be the one you will continue to work with.

Related