Beispiel #1
0
 def test_Y_setter_2d_single_instance(self):
     iris = Table('iris')[:1]
     # Convert iris.Y to (1, 1) shape
     new_y = iris.Y[:, np.newaxis]
     iris.Y = np.hstack((new_y, new_y))
     iris.Y = csr_matrix(iris.Y)
     # We expect the Y shape to match the X shape, which is (1, 4) in iris
     self.assertEqual(iris.Y.shape, (1, 2))
Beispiel #2
0
 def test_Y_setter_2d_single_instance(self):
     iris = Table('iris')[:1]
     # Convert iris.Y to (1, 1) shape
     new_y = iris.Y[:, np.newaxis]
     iris.Y = np.hstack((new_y, new_y))
     iris.Y = csr_matrix(iris.Y)
     # We expect the Y shape to match the X shape, which is (1, 4) in iris
     self.assertEqual(iris.Y.shape, (1, 2))
 def test_Y_setter_2d(self):
     iris = Table("iris")
     assert iris.Y.shape == (150, )
     # Convert iris.Y to (150, 1) shape
     new_y = iris.Y[:, np.newaxis]
     iris.Y = np.hstack((new_y, new_y))
     iris.Y = csr_matrix(iris.Y)
     # We expect the Y shape to match the X shape, which is (150, 4) in iris
     self.assertEqual(iris.Y.shape, (150, 2))
Beispiel #4
0
 def test_Y_setter_1d(self):
     iris = Table('iris')
     assert iris.Y.shape == (150, )
     with iris.unlocked():
         iris.Y = csr_matrix(iris.Y)
     # We expect the Y shape to match the X shape, which is (150, 4) in iris
     self.assertEqual(iris.Y.shape, (150, ))
Beispiel #5
0
 def prepare_data():
     data = Table("iris")
     values = list(range(15))
     class_var = DiscreteVariable("iris5", values=[str(v) for v in values])
     data = data.transform(Domain(attributes=data.domain.attributes, class_vars=[class_var]))
     data.Y = np.array(values * 10, dtype=float)
     return data
Beispiel #6
0
    def __call__(self, data):
        """
        Apply randomization of the given data. Returns a new
        data table.

        Parameters
        ----------
        data : Orange.data.Table
            A data table to be randomized.

        Returns
        -------
        data : Orange.data.Table
            Randomized data table.
        """
        new_data = Table(data)
        new_data.ensure_copy()

        if self.rand_type & Randomize.RandomizeClasses:
            new_data.Y = self.randomize(new_data.Y)
        if self.rand_type & Randomize.RandomizeAttributes:
            new_data.X = self.randomize(new_data.X)
        if self.rand_type & Randomize.RandomizeMetas:
            new_data.metas = self.randomize(new_data.metas)
        return new_data
 def prepare_data():
     data = Table("iris")
     values = list(range(15))
     class_var = DiscreteVariable("iris5", values=[str(v) for v in values])
     data = data.transform(Domain(attributes=data.domain.attributes, class_vars=[class_var]))
     data.Y = np.array(values * 10, dtype=float)
     return data
 def test_sparse(self):
     """
     Test sparse data.
     GH-2152
     GH-2157
     """
     table = Table("iris")
     table.X = sp.csr_matrix(table.X)
     self.assertTrue(sp.issparse(table.X))
     table.Y = sp.csr_matrix(table._Y)  # pylint: disable=protected-access
     self.assertTrue(sp.issparse(table.Y))
     self.send_signal("Data", table)
     self.widget.set_subset_data(table[:30])
     data = self.get_output("Data")
     self.assertTrue(data.is_sparse())
     self.assertEqual(len(data.domain), 5)
Beispiel #9
0
    def test_sparse(self):
        """
        Test sparse data.
        GH-2152
        GH-2157
        """
        table = Table("iris")
        table.X = sp.csr_matrix(table.X)
        self.assertTrue(sp.issparse(table.X))
        table.Y = sp.csr_matrix(table._Y)  # pylint: disable=protected-access
        self.assertTrue(sp.issparse(table.Y))
        self.send_signal(self.widget.Inputs.data, table)
        self.widget.set_subset_data(table[:30])
        data = self.get_output("Data")

        self.assertTrue(data.is_sparse())
        self.assertEqual(len(data.domain), 5)
Beispiel #10
0
 def test_Y_setter_1d(self):
     iris = Table('iris')
     assert iris.Y.shape == (150,)
     iris.Y = csr_matrix(iris.Y)
     # We expect the Y shape to match the X shape, which is (150, 4) in iris
     self.assertEqual(iris.Y.shape, (150, 1))
 def test_Y_setter_1d(self):
     iris = Table("iris")
     assert iris.Y.shape == (150, )
     iris.Y = csr_matrix(iris.Y)
     # We expect the Y shape to match the X shape, which is (150, 4) in iris
     self.assertEqual(iris.Y.shape, (150, 1))