[scikit-learn] inconsistency across version

Huan Tran huantd at gmail.com
Fri Feb 15 19:52:36 EST 2019


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/20190215/2cd56eb9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data
Type: application/octet-stream
Size: 272 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20190215/2cd56eb9/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pca.py
Type: text/x-python
Size: 429 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20190215/2cd56eb9/attachment.py>


More information about the scikit-learn mailing list