def probs_to_classes(self, probabilities):
"""Takes a likelihood matrix produced by predict_proba and returns
the classification for each entry
Naive argmax returns a very noisy signal - windowing helps focus on
strongly matching areas.
"""
smooth_time = self.params.get('smooth_time', 0.1)
dt = self.active_song.time[1] - self.active_song.time[0]
windowsize = np.round(smooth_time / dt)
window = signal.get_window('hamming', int(windowsize))
window /= np.sum(window)
num_classes = probabilities.shape[0]
smooth_prbs = [np.convolve(
probabilities[i, :], window, mode='same') for i in range(num_classes)]
return np.argmax(np.stack(smooth_prbs, axis=0), axis=0)
评论列表
文章目录