Beispiel #1
0
 def test_sparse_pps(self):
     with self.data.unlocked():
         self.data.X = csr_matrix(self.data.X)
     out = AdaptiveNormalize()(self.data)
     true_out = Scale(center=Scale.NoCentering, scale=Scale.Span)(self.data)
     np.testing.assert_array_equal(out, true_out)
     self.data = self.data.X.toarray()
Beispiel #2
0
    def test_reconstruct_domain(self):
        data = Table("heart_disease")
        cls = LogisticRegressionLearner()(data)
        domain = OWNomogram.reconstruct_domain(cls, cls.domain)
        transformed_data = cls.original_data.transform(domain)
        self.assertEqual(transformed_data.X.shape, data.X.shape)
        self.assertFalse(np.isnan(transformed_data.X[0]).any())

        scaled_data = Scale()(data)
        cls = LogisticRegressionLearner()(scaled_data)
        domain = OWNomogram.reconstruct_domain(cls, cls.domain)
        transformed_data = cls.original_data.transform(domain)
        self.assertEqual(transformed_data.X.shape, scaled_data.X.shape)
        self.assertFalse(np.isnan(transformed_data.X[0]).any())

        disc_data = Continuize()(data)
        cls = LogisticRegressionLearner()(disc_data)
        domain = OWNomogram.reconstruct_domain(cls, cls.domain)
        transformed_data = cls.original_data.transform(domain)
        self.assertEqual(transformed_data.X.shape, disc_data.X.shape)
        self.assertFalse(np.isnan(transformed_data.X[0]).any())
Beispiel #3
0
 def test_scaling_pickling(self):
     c = Scale(center=Scale.Median, scale=Scale.Span)
     s = pickle.dumps(c, -1)
     c1 = pickle.loads(s)
     self.assertIs(c1.center, c.center)
     self.assertIs(c1.scale, c.scale)
Beispiel #4
0
 def test_scaling_median_stddev(self):
     table = Scale(center=Scale.Median, scale=Scale.Std)(self.table)
     np.testing.assert_almost_equal(np.std(table, 0), 1)
Beispiel #5
0
 def test_scaling_mean_span(self):
     table = Scale(center=Scale.Mean, scale=Scale.Span)(self.table)
     np.testing.assert_almost_equal(np.mean(table, 0), 0)
     np.testing.assert_almost_equal(np.ptp(table, 0), 1)