def test_gini_impurity_min(self): """Test minimum gini impurity. Asserts: entropy is 0. """ gini_impurity = dt.gini_impurity([1, 1, 1, 1, 1, 1]) assert 0 == round(gini_impurity, 3)
def test_gini_impurity(self): """Test gini impurity. Asserts: gini impurity is matched as expected. """ gini_impurity = dt.gini_impurity([1, 1, 0, 0, 0, 0]) assert round(4. / 9., 3) == round(gini_impurity, 3)
def test_gini_impurity_max(self): """Test maximum gini impurity. Asserts: gini impurity is 0.5. """ gini_impurity = dt.gini_impurity([1, 1, 1, 0, 0, 0]) assert .500 == round(gini_impurity, 3)