0
在R中運行以下代碼來訓練神經網絡以對手寫進行分類。有63列,其中的第63是範圍從0到9使用R Neuralnet軟件包獲取錯誤結果
library(neuralnet)
data <- read.csv("handwriting.csv")
index <- sample(1:nrow(data),round(0.75*nrow(data)))
train <- data[index,]
test <- data[-index,]
n <- names(train)
f <- as.formula(paste("a63 ~", paste(n[!n %in% "a63"], collapse = " + ")))
nn <- neuralnet(f,data=train, hidden=2, linear.output=F, act.fct = "logistic", err.fct="ce")
plot(nn)
pr.nn <- compute(nn,test[, -63])
predicted <- pr.nn$net.result
results <- cbind(predicted, test$a63)
results
我在最後一步中得到的輸出是如下的分類
4480 0.9999991455 0
4482 0.9999991455 2
4490 0.9999991455 0
4492 0.9999991455 2
4494 0.9999991455 4
帶有小數的第一列是預測結果,但這並不是我所期望的,因爲結果應該與最後一列中的類似而非小數,當我更改linear.output = TRUE時,我會得到更接近的值,但這不是正確的解釋,因爲我的意圖是分類
「不正確的結果」是一個煽動性問題標題,與「不是我所期望的」有很大不同。 – Gregor