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

refactor: improve speed of BottomUp #309

Merged
merged 1 commit into from
Nov 28, 2023
Merged

refactor: improve speed of BottomUp #309

merged 1 commit into from
Nov 28, 2023

Conversation

probberechts
Copy link
Contributor

This PR makes some small modifications to improve the speed of the BottomUp segmentation algorithm, especially when applied to long time series.


Below is a simple benchmark:

import time
import ruptures as rpt

n_samples, n_dims, sigma = 100_000, 1, 2
n_bkps = 100  # number of breakpoints
signal, bkps = rpt.pw_constant(n_samples, n_dims, n_bkps, noise_std=sigma)

t1 = time.perf_counter(), time.process_time()
algo = rpt.BottomUp(model="normal").fit(signal)
my_bkps = algo.predict(n_bkps=100)
t2 = time.perf_counter(), time.process_time()
print(f" Real time: {t2[0] - t1[0]:.2f} seconds")
print(f" CPU time: {t2[1] - t1[1]:.2f} seconds")

Current implementation: 46.08 seconds
Adapted implementation: 6.94 seconds

@oboulant oboulant changed the title Improve speed of BottomUp refactor: improve speed of BottomUp Nov 28, 2023
@oboulant oboulant self-requested a review November 28, 2023 19:40
@oboulant oboulant added Type: Refactoring A code change that neither fixes a bug nor adds a feature Type: Performance Change introduced for performance labels Nov 28, 2023
@oboulant
Copy link
Collaborator

@probberechts Thx for the great work !
Can you push some fake changes : indeed it is strange, your created PR did not trigger the usual automated checks (tests and everything).

@oboulant
Copy link
Collaborator

This is an example of a recent PR for which I could allow the usual checks to run for a first time contributor : #315

@probberechts
Copy link
Contributor Author

I don't know why it didn't work, but I think you should be able to run the workflows now.

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (03ff932) 98.77% compared to head (0347762) 98.77%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #309   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files          40       40           
  Lines         978      980    +2     
=======================================
+ Hits          966      968    +2     
  Misses         12       12           
Flag Coverage Δ
unittests 98.77% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oboulant
Copy link
Collaborator

On my end :
Current implementation: 17.23 seconds
Adapted implementation: 1.36 seconds

🚀

Copy link
Collaborator

@oboulant oboulant left a comment

Choose a reason for hiding this comment

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

LGTM

@oboulant oboulant merged commit 87d259a into deepcharles:master Nov 28, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Performance Change introduced for performance Type: Refactoring A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants