kaggle——MNIST之一

通过调整输入数据的处理方式,将灰度图转化为二值化图,准确率从10%提升至88%,深入探讨SVM参数对分类性能的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ml的入门教程,使用svm来做mnist的分类:
细节:直接将image拉成一个向量,然后直接采用svm分类,结果 10%的准确率,和随机猜测ch差不多;

改进版:将grey的image转换为二值化图,即为0或1图,然后相同的的方法训练,准确率飙升至88%;

其他人的版本:将grey归一化到【0,1】,其准确率ch差不多也是88%;

关于此的分析:

So instead of setting values to 0 or 1, I rescaled the features to be within [0, 1] (notice that the numbers still takes continuous values, not only just binary states). The resulting precision is 0.883, very similar to 0.887 here.

I think the true reason has to do with the relative penalty you put on regularization vs. in sample loss in SVM. The objective function you are minimizing is:

regularization term + hinge loss * C

By default, C is set to be 1 in sklearn svm.SVC. When the value of the feature is between 0 and 255, I think the regularization term is effectively so large that SVM does not learn anything from the samples.

By playing with the paramter C, you will see the same effect without rescaling/changing the feature.

Here's an excerpt from sklearn:

"Support Vector Machine algorithms are not scale invariant, so it is highly recommended to scale your data. For example, scale each attribute on the input vector X to [0,1] or [-1,+1], or standardize it to have mean 0 and variance 1. Note that the same scaling must be applied to the test vector to obtain meaningful results. See section Preprocessing data for more details on scaling and normalization."

(所以,出现问题,多看看说明手册,或许会有da'a答案)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值