def test_lda_covw_whitened(self): '''cov_w should be whitened in the transformed space.''' classes = spy.create_training_classes(self.data, self.classes) fld = spy.linear_discriminant(classes) xdata = fld.transform(self.data) classes.transform(fld.transform) fld2 = spy.linear_discriminant(classes) assert_allclose(np.eye(fld2.cov_w.shape[0]), fld2.cov_w, atol=1e-8)
def test_lda_covw_whitened(self): '''cov_w should be whitened in the transformed space.''' import spectral as spy classes = spy.create_training_classes(self.data, self.classes) fld = spy.linear_discriminant(classes) xdata = fld.transform(self.data) classes.transform(fld.transform) fld2 = spy.linear_discriminant(classes) assert_allclose(np.eye(fld2.cov_w.shape[0]), fld2.cov_w, atol=1e-8)
def test_perceptron_learns_image_classes(self): '''Test that perceptron can learn image class means.''' fld = spy.linear_discriminant(self.ts) xdata = fld.transform(self.data) classes = spy.create_training_classes(xdata, self.gt) nfeatures = xdata.shape[-1] nclasses = len(classes) for i in range(10): p = spy.PerceptronClassifier([nfeatures, 20, 8, nclasses]) success = p.train(classes, 1, 5000, batch=1, momentum=0.3, rate=0.3) if success is True: return assert(False)
def test_perceptron_learns_image_classes(self): '''Test that perceptron can learn image class means.''' fld = spy.linear_discriminant(self.ts) xdata = fld.transform(self.data) classes = spy.create_training_classes(xdata, self.gt) nfeatures = xdata.shape[-1] nclasses = len(classes) for i in range(10): p = spy.PerceptronClassifier([nfeatures, 20, 8, nclasses]) success = p.train(classes, 1, 5000, batch=1, momentum=0.3, rate=0.3) if success is True: return assert (False)