使用 scikit-learn 训练数据时 SVM 多类分类停止
SVM multiclass classification halts when training data using scikit-learn
我正在使用 scikit 和 svm 将数据分类为 7 类。数据是音频,我将它们分成 30 毫秒的帧。
最后,大约有 100 万帧,每个帧用作带有 13 个 mfcc 特征的标记样本。
当按照以下代码拟合数据时,我的 cpu 保持在大约 20% 的使用率并且没有任何反应!我等了大约30个小时,但还没有完成。
是不是样本数量太多了?!!
clf = SVC(C=20.0, gamma=0.00001)
clf.fit(X_train, y_train) #This is where it gets stuck
你应该看看documentation。
The fit time scales at least quadratically with the number of samples and may be impractical beyond tens of thousands of samples
此外,由于您使用的是 7 类 的多类问题,并且自
The multiclass support is handled according to a one-vs-one scheme.
您正在训练 21(!) 个分类器,请参阅 here。
文档推荐:
For large datasets consider using sklearn.linear_model.LinearSVC
or sklearn.linear_model.SGDClassifier
instead, possibly after a sklearn.kernel_approximation.Nystroem
transformer.
您是否考虑过 运行 神经网络?
正如 Quickbeam2k1 回答的详细信息,SVM 不能很好地扩展到这么多样本。
我建议改用小型神经网络。一个多层感知器可能有 3-5 个隐藏层,每个隐藏层有 50 个神经元,对于 13 波段 MFCC 和 7 类 应该是一个好的起点。使用 scikit-learn,您可以使用 sklearn.neural_network.MLPClassifier.
我正在使用 scikit 和 svm 将数据分类为 7 类。数据是音频,我将它们分成 30 毫秒的帧。 最后,大约有 100 万帧,每个帧用作带有 13 个 mfcc 特征的标记样本。 当按照以下代码拟合数据时,我的 cpu 保持在大约 20% 的使用率并且没有任何反应!我等了大约30个小时,但还没有完成。 是不是样本数量太多了?!!
clf = SVC(C=20.0, gamma=0.00001)
clf.fit(X_train, y_train) #This is where it gets stuck
你应该看看documentation。
The fit time scales at least quadratically with the number of samples and may be impractical beyond tens of thousands of samples
此外,由于您使用的是 7 类 的多类问题,并且自
The multiclass support is handled according to a one-vs-one scheme.
您正在训练 21(!) 个分类器,请参阅 here。
文档推荐:
For large datasets consider using
sklearn.linear_model.LinearSVC
orsklearn.linear_model.SGDClassifier
instead, possibly after asklearn.kernel_approximation.Nystroem
transformer.
您是否考虑过 运行 神经网络?
正如 Quickbeam2k1 回答的详细信息,SVM 不能很好地扩展到这么多样本。
我建议改用小型神经网络。一个多层感知器可能有 3-5 个隐藏层,每个隐藏层有 50 个神经元,对于 13 波段 MFCC 和 7 类 应该是一个好的起点。使用 scikit-learn,您可以使用 sklearn.neural_network.MLPClassifier.