開始使用免費開始

從包絡線計算特徵

你已經去除了音訊中較吵雜的起伏,現在來看看這是否能提升分類的效果。

上一個練習產生的 audio_rectified_smooth 已可在你的工作區中使用。

本練習屬於課程

Python 的時間序列資料機器學習

檢視課程

練習說明

  • 為每段心跳聲計算平均值、標準差與最大值。
  • 依相同順序將這些統計量以欄方向堆疊(column stack)。
  • 使用交叉驗證,在每次 CV 疊代中擬合模型。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Calculate stats
means = np.____(audio_rectified_smooth, axis=0)
stds = ____(audio_rectified_smooth, axis=0)
maxs = ____(audio_rectified_smooth, axis=0)

# Create the X and y arrays
X = np.column_stack([____, ____, ____])
y = labels.reshape(-1, 1)

# Fit the model and score on testing data
from sklearn.model_selection import cross_val_score
percent_score = ____(model, ____, ____, cv=5)
print(np.mean(percent_score))
編輯並執行程式碼