def test_relieff(self): old_monk = self.monk.copy() weights = ReliefF(random_state=42)(self.monk, None) found = [ self.monk.domain[attr].name for attr in reversed(weights.argsort()[-3:]) ] reference = ['a', 'b', 'e'] self.assertEqual(sorted(found), reference) # Original data is unchanged np.testing.assert_equal(old_monk.X, self.monk.X) np.testing.assert_equal(old_monk.Y, self.monk.Y) # Ensure it doesn't crash on adult dataset weights = ReliefF(random_state=42)(self.adult, None) found = [ self.adult.domain[attr].name for attr in weights.argsort()[-2:] ] # some leeway for randomness in relieff random instance selection self.assertIn('marital-status', found) # Ensure it doesn't crash on missing target class values old_monk.Y[0] = np.nan weights = ReliefF()(old_monk, None) np.testing.assert_array_equal( ReliefF(random_state=1)(self.monk, None), ReliefF(random_state=1)(self.monk, None))
def test_relieff(self): old_breast = self.breast.copy() weights = ReliefF(random_state=42)(self.breast, None) found = [ self.breast.domain[attr].name for attr in reversed(weights.argsort()[-3:]) ] reference = ['Bare_Nuclei', 'Clump thickness', 'Marginal_Adhesion'] self.assertEqual(sorted(found), reference) # Original data is unchanged np.testing.assert_equal(old_breast.X, self.breast.X) np.testing.assert_equal(old_breast.Y, self.breast.Y) # Ensure it doesn't crash on adult dataset weights = ReliefF(random_state=42)(self.lenses, None) found = [ self.lenses.domain[attr].name for attr in weights.argsort()[-2:] ] # some leeway for randomness in relieff random instance selection self.assertIn('tear_rate', found) # Ensure it doesn't crash on missing target class values old_breast.Y[0] = np.nan weights = ReliefF()(old_breast, None) np.testing.assert_array_equal( ReliefF(random_state=1)(self.breast, None), ReliefF(random_state=1)(self.breast, None))
def test_relieff(self): old_monk = self.monk.copy() weights = ReliefF()(self.monk, None) found = [self.monk.domain[attr].name for attr in reversed(weights.argsort()[-3:])] reference = ['a', 'b', 'e'] self.assertEqual(sorted(found), reference) # Original data is unchanged np.testing.assert_equal(old_monk.X, self.monk.X) np.testing.assert_equal(old_monk.Y, self.monk.Y) # Ensure it doesn't crash on adult dataset weights = ReliefF()(self.adult, None) found = [self.adult.domain[attr].name for attr in weights.argsort()[-2:]] # some leeway for randomness in relieff random instance selection self.assertIn('marital-status', found) # Ensure it doesn't crash on missing target class values old_monk.Y[0] = np.nan weights = ReliefF()(old_monk, None)
def test_relieff(self): old_monk = self.monk.copy() weights = ReliefF()(self.monk, None) found = [ self.monk.domain[attr].name for attr in reversed(weights.argsort()[-3:]) ] reference = ['a', 'b', 'e'] self.assertEqual(sorted(found), reference) # Original data is unchanged np.testing.assert_equal(old_monk.X, self.monk.X) np.testing.assert_equal(old_monk.Y, self.monk.Y) # Ensure it doesn't crash on adult dataset weights = ReliefF()(self.adult, None) found = sorted( [self.adult.domain[attr].name for attr in weights.argsort()[-2:]]) reference = ['marital-status', 'relationship'] self.assertEqual(found, reference) # Ensure it doesn't crash on missing target class values old_monk.Y[0] = np.nan weights = ReliefF()(old_monk, None)
def test_relieff(self): old_breast = self.breast.copy() weights = ReliefF(random_state=42)(self.breast, None) found = [self.breast.domain[attr].name for attr in reversed(weights.argsort()[-3:])] reference = ['Bare_Nuclei', 'Clump thickness', 'Marginal_Adhesion'] self.assertEqual(sorted(found), reference) # Original data is unchanged np.testing.assert_equal(old_breast.X, self.breast.X) np.testing.assert_equal(old_breast.Y, self.breast.Y) # Ensure it doesn't crash on adult dataset weights = ReliefF(random_state=42)(self.lenses, None) found = [self.lenses.domain[attr].name for attr in weights.argsort()[-2:]] # some leeway for randomness in relieff random instance selection self.assertIn('tear_rate', found) # Ensure it doesn't crash on missing target class values old_breast.Y[0] = np.nan weights = ReliefF()(old_breast, None) np.testing.assert_array_equal( ReliefF(random_state=1)(self.breast, None), ReliefF(random_state=1)(self.breast, None) )