Working on the feature 13
load("~/PED/prepareDataDay/feature_new_norm13.RData")
##the variables
colnames(feature_new_train13)
## [1] "MAXO3P" "AVGO3P" "MAXO3P_MAXRHP"
## [4] "MAXO3P_MEDIANO2P" "MEDIANWSPP_MEDIANRHP" "MAXWDRP_MEDIANNOxP"
## [7] "MAXTMPP_MAXRHP" "MAXNOXP" "MAXNO2P"
## [10] "WEEKDAYC" "SEASONC" "TMPpoint"
## [13] "RHpoint" "WSPpoint" "MAXO3C"
##the size of samples
nrow(feature_new_train13)
## [1] 2316
nrow(feature_new_test13)
## [1] 409
source('~/PED/nnetAnalysis/function.R', echo=TRUE)
##
## > library(nnet)
##
## > library(randomForest)
## randomForest 4.6-10
## Type rfNews() to see new features/changes/bug fixes.
##
## > modelErrors <- function(predicted, actual) {
## + sal <- vector(mode = "numeric", length = 3)
## + names(sal) <- c("MAE", "RMSE", "RELE")
## + me .... [TRUNCATED]
##
## > train_testErrors <- function(model, inputsTrain, targetsTrain,
## + inputsTest, targetsTest) {
## + trainPredict <- predict(model, newdata = as.d .... [TRUNCATED]
##
## > lm_nnet_rf_error <- function(feature_new_train, feature_new_test,
## + dataset) {
## + inputsTrain <- feature_new_train[, -c(ncol(feature_new_tra .... [TRUNCATED]
###train models and calculate the errors
##lm_nnet_rf_error(feature_new_test13,feature_new_train13,13)##
showing the results
load(paste("dataset_",13,"MAE.RData"))
load(paste("dataset_",13,"RMSE.RData"))
load(paste("lm_size_", "dataset_",13,".RData"))
load(paste("dataset_",13,"MAE.rf.RData"))
load(paste("dataset_",13,"RMSE.rf.RData"))
show the linear regression model errors
error_lm
## $train
## MAE RMSE RELE
## 0.07457 0.09682 0.22565
##
## $test
## MAE RMSE RELE
## 0.07715 0.09781 0.25043
ANN
###ANN
### when decay is 1e-4
MAE[MAE[,"decay"]==1e-4,c("size","trainMAE","testMAE")]->MAE4
MAE4[order(MAE4[,1]),]
## size trainMAE testMAE
## MAE 11 0.03919 0.1163
## MAE 13 0.01762 0.1358
## MAE 15 0.03110 0.1193
## MAE 17 0.01239 0.1318
## MAE 19 0.02271 0.1282
## MAE 21 0.03640 0.1138
## MAE 23 0.01315 0.1342
## MAE 25 0.02412 0.1243
RMSE[RMSE[,"decay"]==1e-4,c("size","trainRMSE","testRMSE")]->RMSE4
RMSE4[order(RMSE4[,1]),]
## size trainRMSE testRMSE
## RMSE 11 0.04985 0.1551
## RMSE 13 0.02434 0.1780
## RMSE 15 0.04051 0.1560
## RMSE 17 0.01768 0.1725
## RMSE 19 0.03166 0.1663
## RMSE 21 0.04842 0.1496
## RMSE 23 0.01852 0.1771
## RMSE 25 0.03297 0.1648
###decay is 1e-3
MAE[MAE[,"decay"]==1e-3,c("size","trainMAE","testMAE")]->MAE3
MAE3[order(MAE3[,1]),]
## size trainMAE testMAE
## MAE 11 0.04680 0.08929
## MAE 13 0.05580 0.08293
## MAE 15 0.04740 0.08756
## MAE 17 0.04403 0.09134
## MAE 19 0.04958 0.08603
## MAE 21 0.04828 0.08706
## MAE 23 0.04642 0.08805
## MAE 25 0.04507 0.09066
RMSE[RMSE[,"decay"]==1e-3,c("size","trainRMSE","testRMSE")]->RMSE3
RMSE3[order(RMSE3[,1]),]
## size trainRMSE testRMSE
## RMSE 11 0.06118 0.1174
## RMSE 13 0.07397 0.1062
## RMSE 15 0.06375 0.1136
## RMSE 17 0.05926 0.1191
## RMSE 19 0.06619 0.1113
## RMSE 21 0.06418 0.1131
## RMSE 23 0.06300 0.1146
## RMSE 25 0.05897 0.1181
###decay is 1e-2
MAE[MAE[,"decay"]==1e-2,c("size","trainMAE","testMAE")]->MAE2
MAE2[order(MAE2[,1]),]
## size trainMAE testMAE
## MAE 11 0.07169 0.07518
## MAE 13 0.07172 0.07518
## MAE 15 0.07288 0.07569
## MAE 17 0.07170 0.07518
## MAE 19 0.07288 0.07570
## MAE 21 0.07287 0.07570
## MAE 23 0.07287 0.07570
## MAE 25 0.07176 0.07517
RMSE[RMSE[,"decay"]==1e-2,c("size","trainRMSE","testRMSE")]->RMSE2
RMSE2[order(RMSE2[,1]),]
## size trainRMSE testRMSE
## RMSE 11 0.09317 0.09645
## RMSE 13 0.09320 0.09645
## RMSE 15 0.09532 0.09705
## RMSE 17 0.09318 0.09644
## RMSE 19 0.09531 0.09705
## RMSE 21 0.09531 0.09706
## RMSE 23 0.09531 0.09705
## RMSE 25 0.09324 0.09644
###decay is 1e-1
MAE[MAE[,"decay"]==1e-1,c("size","trainMAE","testMAE")]->MAE1
MAE1[order(MAE1[,1]),]
## size trainMAE testMAE
## MAE 11 0.08041 0.07920
## MAE 13 0.08040 0.07915
## MAE 15 0.08041 0.07917
## MAE 17 0.08042 0.07921
## MAE 19 0.08040 0.07916
## MAE 21 0.08041 0.07918
## MAE 23 0.08040 0.07915
## MAE 25 0.08041 0.07917
RMSE[RMSE[,"decay"]==1e-1,c("size","trainRMSE","testRMSE")]->RMSE1
RMSE1[order(RMSE1[,1]),]
## size trainRMSE testRMSE
## RMSE 11 0.1028 0.09972
## RMSE 13 0.1028 0.09968
## RMSE 15 0.1028 0.09970
## RMSE 17 0.1028 0.09973
## RMSE 19 0.1028 0.09969
## RMSE 21 0.1028 0.09971
## RMSE 23 0.1028 0.09968
## RMSE 25 0.1028 0.09969
###decay is 1
MAE[MAE[,"decay"]==1,c("size","trainMAE","testMAE")]->MAE0
MAE0[order(MAE0[,1]),]
## size trainMAE testMAE
## MAE 11 0.09680 0.09837
## MAE 13 0.09681 0.09842
## MAE 15 0.09680 0.09835
## MAE 17 0.09681 0.09838
## MAE 19 0.09682 0.09844
## MAE 21 0.09680 0.09836
## MAE 23 0.09681 0.09840
## MAE 25 0.09680 0.09835
RMSE[RMSE[,"decay"]==1,c("size","trainRMSE","testRMSE")]->RMSE0
RMSE0[order(RMSE0[,1]),]
## size trainRMSE testRMSE
## RMSE 11 0.1231 0.1212
## RMSE 13 0.1231 0.1212
## RMSE 15 0.1231 0.1212
## RMSE 17 0.1231 0.1212
## RMSE 19 0.1231 0.1213
## RMSE 21 0.1231 0.1212
## RMSE 23 0.1231 0.1212
## RMSE 25 0.1231 0.1212
randomForest
##when ntree is 500
MAE_rf[MAE_rf[,"ntree"]==500,c("mtry","trainMAE","testMAE")]->MAE500
RMSE_rf[RMSE_rf[,"ntree"]==500,c("mtry","trainRMSE","testRMSE")]->RMSE500
MAE500
## mtry trainMAE testMAE
## MAE 3 0.03219 0.07504
## MAE 5 0.03095 0.07489
## MAE 7 0.03092 0.07511
## MAE 9 0.03027 0.07512
## MAE 11 0.03017 0.07542
## MAE 13 0.03031 0.07559
## MAE 15 0.03006 0.07555
## MAE 17 0.03016 0.07565
## MAE 19 0.03004 0.07546
RMSE500
## mtry trainRMSE testRMSE
## RMSE 3 0.04290 0.09727
## RMSE 5 0.04187 0.09742
## RMSE 7 0.04181 0.09777
## RMSE 9 0.04084 0.09780
## RMSE 11 0.04085 0.09807
## RMSE 13 0.04073 0.09834
## RMSE 15 0.04072 0.09841
## RMSE 17 0.04077 0.09841
## RMSE 19 0.04084 0.09821
##when ntree is 1000
MAE_rf[MAE_rf[,"ntree"]==1000,c("mtry","trainMAE","testMAE")]->MAE1000
RMSE_rf[RMSE_rf[,"ntree"]==1000,c("mtry","trainRMSE","testRMSE")]->RMSE1000
MAE1000
## mtry trainMAE testMAE
## MAE 3 0.03191 0.07495
## MAE 5 0.03112 0.07486
## MAE 7 0.03058 0.07511
## MAE 9 0.03020 0.07504
## MAE 11 0.03027 0.07532
## MAE 13 0.03026 0.07550
## MAE 15 0.03004 0.07557
## MAE 17 0.02994 0.07545
## MAE 19 0.03026 0.07555
RMSE1000
## mtry trainRMSE testRMSE
## RMSE 3 0.04273 0.09719
## RMSE 5 0.04184 0.09739
## RMSE 7 0.04126 0.09767
## RMSE 9 0.04109 0.09779
## RMSE 11 0.04109 0.09806
## RMSE 13 0.04083 0.09833
## RMSE 15 0.04069 0.09834
## RMSE 17 0.04069 0.09819
## RMSE 19 0.04095 0.09833
##when ntree is 1500
MAE_rf[MAE_rf[,"ntree"]==1500,c("mtry","trainMAE","testMAE")]->MAE1500
RMSE_rf[RMSE_rf[,"ntree"]==1500,c("mtry","trainRMSE","testRMSE")]->RMSE1500
MAE1500
## mtry trainMAE testMAE
## MAE 3 0.03199 0.07487
## MAE 5 0.03116 0.07500
## MAE 7 0.03061 0.07504
## MAE 9 0.03037 0.07533
## MAE 11 0.03019 0.07541
## MAE 13 0.03017 0.07550
## MAE 15 0.02994 0.07549
## MAE 17 0.03008 0.07558
## MAE 19 0.03008 0.07548
RMSE1500
## mtry trainRMSE testRMSE
## RMSE 3 0.04278 0.09720
## RMSE 5 0.04186 0.09757
## RMSE 7 0.04131 0.09758
## RMSE 9 0.04094 0.09799
## RMSE 11 0.04082 0.09811
## RMSE 13 0.04090 0.09826
## RMSE 15 0.04067 0.09825
## RMSE 17 0.04064 0.09832
## RMSE 19 0.04086 0.09821
##when ntree is 2000
MAE_rf[MAE_rf[,"ntree"]==2000,c("mtry","trainMAE","testMAE")]->MAE2000
RMSE_rf[RMSE_rf[,"ntree"]==2000,c("mtry","trainRMSE","testRMSE")]->RMSE2000
MAE2000
## mtry trainMAE testMAE
## MAE 3 0.03200 0.07483
## MAE 5 0.03105 0.07492
## MAE 7 0.03065 0.07523
## MAE 9 0.03030 0.07519
## MAE 11 0.03019 0.07539
## MAE 13 0.03007 0.07550
## MAE 15 0.03012 0.07551
## MAE 17 0.03016 0.07556
## MAE 19 0.03008 0.07558
RMSE2000
## mtry trainRMSE testRMSE
## RMSE 3 0.04281 0.09711
## RMSE 5 0.04183 0.09749
## RMSE 7 0.04134 0.09782
## RMSE 9 0.04100 0.09786
## RMSE 11 0.04080 0.09807
## RMSE 13 0.04068 0.09823
## RMSE 15 0.04092 0.09825
## RMSE 17 0.04079 0.09832
## RMSE 19 0.04065 0.09833
##when ntree is 2500
MAE_rf[MAE_rf[,"ntree"]==2500,c("mtry","trainMAE","testMAE")]->MAE2500
RMSE_rf[RMSE_rf[,"ntree"]==2500,c("mtry","trainRMSE","testRMSE")]->RMSE2500
MAE2500
## mtry trainMAE testMAE
## MAE 3 0.03199 0.07480
## MAE 5 0.03091 0.07486
## MAE 7 0.03057 0.07514
## MAE 9 0.03029 0.07518
## MAE 11 0.03021 0.07533
## MAE 13 0.03013 0.07554
## MAE 15 0.03008 0.07549
## MAE 17 0.03014 0.07550
## MAE 19 0.03017 0.07556
RMSE2500
## mtry trainRMSE testRMSE
## RMSE 3 0.04286 0.09715
## RMSE 5 0.04158 0.09741
## RMSE 7 0.04120 0.09772
## RMSE 9 0.04090 0.09786
## RMSE 11 0.04084 0.09803
## RMSE 13 0.04084 0.09829
## RMSE 15 0.04081 0.09823
## RMSE 17 0.04092 0.09829
## RMSE 19 0.04080 0.09828