SVM 总是收敛吗?

Does SVM always converge?

我在 python 中使用 scikit-learn 来使用 svm.SVC 对我的实例进行分类;然而,对于某些参数组合,拟合永远不会停止。这是因为算法需要更多时间吗?还是算法没有收敛到极值点。

请注意,我没有对我的数据做任何假设。知道这一点,svm 是否总是收敛于任意数据集?

它应该总是收敛的,除非有数值问题。

确保您的数据已正确缩放。如果不同的特征具有不同数量级的值,这是一个坏主意。您可能希望将所有特征标准化到 [-1,+1] 范围内,尤其是对于超过 100 个特征的问题。

Q: The program keeps running (with output, i.e. many dots). What should I do?

In theory libsvm guarantees to converge. Therefore, this means you are handling ill-conditioned situations (e.g. too large/small parameters) so numerical difficulties occur.

Reference: https://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html

正如 Imanol 和其他人在上面所建议的那样,扩大你的训练和测试输入。

遵循一般标准,例如:mean=0 and STD=1

您可以使用 sklearn.preprocessing 库中提供的 StandardScaler API。

注意:仅在训练输入集上拟合 StandardScaler 函数并转换训练和测试,因此应用相同的比例。

scaler = StandardScaler().fit(train_ip)
scaler.transform(train_ip)
scaler.transform(test_ip)