def test_gini_gain(self): """Test gini gain. Asserts: gini gain is within acceptable bounds """ gini_gain = dt.gini_gain([1, 1, 1, 0, 0, 0], [[1, 1, 0], [1, 0, 0]]) assert 0.056 == round(gini_gain, 3)
def test_gini_gain_max(self): """Test maximum gini gain. Asserts: gini gain is 0.5. """ gini_gain = dt.gini_gain([1, 1, 1, 0, 0, 0], [[1, 1, 1], [0, 0, 0]]) assert .500 == round(gini_gain, 3)
def test_gini_gain_restaurant_patrons(self): """Test gini gain using restaurant patrons. Asserts: gini gain rounded to 3 decimal places matches as expected. """ gain_patrons = dt.gini_gain(self.restaurant['restaurants'], self.restaurant['split_patrons']) assert round(gain_patrons, 3) == 0.278
def test_gini_gain_restaurant_type(self): """Test gini gain using restaurant food type. Asserts: gini gain is 0. """ gain_type = round( dt.gini_gain(self.restaurant['restaurants'], self.restaurant['split_food_type']), 2) assert gain_type == 0.00