-
-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Closed
ajtulloch
wants to merge
10
commits into
scikit-learn:master
from
ajtulloch:isotonic-regression-in-linear-time
Closed
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8e25dbc
ENH - Improve performance of isotonic regression
ajtulloch d9da527
Updated with @ogrisel's helpful comments.
ajtulloch b99a548
Fixed `k+1` => `k + 1` to follow style guide.
ajtulloch 222ac33
Fixed unnecessary newline in `whats_new.rst`
ajtulloch 615c48c
Make comments more explicit.
ajtulloch a196711
Cleaned up benchmark script somewhat.
ajtulloch d6d4375
Added link to Andrew Tulloch's homepage in `whats_new.rst`.
ajtulloch 6827311
Clean up benchmark tool to be more self documenting and
ajtulloch a3dba48
Further cleanups to benchmark script.
ajtulloch 39310f7
Improved comments in benchmark script.
ajtulloch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.