Skip to content

Commit e0f22a9

Browse files
martin-hahnTomDLT
authored andcommitted
[MRG+1] Calculate confidence intervall only if we have enough samples (scikit-learn#8621)
* calculate confidence intervall only if we have enough samples * pep8 * removed parentheses
1 parent ec4def8 commit e0f22a9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

sklearn/isotonic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def check_increasing(x, y):
5757
increasing_bool = rho >= 0
5858

5959
# Run Fisher transform to get the rho CI, but handle rho=+/-1
60-
if rho not in [-1.0, 1.0]:
60+
if rho not in [-1.0, 1.0] and len(x) > 3:
6161
F = 0.5 * math.log((1. + rho) / (1. - rho))
6262
F_se = 1 / math.sqrt(len(x) - 3)
6363

sklearn/tests/test_isotonic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ def test_permutation_invariance():
2727
assert_array_equal(y_transformed, y_transformed_s)
2828

2929

30+
def test_check_increasing_small_number_of_samples():
31+
x = [0, 1, 2]
32+
y = [1, 1.1, 1.05]
33+
34+
is_increasing = assert_no_warnings(check_increasing, x, y)
35+
assert_true(is_increasing)
36+
37+
3038
def test_check_increasing_up():
3139
x = [0, 1, 2, 3, 4, 5]
3240
y = [0, 1.5, 2.77, 8.99, 8.99, 50]

0 commit comments

Comments
 (0)