easiest would be to associate each one of your complex features to an R^2
real feature. You can do this with np.hstack([np.real(X), np.imag(X)]).
This has more degrees of freedom in a sense, since you are not constrained
by complex multiplication anymore. If however this is essential to you I'd
suggest to do the PCA by hand as centering -> covariance -> eigh or
something to that effect.

hope that helps,
Michael

On Wednesday, March 30, 2016, David Brough <david.brough.0...@gmail.com>
wrote:

> Hello all,
>
> I have a complex valued array that I would like to do PCA on, but I am
> running into an issue where
> sklearn is casting the complex128 array as a float64.
>
>
>     X = np.random.random((30, 50)) + 1j * np.random.random((30, 50))
>     pca = RandomizedPCA()
>     pca.fit(X)
>
>     ComplexWarning: Casting complex values to real discards the imaginary
> part
>
> It looks like it is coming form the following lines of code.
>
>
> https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/decomposition/pca.py#L639
>
> https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/validation.py#L101
>
> Is there a way to do PCA on complex valued array with sklearn?
>
> Thanks,
>
> David
>
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to