Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Improve performance of isotonic regression #2944

31 changes: 31 additions & 0 deletions benchmarks/bench_isotonic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import print_function

import numpy as np
import gc
from datetime import datetime
from sklearn.isotonic import IsotonicRegression
from sklearn.utils.bench import total_seconds
import sys


def bench_isotonic_regression(X, Y):
gc.collect()

tstart = datetime.now()
clf = IsotonicRegression()
clf.fit(X, Y)
delta = datetime.now() - tstart
return total_seconds(delta)

if __name__ == '__main__':
min_exp, max_exp, iters = map(int, sys.argv[1:])
timings = []
for i in range(min_exp, max_exp):
n = 10 ** i
X = np.arange(n)
Y = np.random.randint(-50, 50, size=(n,)) \
+ 50. * np.log(1 + np.arange(n))
times = [bench_isotonic_regression(X, Y) for i in range(iters)]
timing = (n, np.mean(times))
timings.append(timing)
print(n, np.mean(times))
4 changes: 4 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ Changelog
:func:`feature_selection.f_regression` when variates are not centered.
By `VirgileFritsch`_.

- Significant performance improvements (more than 100x speedup for
large problems) in :class:`isotonic.IsotonicRegression` by
`Andrew Tulloch`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to link to your home page you must give the URL at the end of the file. Otherwise, just remove the link markup.



API changes summary
-------------------
Expand Down
Loading