我正在尝试使用支持向量机(svmPoly)和神经网络(nnet)运行卫星图像分类。运行交叉验证时,我从两种方法中获得所需的输出(即6x6混淆矩阵)。当我在整个数据集上运行分类时,只有SVM产生多类(6个离散类)图像输出,而nnet产生具有单个类的图像输出。
Here, is the code I'm using in R
## Creating a data Partition, which splits the data into 70% for training and 30% for testing
data_partition <- createDataPartition(training_table$layer, times= 100, p= 0.7, list= FALSE)
data_train <- training_table[data_partition,] ## Training data
data_test <- training_table[-data_partition,] ## Testing data
## Defining training control parameters
control <- trainControl(method="repeatedcv", number=5, repeats=100, savePredictions="final", verboseIter=TRUE, classProbs=FALSE)
## Creating list of models to use
algorithmList <- c('svmPoly', 'nnet')
## Training the models
set.seed(50)
models <- caretList(factor(class) ~ a+b+c+d+e+f , data=data_train, trControl=control, methodList=algorithmList)
## Using the models created to predict the LULC classes of the Testing data
preds <- as.data.frame(predict(object= models, data_test))
## Creating confusion matrix to check the accuracy of the prediction made by the different models wrt Testing data
cm_svm <- confusionMatrix(preds$svmPoly, data_test$layer)
cm_nn <- confusionMatrix(preds$nnet, data_test$layer)
## Print confusion matrix
print(cm_svm)
print(cm_nn)
## Image Classification
## Training models using different methods
set.seed(50)
img_train_svm <- ksvm(class ~ a+b+c+d+e+f, data= training_table, type= "C-svc", kernel= "polydot", degree= 3, scale= 0.1, C= 1)
set.seed(50)
img_train_nn <- nnet(class ~ a+b+c+d+e+f, data= training_table, size = 5)
## Using different methods for classification
img_class_svm <- predict(study_area, img_train_svm, fun= predict, na.rm=TRUE, progress="text")
img_class_nn <- predict(study_area, img_train_nn, fun= predict, na.rm=TRUE, progress="text")
## Viewing classification
plot(img_class_svm, col= c("yellow", "red","brown", "green", "blue", "black"), main= 'SVM')
plot(img_class_nn, col= c("yellow", "red","brown", "green", "blue", "black"), main= 'NNet')
这些是分类的输出 Classification using svmPoly Classification using nnet
我不确定我做错了什么。任何人都可以指出明显的?