This can be happened inside scikit and depends upon what you are doing. Read the documentation of the functions you are using. If you are using on which depends, like on your matrix is positive definite and not fulfilling the criteria.
If you are using the code like;
np.isnan(mat.any()) // get the result false
np.isfinite(mat.all()) // get the result True
Obviously this will generate an error message.
You can use the above lines as;
I think you want to check whether any of the elements is NAN, and nor the return value of any function is a number.
Sklearn with pandas:
If you are facing the same issue while using sklearn with pandas. The solution is to reset the index of data frame df before running any sklearn code;f
df = df.reset_index()
Remove some entries like;
df = df[df.label == ‘desired_one’]
Infinite and null values:
In most cases getting rid of infinite and null values can solve this problem.
Getting rid of infinite values:
You can do this by using the code like;
df.replace([np.inf, -np.inf], np.nan, inplace=True)
Getting rid of null values:
Get rid of null values as you like. Specifies values such as 999, or create your function to impute missing values
df.fillna(999, in place = True)