Ignore:
Timestamp:
03/26/12 16:37:25 (2 years ago)
Author:
anze <anze.staric@…>
Branch:
default
Message:

PCA now returns the same results as prcomp(X, scale=TRUE) in R.
(Fixed normalization in linalg numpy operations and output of st. dev)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/testing/unit/tests/test_projection_linear.py

    r10644 r10645  
    6060        self.assertIsInstance(pca, linear.PcaProjector) 
    6161 
    62         absolute_error = (np.abs(pca.eigen_vectors[0]) - np.abs(self.principal_component)).sum() 
     62        absolute_error = (np.abs(pca.projection[0]) - np.abs(self.principal_component)).sum() 
    6363        self.assertAlmostEqual(absolute_error, 0.) 
    6464 
     
    6969        self.assertIsInstance(pca, linear.PcaProjector) 
    7070 
    71         absolute_error = (np.abs(pca.eigen_vectors[0]) - np.abs(self.principal_component)).sum() 
     71        absolute_error = (np.abs(pca.projection[0]) - np.abs(self.principal_component)).sum() 
    7272        self.assertAlmostEqual(absolute_error, 0., 1) 
    7373 
     
    7676 
    7777        pca = linear.Pca(standardize=True)(self.dataset) 
    78         eigen_vector = pca.eigen_vectors[0] 
     78        eigen_vector = pca.projection[0] 
    7979        non_zero_elements = eigen_vector[eigen_vector.nonzero()] 
    8080 
     
    8787        pca = linear.Pca(variance_covered=.99)(self.dataset) 
    8888        # all data points lie in one dimension, one component should cover all the variance 
    89         nvectors, vector_dimension = pca.eigen_vectors.shape 
     89        nvectors, vector_dimension = pca.projection.shape 
    9090        self.assertEqual(nvectors, 1) 
    9191 
     
    9696        pca = linear.Pca(max_components=max_components)(self.dataset) 
    9797        # all data points lie in one dimension, one component should cover all the variance 
    98         nvectors, vector_dimension = pca.eigen_vectors.shape 
     98        nvectors, vector_dimension = pca.projection.shape 
    9999        self.assertEqual(nvectors, max_components) 
    100100 
    101101    def test_pca_handles_unknowns(self): 
    102102        self.create_dataset_with_unknowns() 
    103         print self.dataset[0] 
    104103 
    105104        pca = linear.Pca()(self.dataset) 
Note: See TracChangeset for help on using the changeset viewer.