gpt4 book ai didi

python - SVC 未在 MNIST 上解析

转载 作者:太空宇宙 更新时间:2023-11-04 01:47:05 29 4
gpt4 key购买 nike

我正在使用以下代码分解 MNIST 并运行 SVM:

mnist = fetch_openml('mnist_784', version=1)
X, y = mnist['data'], mnist['target']
y = y.astype(np.uint8)
X_train, X_test, y_train, y_test = X[:60000], X[60000:], y[:60000], y[60000:]
svm_clf = SVC()
svm_clf.fit(X_train, y_train)

昨晚我离开了它去运行。三个小时过去了,问题仍然没有解决。

我得到了 future 的警告

FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.
"avoid this warning.", FutureWarning)

但我无法想象不设置 Gamma 会以这种方式影响它。

我在 Jupyter 5.7.8 中运行 Python 3.6.7。

最佳答案

的确,没有解决办法。随着训练向量数量的增加,训练时间也会增加。

引用:https://scikit-learn.org/stable/modules/svm.html#complexity

enter image description here

郑重声明,SVM 非常适合解决这些问题(参见此处:https://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html),但当数据集很大时,它们会变慢。


编辑 1:在 sklearn website 中有这个:

The implementation is based on libsvm. The fit time scales at least quadratically with the number of samples and may be impractical beyond tens of thousands of samples. For large datasets consider using sklearn.linear_model.LinearSVC or sklearn.linear_model.SGDClassifier instead, possibly after a sklearn.kernel_approximation.Nystroem transformer.

关于python - SVC 未在 MNIST 上解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58859565/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com