def compute_score(self, state): attrs = [self.attrs[i] for i in state] domain = Domain(attributes=attrs, class_vars=[self.attr_color]) data = self.data.transform(domain) projector = RadViz() projection = projector(data) radviz_xy = projection(data) y = projector.preprocess(data).Y return -self._evaluate_projection(radviz_xy, y)
def test_discrete_features(self): table = self.titanic[::10] projector = RadViz() self.assertRaises(ValueError, projector, table) table = table.transform(Domain(table.domain.attributes[1:])) projector = RadViz() projection = projector(table) embedding = projection(table[::10]) self.assertEqual(np.sum(embedding), -17)
def clear(self): if self.model_selected: self.model_selected.clear() if self.model_other: self.model_other.clear() super().clear() self.projector = RadViz()
def test_radviz(self): table = self.iris table = table.transform(Domain(table.domain.attributes[2:])) projector = RadViz() projection = projector(table) embedding = projection(table) self.assertEqual(len(embedding), len(table)) self.assertTrue(np.isnan(embedding.X).any()) np.testing.assert_array_equal(embedding[:100], projection(table[:100]))
def clear(self): super().clear() self.projector = RadViz()