recalls[label][median], label='%s vs rest' % genre_list[label]) plot_roc(roc_scores[label][median], desc, tprs[label][median], fprs[label][median], label='%s vs rest' % genre_list[label]) all_pr_scores = np.asarray(pr_scores.values()).flatten() summary = (np.mean(scores), np.std(scores), np.mean(all_pr_scores), np.std(all_pr_scores)) print("%.3f\t%.3f\t%.3f\t%.3f\t" % summary) return np.mean(train_errors), np.mean(test_errors), np.asarray(cms) def create_model(): from sklearn.linear_model.logistic import LogisticRegression clf = LogisticRegression() return clf if __name__ == "__main__": X, y = read_fft(genre_list) train_avg, test_avg, cms = train_model( create_model, X, y, "Log Reg FFT", plot=True) cm_avg = np.mean(cms, axis=0) cm_norm = cm_avg / np.sum(cm_avg, axis=0) plot_confusion_matrix(cm_norm, genre_list, "fft", "Confusion matrix of an FFT based classifier")
summary = (np.mean(scores), np.std(scores), np.mean(all_pr_scores), np.std(all_pr_scores)) print("%.3f\t%.3f\t%.3f\t%.3f\t" % summary) return np.mean(train_errors), np.mean(test_errors), np.asarray(cms) def create_model(): from sklearn.linear_model.logistic import LogisticRegression clf = LogisticRegression() return clf if __name__ == "__main__": X, y = read_fft(genre_list) train_avg, test_avg, cms = train_model(create_model, X, y, "Log Reg FFT", plot=True) cm_avg = np.mean(cms, axis=0) cm_norm = cm_avg / np.sum(cm_avg, axis=0) print(cm_norm) plot_confusion_matrix(cm_norm, genre_list, "fft", "Confusion matrix of an FFT based classifier")
def __init__(self): super(FFTSoundClassify, self).__init__() self._X, self._Y = read_fft(GENRE_LIST)