【发布时间】:2016-10-22 00:42:12
【问题描述】:
我刚刚编写了我的第一次尝试,即通过使用能耗特征为家庭分类提供神经网络。到目前为止,我可以让它运行,但输出似乎有问题。 所以就像你看到的那样,我使用了 18 个特征(也许很多?)来预测它是单身家庭还是非单身家庭。
我有 3488 行这样的:
c_day c_weekend c_evening c_morning c_night c_noon c_max c_min r_mean_max r_min_mean r_night_day r_morning_noon
12 14 1826 9 765 3 447 2 878 0 7338 4
r_evening_noon t_above_1kw t_above_2kw t_above_mean t_daily_max single
3424 1 695 0 174319075712881 1
我的神经网络使用这些参数:
net.nn <- neuralnet(single
~ c_day
+ c_weekend
+ c_weekday
+ c_evening
+ c_morning
+ c_night
+ c_noon
+ c_max
+ c_min
+ r_mean_max
+ r_min_mean
+ r_night_day
+ r_morning_noon
+ r_evening_noon
+ t_above_1kw
+ t_above_2kw
+ t_above_mean
+ t_daily_max
,train, hidden=15, threshold=0.01,linear.output=F)
1 repetition was calculated.
Error Reached Threshold Steps
1 126.3425379 0.009899229932 4091
我之前使用最小-最大归一化公式对数据进行了归一化:
for(i in names(full_data)){
x <- as.numeric(full_data[,i])
full_data[,i] <- (x-min(x)/max(x)-min(x))
}
我得到了 3488 行数据并将它们分成训练集和测试集。
half <- nrow(full_data)/2
train <- full_data[1:half,]
test <- full_data[half:3488,]
net.results <- compute(net.nn,test)
nn$net.result
我使用了预测方法并将其绑定到实际的“single[y/no]”列来比较结果:
predict <- nn$net.result
cleanoutput <- cbind(predict,full_data$single[half:3488])
colnames(cleanoutput) <- c("predicted","actual")
所以当我打印出来的时候,这是我对前 10 行的分类结果:
predicted actual
1701 0.1661093405 0
1702 0.1317067578 0
1703 0.1677147708 1
1704 0.2051188618 1
1705 0.2013035634 0
1706 0.2088726723 0
1707 0.2683753128 1
1708 0.1661093405 0
1709 0.2385537285 1
1710 0.1257108821 0
因此,如果我理解正确,当我对预测输出进行四舍五入时,它应该是 0 或 1,但最终总是为 0!
我是否使用了错误的参数?我的数据根本不适合 nn 预测吗?归一化错了吗?
【问题讨论】:
-
感谢您的提示。正如你所说,我刚刚尝试了平均标准偏差归一化,它将误差降低到 ~25。
-
现在您的错误率很低。现在您可能想要比较训练和测试数据集之间的误差,看看您是否过度拟合。
标签: r neural-network