def test_z_score(self): domain = Domain([ContinuousVariable('A'), ContinuousVariable('B')]) table = Table.from_list(domain, [[1, 2], [3, 4]]) _table = ZScore(axis=0)(table) np.testing.assert_array_almost_equal([[-1, -1], [1, 1]], _table.X) _table = ZScore(axis=1)(table) np.testing.assert_array_almost_equal([[-1, 1], [-1, 1]], _table.X)
def test_quantile_normalization(self): domain = Domain( [ContinuousVariable('A'), ContinuousVariable('B'), ContinuousVariable('C'), ContinuousVariable('D')] ) table = Table.from_list(domain, [[5, 2, 3, 4], [4, 1, 4, 2], [3, 4, 6, 8]]) _table = QuantileNormalization()(table) # expected result result = np.array([[5.66666667, 2, 3, 4.66666667], [5.166667, 2, 5.166667, 3], [2, 3, 4.66666667, 5.66666667]]) np.testing.assert_array_almost_equal(result, _table.X)
def setUp(self) -> None: domain = Domain( [], metas=[ StringVariable('Subject'), ContinuousVariable('Time'), DiscreteVariable('Event', values=('no', 'yes')), DiscreteVariable('Group', values=('group1', 'group2')), ], ) test_data = Table.from_list( domain, [ ['B', 1, 1, 0], ['E', 2, 1, 0], ['F', 3, 1, 0], ['A', 4, 1, 0], ['D', 4.5, 1, 0], ['C', 5, 0, 0], ['U', 0.5, 1, 1], ['Z', 0.75, 1, 1], ['W', 1, 1, 1], ['V', 1.5, 0, 1], ['X', 2, 1, 1], ['Y', 3.5, 1, 1], ], ) self.widget = self.create_widget(OWKaplanMeier) self.send_signal(self.widget.Inputs.data, test_data) self.widget.time_var = self.widget.data.domain['Time'] self.widget.event_var = self.widget.data.domain['Event'] self.widget.on_controls_changed() # If we don't do this function ViewBox.mapSceneToView fails with num py.linalg.LinAlgError: Singular matrix vb = self.widget.graph.getViewBox() vb.resize(200, 200)
def test_log2_normalization(self): domain = Domain([ContinuousVariable('A'), ContinuousVariable('B')]) table = Table.from_list(domain, [[0, 1], [3, 7], [15, 31]]) _table = LogarithmicScale()(table) np.testing.assert_array_almost_equal([[0, 1], [2, 3], [4, 5]], _table.X)