Closed
Description
Description
pca._fit()
casts input arrays to float types.
ComplexWarning: Casting complex values to real discards the imaginary part
array = np.array(array, dtype=dtype, order=order, copy=copy)
This forbids PCAs on complex input data, although possible with scipy.linalg.svd
Steps/Code to Reproduce
import numpy as np
from sklearn.decomposition import PCA
X = np.array([[-1+1j, -1], [-2j, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
pca = PCA(svd_solver='full')
Y = pca.fit_transform(X)
B = pca.components_
print(pca.singular_values_)
print(B)
X_reconstructed = pca.inverse_transform(Y)
print(np.allclose(X, X_reconstructed))
Expected Results
True
Actual Results
False
Versions
Linux-4.10.0-42-generic-x86_64-with-debian-stretch-sid
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0]
NumPy 1.13.3
SciPy 0.19.1
Scikit-Learn 0.19.1
Metadata
Metadata
Assignees
Labels
No labels