def test_PCA_scorer_component(self): pca = PCA() for i in range(1, len(self.zoo.domain.attributes) + 1): pca.component = i scores = pca.score_data(self.zoo) self.assertEqual(scores.shape, (pca.component, len(self.zoo.domain.attributes)))
def test_PCA_scorer_component(self): pca = PCA() for i in range(1, len(self.zoo.domain.attributes) + 1): pca.component = i scores = pca.score_data(self.zoo) self.assertEqual(scores.shape, (pca.component, len(self.zoo.domain.attributes)))
def test_PCA_scorer(self): data = self.iris pca = PCA(preprocessors=[Normalize()]) pca.component = 1 scores = pca.score_data(data) self.assertEqual(scores.shape[1], len(data.domain.attributes)) self.assertEqual(['petal length', 'petal width'], sorted([data.domain.attributes[i].name for i in np.argsort(scores[0])[-2:]])) self.assertEqual([round(s, 4) for s in scores[0]], [0.5224, 0.2634, 0.5813, 0.5656])
def test_PCA_scorer(self): data = self.iris pca = PCA(preprocessors=[Normalize()]) pca.component = 1 scores = pca.score_data(data) self.assertEqual(scores.shape[1], len(data.domain.attributes)) self.assertEqual(['petal length', 'petal width'], sorted([data.domain.attributes[i].name for i in np.argsort(scores[0])[-2:]])) self.assertEqual([round(s, 4) for s in scores[0]], [0.5224, 0.2634, 0.5813, 0.5656])
def test_PCA_scorer_all_components(self): n_attr = len(self.iris.domain.attributes) pca = PCA() scores = pca.score_data(self.iris) self.assertEqual(scores.shape, (n_attr, n_attr))
def test_PCA_scorer_all_components(self): n_attr = len(self.iris.domain.attributes) pca = PCA() scores = pca.score_data(self.iris) self.assertEqual(scores.shape, (n_attr, n_attr))