[scikit-learn] inconsistency across version

Huan Tran huantd at gmail.com
Sat Feb 16 16:42:26 EST 2019


Thank you, Nicolas.
Huan

On Fri, Feb 15, 2019 at 7:52 PM Huan Tran <huantd at gmail.com> wrote:

> Dear community,
>
> I did a very small pca analysis on a 3D data to print out the
> explained_variance. I found that with scikit-learn 0.18.1 AND 0.20.2, the
> results are significantly different. In particular, for 0.18.1 I got
> +3.875925353581E+00 +3.270175297443E+00 +2.207814537475E+00
>
> and with 0.20.2, I got
> +4.651110424297E+00 +3.924210356932E+00 +2.649377444970E+00
>
> Could anyone has a hint on what is going on? FYI, my data and code are
> enclosed. Many thanks.
>
> Huan
>
> My data is
>
>  -3.117642E+00,  1.453819E+00, -7.952874E-02
>   3.081224E+00,  1.453819E+00, -7.952874E-02
>   1.376932E-01, -2.491454E+00, -1.908521E-01
>   9.578602E-02,  3.632759E+00, -1.908521E-01
>  -1.238644E-01,  5.396424E-02, -3.147031E+00
>   6.335262E-01,  1.393937E+00,  2.500474E+00
>
> and my code is
>
> import pandas as pd
> import numpy as np
> from sklearn import decomposition
>
> df = pd.read_csv('data', delimiter=',', header=None)
> data = np.array(df)
>
> X = data[:,:]
> data_size   = X.shape[0]
> feature_dim = X.shape[1]
>
> print X
>
> pca = decomposition.PCA(n_components=feature_dim)
> X_transformed = pca.fit_transform(X)
> print "%+4.12E %+4.12E %+4.12E" %(pca.explained_variance_[0],
> pca.explained_variance_[1], pca.explained_variance_[2])
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20190216/c4c6550e/attachment.html>


More information about the scikit-learn mailing list