這裏是更新的代碼。我的問題是「結果」的輸出。作爲可讀性的格式,我將在下面發佈。R神經網絡問題
library("neuralnet")
library("ggplot2")
setwd("C:/Users/Aaron/Documents/UMUC/R/Data For Assignments")
trainset <- read.csv("SOTS.csv")
head(trainset)
## val data classification
str(trainset)
## building the neural network
risknet <- neuralnet(Overall.Risk.Value ~ Finance + Personnel + Information.Dissemenation.C, trainset, hidden = 10, lifesign = "minimal", linear.output = FALSE, threshold = 0.1)
##plot nn
plot(risknet, rep="best")
##import scoring set
score_set <- read.csv("SOSS.csv")
##select subsets-training and scoring match
score_test <- subset(score_set, select = c("Finance", "Personnel", "Information.Dissemenation.C"))
##display values of score_test
head(score_test)
##neural network compute function score_test and the neural net "risknet"
risknet.results <- compute(risknet, score_test)
##Actual value of Overall.Risk.Value variable wanting to predict. net.result = a matrix containing the overall result of the neural network
results <- data.frame(Actual = score_set$Overall.Risk.Value, Prediction = risknet.results$net.result)
results[1:14, ]
結果的輸出與預期不符。例如,實際數據是介於5和8之間的數字,而「預測」則顯示每個結果的.9995 ...的輸出。
再次感謝您的幫助。
什麼是你所謂的「得分」集?驗證集或測試集? –
評分集與訓練集的數據完全相同(在變量risknet中顯示)。唯一的區別是Overall.Risk.Value的價值 –