我正在尝试使用svm对图像进行监督图像分类并在运行模型时面临群集错误

问题描述

我正在尝试使用SVM在R中进行监督分类,并使用了以下代码

# load libraries
library(rgdal)
library(raster)
library(caret)
library(sf)
library(e1071)

# stacked image import
img <- brick("Composite_LT05_L1TP_145039_19950318_20170109_01_T1_B1.tif")

#signature .shp files 
trainData <- readOGR("C:/Users/Zainab Khan/Desktop/india","trainData")

#ploting the image
plotRGB(img,5,4,3,stretch = "lin")

# traing the data for supervised classification
model1 <- svm( ~.,data = trainData,kernel = "linear")

# testing data
beginCluster()
svm_class <- clusterR(img,raster::predict,args = list(model1=model1))
endCluster()

引发错误代码: beginCluster()

错误消息: 使用11

检测到12个内核

引发错误代码: svm_class

错误消息: clusterR中的错误(img,raster :: predict,args = list(model1 = model1)):

解决方法

由于您没有提供可复制的示例,因此很难提供帮助。请参阅?raster::predict以获取示例。这行可能应该是

svm_class <- clusterR(img,raster::predict,args = list(model=model1))

({model=,而不是model1=