Skip to content
Advertisement

Problem with plotting peaks using find_peaks from SciPy to detect drastic up/down turns or global outliers

Let’s say I have following dataframe contains value over time or date:

JavaScript

I inspired from this answer to detect peaks and valleys via below code:

JavaScript

This is the output:

img

The problems:

  • I can’t figure out how I can configure find_peaks() documentation to reach meaningful/drastic peaks & valley with respect to threshold as global outliers. I also checked this post but couldn’t help me to find the cheap solution as well as other libraries offered here.
  • The upper threshold with red dashed is missing!

Advertisement

Answer

  1. You need to specify height in the same domain as your data
  2. Upper thresohld is not missing, it is on the plot, just all those lines are close to 0 and clutter on the bottom.
JavaScript

enter image description here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement