import numpy as np

import nose.tools as nt

from sklearn.isotonic import isotonic_regression


def test_isotonic_ymin_ymax():

    X = np.array([1.26, 1.31,-0.57, 0.30, -0.70,

                  -0.17, -1.59, 1.05, 1.39, 1.90,

                  0.20, 0.03, -0.08, 0.44, 0.01,

                  -0.37, -0.89, -0.37, -1.32, 0.18])


    X_iso = isotonic_regression(X, y_min=0., y_max=0.1)

    nt.assert_true(np.all((X_iso <= 0.1) * (X_iso >= 0.)))


test_isotonic_ymin_ymax()


On Wed, Jun 22, 2016 at 12:27 AM, <scikit-learn-request@python.org> wrote:
Send scikit-learn mailing list submissions to
        scikit-learn@python.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.python.org/mailman/listinfo/scikit-learn
or, via email, send a message with subject or body 'help' to
        scikit-learn-request@python.org

You can reach the person managing the list at
        scikit-learn-owner@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of scikit-learn digest..."


Today's Topics:

   1. isotonic regression weird behavior? (Jonathan Taylor)
   2. Re: isotonic regression weird behavior? (Jonathan Taylor)
   3. Re: isotonic regression weird behavior? (Jonathan Taylor)
   4. Re: isotonic regression weird behavior? (Gael Varoquaux)


----------------------------------------------------------------------

Message: 1
Date: Tue, 21 Jun 2016 19:18:12 -0700
From: Jonathan Taylor <jonathan.taylor@stanford.edu>
To: scikit-learn@python.org
Subject: [scikit-learn] isotonic regression weird behavior?
Message-ID:
        <CANmCCuSkekfbjH0d450_Cm5V3JYVXsSgEyGtj3pNmA6Ek8CssQ@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Was trying to fit isotonic regression with non-trivial y_min and y_max:

In [*17*]: X

Out[*17*]:

array([ 1.26336413,  1.31853693, -0.57200917,  0.3072928 , -0.70686507,

       -0.17614937, -1.59943059,  1.05908504,  1.3958263 ,  1.90580318,

        0.20992272,  0.02836316, -0.08092235,  0.44438247,  0.01791253,

       -0.3771914 , -0.89577538, -0.37726249, -1.32687569,  0.18013201])


In [*18*]: iso.isotonic_regression(X, y_min=0, y_max=0.1)

Out[*18*]:

array([-0.00826919, -0.00826919, -0.00826919, -0.00826919, -0.00826919,

       -0.00826919, -0.00826919,  0.10449344,  0.10449344,  0.10449344,

        0.10449344,  0.10449344,  0.10449344,  0.10449344,  0.10449344,

        0.10449344,  0.10449344,  0.10449344,  0.10449344,  0.10449344])


The solution does not satisfy the bounds that each entry should be in
[0,0.1]



--
Jonathan Taylor
Dept. of Statistics
Sequoia Hall, 137
390 Serra Mall
Stanford, CA 94305
Tel:   650.723.9230
Fax:   650.725.8977
Web: http://www-stat.stanford.edu/~jtaylo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20160621/178cef23/attachment-0001.html>

------------------------------

Message: 2
Date: Tue, 21 Jun 2016 19:19:42 -0700
From: Jonathan Taylor <jonathan.taylor@stanford.edu>
To: scikit-learn@python.org
Subject: Re: [scikit-learn] isotonic regression weird behavior?
Message-ID:
        <CANmCCuSJH45Z=ZUj+gVzsBAS0CG5iaUXTinfVVnEy4+DLA=42g@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Should have included:

In [*22*]: iso

Out[*22*]: <module 'sklearn.isotonic' from
'/Users/jonathantaylor/anaconda/envs/py27/lib/python2.7/site-packages/sklearn/isotonic.pyc'>

On Tue, Jun 21, 2016 at 7:18 PM, Jonathan Taylor <
jonathan.taylor@stanford.edu> wrote:

> Was trying to fit isotonic regression with non-trivial y_min and y_max:
>
> In [*17*]: X
>
> Out[*17*]:
>
> array([ 1.26336413,  1.31853693, -0.57200917,  0.3072928 , -0.70686507,
>
>        -0.17614937, -1.59943059,  1.05908504,  1.3958263 ,  1.90580318,
>
>         0.20992272,  0.02836316, -0.08092235,  0.44438247,  0.01791253,
>
>        -0.3771914 , -0.89577538, -0.37726249, -1.32687569,  0.18013201])
>
>
> In [*18*]: iso.isotonic_regression(X, y_min=0, y_max=0.1)
>
> Out[*18*]:
>
> array([-0.00826919, -0.00826919, -0.00826919, -0.00826919, -0.00826919,
>
>        -0.00826919, -0.00826919,  0.10449344,  0.10449344,  0.10449344,
>
>         0.10449344,  0.10449344,  0.10449344,  0.10449344,  0.10449344,
>
>         0.10449344,  0.10449344,  0.10449344,  0.10449344,  0.10449344])
>
>
> The solution does not satisfy the bounds that each entry should be in
> [0,0.1]
>
>
>
> --
> Jonathan Taylor
> Dept. of Statistics
> Sequoia Hall, 137
> 390 Serra Mall
> Stanford, CA 94305
> Tel:   650.723.9230
> Fax:   650.725.8977
> Web: http://www-stat.stanford.edu/~jtaylo
>



--
Jonathan Taylor
Dept. of Statistics
Sequoia Hall, 137
390 Serra Mall
Stanford, CA 94305
Tel:   650.723.9230
Fax:   650.725.8977
Web: http://www-stat.stanford.edu/~jtaylo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20160621/2e999af0/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 21 Jun 2016 19:21:59 -0700
From: Jonathan Taylor <jonathan.taylor@stanford.edu>
To: scikit-learn@python.org
Subject: Re: [scikit-learn] isotonic regression weird behavior?
Message-ID:
        <CANmCCuQY33TX884_7owwyz1nAC8tpgQhJoZCYTUxSsSpXbSRHA@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Sorry, docstring is also a bit funny.

Is the problem it is trying to solve have an __equality__ constraint for
y_min, y_max or __inequality__ constraint for y_min / y_max?

Either way the produced solution does not satisfy such a constraint...

On Tue, Jun 21, 2016 at 7:19 PM, Jonathan Taylor <
jonathan.taylor@stanford.edu> wrote:

> Should have included:
>
> In [*22*]: iso
>
> Out[*22*]: <module 'sklearn.isotonic' from
> '/Users/jonathantaylor/anaconda/envs/py27/lib/python2.7/site-packages/sklearn/isotonic.pyc'>
>
> On Tue, Jun 21, 2016 at 7:18 PM, Jonathan Taylor <
> jonathan.taylor@stanford.edu> wrote:
>
>> Was trying to fit isotonic regression with non-trivial y_min and y_max:
>>
>> In [*17*]: X
>>
>> Out[*17*]:
>>
>> array([ 1.26336413,  1.31853693, -0.57200917,  0.3072928 , -0.70686507,
>>
>>        -0.17614937, -1.59943059,  1.05908504,  1.3958263 ,  1.90580318,
>>
>>         0.20992272,  0.02836316, -0.08092235,  0.44438247,  0.01791253,
>>
>>        -0.3771914 , -0.89577538, -0.37726249, -1.32687569,  0.18013201])
>>
>>
>> In [*18*]: iso.isotonic_regression(X, y_min=0, y_max=0.1)
>>
>> Out[*18*]:
>>
>> array([-0.00826919, -0.00826919, -0.00826919, -0.00826919, -0.00826919,
>>
>>        -0.00826919, -0.00826919,  0.10449344,  0.10449344,  0.10449344,
>>
>>         0.10449344,  0.10449344,  0.10449344,  0.10449344,  0.10449344,
>>
>>         0.10449344,  0.10449344,  0.10449344,  0.10449344,  0.10449344])
>>
>>
>> The solution does not satisfy the bounds that each entry should be in
>> [0,0.1]
>>
>>
>>
>> --
>> Jonathan Taylor
>> Dept. of Statistics
>> Sequoia Hall, 137
>> 390 Serra Mall
>> Stanford, CA 94305
>> Tel:   650.723.9230
>> Fax:   650.725.8977
>> Web: http://www-stat.stanford.edu/~jtaylo
>>
>
>
>
> --
> Jonathan Taylor
> Dept. of Statistics
> Sequoia Hall, 137
> 390 Serra Mall
> Stanford, CA 94305
> Tel:   650.723.9230
> Fax:   650.725.8977
> Web: http://www-stat.stanford.edu/~jtaylo
>



--
Jonathan Taylor
Dept. of Statistics
Sequoia Hall, 137
390 Serra Mall
Stanford, CA 94305
Tel:   650.723.9230
Fax:   650.725.8977
Web: http://www-stat.stanford.edu/~jtaylo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20160621/f7c40e1c/attachment-0001.html>

------------------------------

Message: 4
Date: Wed, 22 Jun 2016 09:27:06 +0200
From: Gael Varoquaux <gael.varoquaux@normalesup.org>
To: Scikit-learn user and developer mailing list
        <scikit-learn@python.org>
Subject: Re: [scikit-learn] isotonic regression weird behavior?
Message-ID: <20160622072706.GF1018883@phare.normalesup.org>
Content-Type: text/plain; charset=us-ascii

Looks like a bug indeed. Could you please put a small code snippet to
enable us to reproduce.



------------------------------

Subject: Digest Footer

_______________________________________________
scikit-learn mailing list
scikit-learn@python.org
https://mail.python.org/mailman/listinfo/scikit-learn


------------------------------

End of scikit-learn Digest, Vol 3, Issue 37
*******************************************



--
Jonathan Taylor                         
Dept. of Statistics                     
Sequoia Hall, 137                         
390 Serra Mall
Stanford, CA 94305
Tel:   650.723.9230
Fax:   650.725.8977
Web: http://www-stat.stanford.edu/~jtaylo