Typehint for Sklearn. (#6799)
This commit is contained in:
@@ -22,14 +22,14 @@ def is_correctly_constrained(learner, feature_names=None):
|
||||
for i in range(n):
|
||||
fixed_x = fixed_xs_values[i] * np.ones((n, 1))
|
||||
monotonically_increasing_x = np.column_stack((variable_x, fixed_x))
|
||||
monotonically_increasing_dset = xgb.DMatrix(monotonically_increasing_x,
|
||||
monotonically_increasing_dset = xgb.DMatrix(monotonically_increasing_x,
|
||||
feature_names=feature_names)
|
||||
monotonically_increasing_y = learner.predict(
|
||||
monotonically_increasing_dset
|
||||
)
|
||||
|
||||
monotonically_decreasing_x = np.column_stack((fixed_x, variable_x))
|
||||
monotonically_decreasing_dset = xgb.DMatrix(monotonically_decreasing_x,
|
||||
monotonically_decreasing_dset = xgb.DMatrix(monotonically_decreasing_x,
|
||||
feature_names=feature_names)
|
||||
monotonically_decreasing_y = learner.predict(
|
||||
monotonically_decreasing_dset
|
||||
@@ -105,7 +105,7 @@ class TestMonotoneConstraints:
|
||||
|
||||
@pytest.mark.parametrize('format', [dict, list])
|
||||
def test_monotone_constraints_feature_names(self, format):
|
||||
|
||||
|
||||
# next check monotonicity when initializing monotone_constraints by feature names
|
||||
params = {
|
||||
'tree_method': 'hist', 'verbosity': 1,
|
||||
@@ -119,13 +119,13 @@ class TestMonotoneConstraints:
|
||||
with pytest.raises(ValueError):
|
||||
xgb.train(params, training_dset)
|
||||
|
||||
feature_names =[ 'feature_0', 'feature_2']
|
||||
feature_names = ['feature_0', 'feature_2']
|
||||
training_dset_w_feature_names = xgb.DMatrix(x, label=y, feature_names=feature_names)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
xgb.train(params, training_dset_w_feature_names)
|
||||
|
||||
feature_names =[ 'feature_0', 'feature_1']
|
||||
|
||||
feature_names = ['feature_0', 'feature_1']
|
||||
training_dset_w_feature_names = xgb.DMatrix(x, label=y, feature_names=feature_names)
|
||||
|
||||
constrained_learner = xgb.train(
|
||||
|
||||
Reference in New Issue
Block a user