msmbuilder / osprey

🦅Hyperparameter optimization for machine learning pipelines 🦅
http://msmbuilder.org/osprey
Apache License 2.0
74 stars 26 forks source link

Mapping integer variables from [0,1] in Gaussian Processes strategy #233

Closed RobertArbon closed 7 years ago

RobertArbon commented 7 years ago

This code doesn't seem correct for the IntVariable in search_space.py:

    def point_from_gp(self, gpvalue):
        if self.warp is None:
            return int( self.min + ( gpvalue * (self.max - self.min) ) )

Shouldn't it return

 int(np.floor( min( self.min + gpvalue * (self.max - self.min + 1), self.max ) ))

?

Reason:

Let's say we have an integer variable that can take on values 1, 2, 3, 4, 5. Call x the value returned from point_from_gp, then this function is:

gpvalue x
[0.0, 0.25) 1
[0.25, 0.5) 2
[0.5, 0.75) 3
[0.75, 1) 4
1.0 5

using my suggested alteration the function becomes:

gpvalue x
[0.0, 0.2 ) 1
[0.2, 0.4) 2
[0.4, 0.6) 3
[0.6, 0.8) 4
[0.8, 1.0] 5

You can see more examples here

It's also a problem for the warped variables but I haven't worked out the answer to that yet.

cxhernandez commented 7 years ago

done in #234