我正在使用Scikit-学习支持向量机来训练我的STL-10数据集模型,其中包含5000幅训练图像(10个预定义的折叠)。所以我有5000*96*96*3大小的数据集,用于培训和测试。我使用下面的代码来训练它,并测量测试集的准确性。(80%,20%)。最终结果为0.323的准确性。如何提高支持向量机的精度。
我是STL10数据集
def train_and_evaluate(clf, train_x, train_y):
clf.fit(train_x, train_y)
#make 2D array as we can apply only 2d to fit() function
nsamples, nx, ny, nz = images.shape
reshaped_train_dataset = images.reshape((nsamples, nx * ny * nz))
X_train, X_test, Y_train, Y_test = train_test_split(reshaped_train_dataset, read_labels(LABEL_PATH), test_size=0.20, random_state=33)
train_and_evaluate(my_svc, X_train, Y_train)
print(metrics.accuracy_score(Y_test, clf2.predict(X_test)))发布于 2016-05-30 17:26:56
所以看起来你是直接在图像上使用原始支持向量机。这通常不是一个好主意(实际上是相当糟糕的)。
我将描述过去几十年流行的经典图像分类管道!请记住,目前性能最好的方法可能会使用深层神经网络将其中的一些步骤结合起来(这是一种非常不同的方法;过去几年进行了大量的研究!)
- **Preprocessing** is needed!
- **Normalize** mean and variance (i would not expect your dataset to be already normalized)
- Optional: **histogram-equalization**
- **Feature-extraction** -> you should learn some features from these images. There are a lot of approaches including
- **(Kernel-)PCA**
- **(Kernel-)LDA**
- **Dictionary-learning**
- **Matrix-factorization**
- **Local binary patterns**
- ... (just test with LDA initially)
- **SVM** for classification
- again there might be a Normalization-step needed before this and as mentioned in the comments by @David Batista: there might be some parameter-tuning needed (especially for Kernel-SVM)
如果在这里使用颜色信息是明智的,也是不清楚的。对于更简单的方法,我期望黑白图像更优越(您正在丢失信息,但是调优管道更健壮;高性能的方法当然会使用颜色信息)。
有关描述类似问题的随机教程,请参见这里。虽然我不知道这是不是好工作,你可以立即识别上面提到的处理管道(预处理,特征提取,分类器学习)!
编辑:为什么预处理?:有些算法假设样本以单位方差为中心,因此需要归一化.这是(至少)非常重要的PCA,LDA和SVM的。
https://stackoverflow.com/questions/37530074
复制相似问题