Skip to content

Commit

Permalink
FIX missing order in old path
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr committed May 10, 2024
1 parent 4ca6e8b commit 43cadcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions sklearn/isotonic.py
Expand Up @@ -166,6 +166,7 @@ def isotonic_regression(
sample_weight = _check_sample_weight(sample_weight, y, dtype=y.dtype, copy=True)
sample_weight = np.ascontiguousarray(sample_weight[order])
_inplace_contiguous_isotonic_regression(y, sample_weight)
y = y[order]

if y_min is not None or y_max is not None:
# Older versions of np.clip don't accept None as a bound, so use np.inf
Expand Down
6 changes: 6 additions & 0 deletions sklearn/tests/test_isotonic.py
Expand Up @@ -227,7 +227,13 @@ def test_isotonic_regression_with_ties_in_differently_sized_groups():

def test_isotonic_regression_reversed():
y = np.array([10, 9, 10, 7, 6, 6.1, 5])
y_result = np.array([10, 9.5, 9.5, 7, 6.05, 6.05, 5])

y_iso = isotonic_regression(y, increasing=False)
assert_allclose(y_iso, y_result)

y_ = IsotonicRegression(increasing=False).fit_transform(np.arange(len(y)), y)
assert_allclose(y_, y_result)
assert_array_equal(np.ones(y_[:-1].shape), ((y_[:-1] - y_[1:]) >= 0))


Expand Down

0 comments on commit 43cadcb

Please sign in to comment.