def test_quantile_boundaries_detection(self): """...Test boundaries detection for method `quantile` """ n_cuts = 3 binarizer = FeaturesBinarizer(method='quantile', n_cuts=n_cuts, detect_column_type="column_names", remove_first=False) # only for the two continuous features boundaries_0 = binarizer._get_boundaries(self.columns[0], self.features[:, 0], fit=True) np.testing.assert_array_almost_equal( boundaries_0, np.array([-np.inf, 0.009021, 0.271109, 0.473155, np.inf])) boundaries_1 = binarizer._get_boundaries(self.columns[1], self.features[:, 1], fit=True) np.testing.assert_array_almost_equal( boundaries_1, np.array([-np.inf, -0.718759, -0.191478, 0.445833, np.inf]))
def test_linspace_boundaries_detection(self): """...Test boundaries detection for method `linspace` """ n_cuts = 3 binarizer = FeaturesBinarizer(method='linspace', n_cuts=n_cuts, detect_column_type="column_names", remove_first=False) # only for the two continuous features boundaries_0 = binarizer._get_boundaries(self.columns[0], self.features[:, 0], fit=True) np.testing.assert_array_almost_equal( boundaries_0, np.array([-np.inf, -0.230951, 0.527193, 1.285336, np.inf])) boundaries_1 = binarizer._get_boundaries(self.columns[1], self.features[:, 1], fit=True) np.testing.assert_array_almost_equal( boundaries_1, np.array([-np.inf, -0.495156, 0.124166, 0.743488, np.inf]))