相同的代码,不同的计算机,不同的结果

问题描述 投票:0回答:1

我编写了显示混乱矩阵的代码。当我在一台计算机上运行代码时,我得到的结果与另一台计算机略有不同。我在3台计算机上进行了尝试,两台计算机匹配,而第一台计算机给出的答案与其他两台计算机不同。

我尝试重置垃圾收集器,删除了所有对象。唯一可行的解​​决方案是设置种子,即使算法中没有随机化。

mydata=read.csv("dividendinfo.csv")
normalize <- function(x) {
  return ((x - min(x)) / (max(x) - min(x)))
}
maxmindf <- as.data.frame(lapply(mydata, normalize))
trainset <- maxmindf[1:160, ]
testset <- maxmindf[161:200, ]
library(neuralnet)
nn <- neuralnet(dividend ~ fcfps + earnings_growth + de + mcap + current_ratio, data=trainset, hidden=c(2,1), linear.output=FALSE, threshold=0.01)
nn$result.matrix
temp_test <- subset(testset, select = c("fcfps","earnings_growth", "de", "mcap", "current_ratio")) 
nn.results <- compute(nn, temp_test)
results <- data.frame(actual = testset$dividend, prediction =nn.results$net.result)
roundedresults<-data.frame(sapply(results,round,digits=0))
CM=table(actual=roundedresults$actual,prediction=roundedresults$prediction)

预期结果是


        0  1
     0 17  0
     1  3 20

实际结果是


        0  1
     0 17  0
     1  4 19
r compilation
1个回答
0
投票

您能给我发这个股息信息.csv数据集吗? [email protected]

© www.soinside.com 2019 - 2024. All rights reserved.