yandex / rep

Machine Learning toolbox for Humans
http://yandex.github.io/rep/
Other
687 stars 144 forks source link

do we need to measure fit/predict time without %time? #73

Closed anaderi closed 8 years ago

anaderi commented 8 years ago

it is useful if jupyter frontend disconnects during fit/predict execution.

might the following snippet be handy for such cases

class Stopwatch(object):
    def __enter__(self):
        self.t0 = datetime.datetime.now()
        return self

    def __exit__(self, type, value, traceback):
        self.t1 = datetime.datetime.now()

    def __repr__(self):
        return "delta: (%s)" % (self.t1 - self.t0)

with Stopwatch() as sfit:
    time.sleep(1)
with Stopwatch() as spredict:
    time.sleep(1)

print "fit:", sfit, "spredict:", spredict
arogozhnikov commented 8 years ago

We can add this into utils (I'm using time.time()). It's actually a shame that in 2016 none of standard python modules have some similar class.

arogozhnikov commented 8 years ago

done in https://github.com/yandex/rep/commit/004b1dcc6ccdd5adf27c9817a1ce0d1ed43deadb