从包络计算特征
既然您已经去除了音频中较嘈杂的波动,我们来看看这是否能提升分类效果。
上一个练习中的 audio_rectified_smooth 已在您的工作区中可用。
本练习是课程的一部分
Python 中的时间序列机器学习
练习说明
- 为每个心跳声音计算均值、标准差和最大值。
- 按相同顺序将这些统计量按列堆叠。
- 使用交叉验证,在每次 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))