0
0
SciPydata~15 mins

Peak finding (find_peaks) in SciPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Peak Finding in a Signal Using scipy
📖 Scenario: You have recorded a simple signal from a sensor over time. The signal has some peaks that represent important events. You want to find where these peaks occur.
🎯 Goal: Build a small program to find the peaks in a signal using the scipy.signal.find_peaks function.
📋 What You'll Learn
Create a list called signal with exact values representing the sensor data.
Create a variable called height_threshold to filter peaks by minimum height.
Use scipy.signal.find_peaks with the height parameter set to height_threshold to find peaks.
Print the indices of the peaks found.
💡 Why This Matters
🌍 Real World
Peak finding is used in many fields like analyzing heartbeats in medical data, detecting events in sensor data, or finding important points in stock price movements.
💼 Career
Data scientists and analysts often need to extract meaningful features from time series or signal data, and peak detection is a common technique for this.
Progress0 / 4 steps
1
Create the signal data
Create a list called signal with these exact values: [0, 2, 1, 3, 7, 1, 2, 6, 0, 1].
SciPy
Need a hint?

Use square brackets to create a list and separate numbers with commas.

2
Set the height threshold for peaks
Create a variable called height_threshold and set it to 4 to filter peaks by minimum height.
SciPy
Need a hint?

Just assign the number 4 to the variable height_threshold.

3
Find peaks using scipy.signal.find_peaks
Import find_peaks from scipy.signal. Use find_peaks on signal with the parameter height=height_threshold. Store the result indices in a variable called peaks.
SciPy
Need a hint?

Use from scipy.signal import find_peaks to import. Then call find_peaks(signal, height=height_threshold) and unpack the first result as peaks.

4
Print the indices of the peaks
Print the variable peaks to display the indices of the peaks found in the signal.
SciPy
Need a hint?

Use print(peaks) to show the peak indices.