0
저는 마지막 클래스 이름을 기반으로 한 데이터 프레임을 svm에 몇 시간이나 몇 시간 동안 노력하고 있습니다.SVM 마지막 열을 기반으로하는 데이터 프레임
나는이 데이터 프레임을 가지고
#FIll the data frame
df = read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data",
sep=",",
col.names=c("buying", "maint", "doors", "persons", "lug_boot", "safety", ""),
fill=TRUE,
strip.white=TRUE)
lastColName <- colnames(df)[ncol(df)]
... 내가 NULL
또는 Error in model.frame.default(formula = str(lastColName) ~ ., data = df1, : invalid type (NULL) for variable 'str(lastColName)'
중 하나를 얻고있다
model <- svm(lastColName~.,
data = df,
kernel="polynomial",
degree = degree,
type = "C-classification",
cost = cost)
. 열이 이름이 없을 때 NULL
이 도착하는 것을 이해합니다. 나는 마지막 열 이름이기 때문에 다른 오류를 이해하지 못합니다 ..
어떤 생각?
와우, 그것은 작동합니다 감사합니다! 그러나 예측은 인수가 같은 길이가 아니라는 말로 실패합니다. 나는 당신의 방법 =>'table (predict (model), as.formula (paste (lastColName, "~.", sep = "")), dnn = c ("예측", "실제")) – Emixam23
모델에서 예측할 답변을 업데이트했습니다. – discipulus