0
$\begingroup$

I use PCA from from sklearn.decomposition to reduce data dimension.

    pca = PCA(n_components=pca_components, whiten=True, svd_solver='full')
    y = pca.fit_transform(x)

The numpy array shape is (512, 48), dtype is float64. The minimum value in the array is 0.0, the maximum value is 1.7976931348623157e+308. The array does not contain infs or NaNs but I get an error

ValueError: array must not contain infs or NaNs

I have looke for reasons of this error and found nothing useful for me. I suppose that maybe the maxim value in the array is too large for PCA. But I still do not know how deal with it. Could you advice me something. Thanks alot in advance.

$\endgroup$
1
$\begingroup$

My guess is the issue is a combination of whiten=True and the largest value equal to the largest possible value of a float64.

From scikit-learn's PCA docs:

When True (False by default) the components_ vectors are multiplied by the square root of n_samples…

That creates an overflow issue which results in the ValueError exception.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.