library(GNAR)
Import
library(jsonlite)
function
<- function(data, net_input, lags, missing_rate) {
cal_mse <- floor(nrow(data) * 0.8)
train_ratio <- ceiling(nrow(data) * 0.2)
test_ratio <- data
df <- ncol(df)
num_cols for (i in 1:num_cols) {
<- sample(c(1:(nrow(df) - test_ratio - lags)),
indices_to_replace size = missing_rate * (nrow(df) - test_ratio - lags))
<- NA
df[indices_to_replace, i]
}<- GNARfit(vts = df[1:train_ratio,], net = net_input, alphaOrder = lags, betaOrder = rep(1, lags))
nafit <- predict(nafit,n.ahead = test_ratio)
predict
<- numeric(num_cols)
mse_each for (i in 1:num_cols) {
<- mean((predict[,i] - df[(train_ratio+1):nrow(df),i])**2)
mse_each[i]
}<- mean(mse_each)
mse_total return(list('each'= mse_each, 'total'=mse_total))
}
<- function(data, net_input, lags, mindex) {
block_cal_mse <- floor(nrow(data) * 0.8)
train_ratio <- ceiling(nrow(data) * 0.2)
test_ratio <- data
df <- ncol(df)
num_cols for (i in 1:num_cols) {
<- NA
df[mindex[[i]],i]
}<- GNARfit(vts = df[1:train_ratio,], net = net_input, alphaOrder = lags, betaOrder = rep(1, lags))
nafit <- predict(nafit,n.ahead = test_ratio)
predict
<- numeric(num_cols)
mse_each for (i in 1:num_cols) {
<- mean((predict[,i] - df[(train_ratio+1):nrow(df),i])**2)
mse_each[i]
}<- mean(mse_each)
mse_total return(list('each'= mse_each, 'total'=mse_total))
}
fivenodes
random
<- fiveVTS
fixed_data <- fiveNet
fixed_net_input <- 2
fixed_lags
<- data.frame(mrate = numeric(),
results_df mse = numeric())
<- c(0,0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8)
missing_rates
for (rate in missing_rates) {
<- cal_mse(fixed_data, fixed_net_input, fixed_lags, rate)
result <- rbind(results_df, data.frame(mrate = rate, mse = result[2]))
results_df
} results_df
mrate | total |
---|---|
<dbl> | <dbl> |
0.0 | 1.257729 |
0.1 | 1.252735 |
0.2 | 1.265524 |
0.3 | 1.250937 |
0.4 | 1.271402 |
0.5 | 1.278707 |
0.6 | 1.301504 |
0.7 | 1.301504 |
0.8 | 1.301504 |
'dataset'] = 'FiveVTS'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'rand'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df FiveVTS_results
block
<- fromJSON("FiveVTS_mindex.json") FiveVTS_mindex
<- fiveVTS
fixed_data <- fiveNet
fixed_net_input <- 2
fixed_lags <- FiveVTS_mindex
fixed_mindex
<- data.frame(mrate = numeric(),
results_df mse = numeric())
<- 0
total_length
for (i in seq_along(fixed_mindex)) {
<- total_length + length(fixed_mindex[[i]])
total_length
}
= total_length/(length(fixed_data[,])*0.8)
rate
<- data.frame(mrate = rate,
results_df mse = block_cal_mse(fixed_data, fixed_net_input, fixed_lags, fixed_mindex)[2])
results_df
mrate | total |
---|---|
<dbl> | <dbl> |
0.125 | 1.272369 |
'dataset'] = 'FiveVTS'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'block'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df FiveVTS_block_results
Chickenpox
random
<-read.csv('./data/Chickenpox.csv',header = TRUE) Chickenpox
<-read.csv('./data/Chickenpox_w.csv',header = FALSE)[2:21,2:21] Chickenpox_w
<- as.matrix(Chickenpox[,2:ncol(Chickenpox)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(Chickenpox_w))
fixed_net_input <- 4
fixed_lags
<- data.frame(mrate = numeric(),
results_df mse = numeric())
<- c(0,0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8)
missing_rates
for (rate in missing_rates) {
<- cal_mse(fixed_data, fixed_net_input, fixed_lags, rate)
result <- rbind(results_df, data.frame(mrate = rate, mse = result[2]))
results_df
} results_df
WARNING: diagonal entries present in original matrix, these will be removed
mrate | total |
---|---|
<dbl> | <dbl> |
0.0 | 1.016342 |
0.1 | 1.016460 |
0.2 | 1.015845 |
0.3 | 1.018481 |
0.4 | 1.020843 |
0.5 | 1.019158 |
0.6 | 1.021600 |
0.7 | 1.021411 |
0.8 | 1.020084 |
'dataset'] = 'Chickenpox'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'rand'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Chickenpox_results
block
<- fromJSON("Chickenpox_mindex.json") Chickenpox_mindex
<- as.matrix(Chickenpox[,2:ncol(Chickenpox)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(Chickenpox_w))
fixed_net_input <- 4
fixed_lags <- Chickenpox_mindex
fixed_mindex
<- 0
total_length
for (i in seq_along(fixed_mindex)) {
<- total_length + length(fixed_mindex[[i]])
total_length
}
= total_length/(length(fixed_data[,])*0.8)
rate
<- data.frame(mrate = rate,
results_df mse = block_cal_mse(fixed_data, fixed_net_input, fixed_lags, fixed_mindex)[2])
results_df
WARNING: diagonal entries present in original matrix, these will be removed
mrate | total |
---|---|
<dbl> | <dbl> |
0.2884615 | 1.017119 |
'dataset'] = 'Chickenpox'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'block'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Chickenpox_block_results
PedalMe
random
<-read.csv('./data/PedalMe.csv',header = TRUE) PedalMe
<-read.csv('./data/PedalMe_w.csv',header = FALSE)[2:16,2:16] PedalMe_w
<- as.matrix(PedalMe[,2:ncol(PedalMe)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(PedalMe_w))
fixed_net_input <- 4
fixed_lags
<- data.frame(mrate = numeric(),
results_df mse = numeric())
<- c(0,0.1, 0.2, 0.3, 0.4, 0.5, 0.6,0.7, 0.8)
missing_rates
for (rate in missing_rates) {
<- cal_mse(fixed_data, fixed_net_input, fixed_lags, rate)
result <- rbind(results_df, data.frame(mrate = rate, mse = result[2]))
results_df
} results_df
WARNING: diagonal entries present in original matrix, these will be removed
mrate | total |
---|---|
<dbl> | <dbl> |
0.0 | 0.5016028 |
0.1 | 0.4971018 |
0.2 | 0.5027820 |
0.3 | 0.5148579 |
0.4 | 0.5226205 |
0.5 | 0.5917800 |
0.6 | 0.4917371 |
0.7 | 0.4917371 |
0.8 | 0.4917371 |
'dataset'] = 'Pedalme'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'rand'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Pedalme_results
block
<- fromJSON("Pedalme_mindex.json") Pedalme_mindex
<- as.matrix(PedalMe[,2:ncol(PedalMe)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(PedalMe_w))
fixed_net_input <- 4
fixed_lags <- Pedalme_mindex
fixed_mindex
<- 0
total_length
for (i in seq_along(fixed_mindex)) {
<- total_length + length(fixed_mindex[[i]])
total_length
}
= total_length/(length(fixed_data[,])*0.8)
rate
<- data.frame(mrate = rate,
results_df mse = block_cal_mse(fixed_data, fixed_net_input, fixed_lags, fixed_mindex)[2])
results_df
WARNING: diagonal entries present in original matrix, these will be removed
mrate | total |
---|---|
<dbl> | <dbl> |
0.2941176 | 0.4916068 |
'dataset'] = 'Pedalme'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'block'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Pedalme_block_results
WikiMath
random
<- read.csv('./data/WikiMath.csv',header = TRUE) WikiMath
<-read.csv('./data/WikiMath_w.csv',header = FALSE)[2:1069,2:1069] WikiMath_w
<- as.matrix(WikiMath[,2:ncol(WikiMath)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(WikiMath_w))
fixed_net_input <- 8
fixed_lags
<- data.frame(mrate = numeric(),
results_df mse = numeric())
<- c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,0.8)
missing_rates
for (rate in missing_rates) {
<- cal_mse(fixed_data, fixed_net_input, fixed_lags, rate)
result <- rbind(results_df, data.frame(mrate = rate, mse = result[2]))
results_df
} results_df
mrate | total |
---|---|
<dbl> | <dbl> |
0.0 | 0.9022260 |
0.1 | 0.9015769 |
0.2 | 0.9015677 |
0.3 | 0.9112567 |
0.4 | 0.9576448 |
0.5 | 0.9042646 |
0.6 | 0.9465203 |
0.7 | 0.9607108 |
0.8 | 2.0823862 |
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.8)
- $each
-
- 0.716609198713466
- 0.33609587613803
- 1.53037835095656
- 0.571880746642037
- 0.679040279504007
- 0.86770944778941
- 0.94211227018673
- 1.23095352750805
- 0.255562766991466
- 1.41021788933164
- 1.11902155194291
- 0.120777688992921
- 0.351686917275931
- 1.03547247825773
- 0.387637099981085
- 1.67286280810398
- 0.645688480011486
- 1.0239900868632
- 0.470515111097122
- 1.39830664819096
- 0.527474807132737
- 0.8735963282032
- 3.91639405449372
- 0.809748710059726
- 1.52352969809872
- 0.954809969249318
- 0.59427155802543
- 1.07384103357951
- 1.16050099594077
- 0.812378842811124
- 0.0843670469492011
- 0.582886411165827
- 0.610941121703098
- 1.77501610902324
- 0.832188481120773
- 0.285547881469451
- 0.856793802022823
- 0.786179971570512
- 1.08285614539823
- 1.27673758653078
- 1.12110059423744
- 0.648071663993775
- 0.673979827782925
- 0.712715502627798
- 1.87262235868375
- 0.124200302121232
- 0.555950049342005
- 0.435166649123954
- 0.769617918273443
- 0.881959635622835
- 0.40965568736942
- 0.258821142109795
- 0.654369346322235
- 1.04090279257922
- 1.1061812648765
- 0.580818122343255
- 0.901648986229663
- 3.86663463586941
- 0.530337162741244
- 0.972110004768848
- 0.316786096508165
- 0.557853502271672
- 0.609346017318418
- 0.957185734279332
- 0.858951986864947
- 2.05441524669808
- 0.608148889786941
- 0.430581170395533
- 1.01848969890488
- 0.98091231232729
- 0.148007671286301
- 1.0140983318778
- 1.05590400538779
- 0.526744030480917
- 1.32274715512224
- 0.800076399591026
- 0.780419329492746
- 0.837919911530672
- 0.510269142256027
- 0.380425662220073
- 1.3354074181194
- 1.00353609488391
- 0.634746282337837
- 0.75538373153857
- 1.08267747622175
- 0.721353129770973
- 2.29833341248174
- 0.840687862825381
- 0.53197955558188
- 0.859597370162925
- 0.140911558911028
- 0.775918015624929
- 0.934127595127467
- 4.81659441445243
- 0.849270603708581
- 0.89518462647368
- 0.513747763885861
- 2.93268640121624
- 0.689600518459722
- 1.19716633239158
- 0.764706264091288
- 0.868973987146579
- 0.047803878277393
- 0.882096000730532
- 0.323349164491115
- 0.571788418695414
- 0.658809415081502
- 0.752118204284113
- 0.875370276588189
- 1.47330627824686
- 0.602764232570274
- 0.233449381706328
- 0.780511074509138
- 0.811033560447562
- 0.674502813846662
- 0.7035270579552
- 1.65561277428853
- 0.445694002432267
- 0.576280571354429
- 4.86089960991113
- 2.91953625762061
- 0.482472685195718
- 0.75937768636645
- 0.532684811665447
- 1.43877390431298
- 2.16968797831456
- 0.984545871282185
- 0.91300652208627
- 1.06506828687396
- 0.855820706557502
- 4.71409577579748
- 1.00157750328145
- 0.101630960191099
- 1.24809671179514
- 1.40404140237428
- 1.43001425203569
- 1.26345838051679
- 1.38900944820928
- 1.07859369234921
- 1.17680002849953
- 1.37956355323053
- 0.919415765822281
- 2.16635302006885
- 0.924647860287593
- 0.95160412994811
- 0.961890614683368
- 1.02526390898812
- 0.208856871449811
- 1.32637412731965
- 0.578110944837491
- 0.390815387419206
- 0.990828080366405
- 0.65009011038783
- 0.945613681421153
- 0.226257780983231
- 0.481419585393321
- 0.850413119654658
- 0.72740764355823
- 0.731942846393961
- 1.92466970254138
- 0.382486746204728
- 0.76315234207082
- 0.0718597166439553
- 0.689840302220608
- 0.725261906253108
- 2.19828457580681
- 0.713032222475787
- 1.06066009835845
- 0.950122183554527
- 0.832513810290847
- 1.06902081670756
- 1.07562044439096
- 1.10584501114595
- 1.22421444767378
- 1.13842887375702
- 1.13973299549623
- 0.230339952314396
- 1.11115013470241
- 0.46195868137291
- 1.10830054069493
- 1.29817313122251
- 1.48189061977968
- 0.80751856558624
- 1.21626445841625
- 0.741153133998466
- 0.203125911846464
- 0.176441956134648
- 1.57100644904887
- 0.966437057763941
- 1.14319556497267
- 0.42683159460263
- 0.0647526572400368
- 0.799270461868229
- 0.599104207041784
- 0.458284463056947
- 0.760188155933332
- 1.25520996051645
- 0.583448964829483
- 0.813062384305237
- 0.754284899404217
- ⋯
- 0.697955859318106
- 1.53669691458504
- 2.15427026921249
- 1.05215478575802
- 0.755996333589739
- 0.752391344045349
- 0.952999244134816
- 0.65022290631062
- 1.53130693382565
- 1.12748654628639
- 1.20101355963127
- 0.0309960306346116
- 0.944525884110296
- 1.10761766432827
- 0.75159012343607
- 0.896190135327401
- 0.994401883783327
- 1.04272794268577
- 1.13659142880185
- 0.0660217555838882
- 0.699505787828507
- 0.992829156878162
- 1.00644259533414
- 0.751505593277302
- 1.55225172014916
- 0.693480592173125
- 0.940830279548329
- 0.988240375939909
- 0.877339654041416
- 1.8235251154298
- 1.08650044617159
- 2.16099131770101
- 1.34855530956481
- 1.15891221923222
- 3.33667689311605
- 1.08364790578225
- 0.587025236923711
- 1.15126492545006
- 1.1006286052305
- 1.02170471989676
- 0.957584695293854
- 1.12917463081446
- 1.43451429818866
- 2.29768328517638
- 1.26495654234758
- 1.12700428127622
- 1.64870132771776
- 0.98970420928481
- 0.571926739880371
- 1.62611228891497
- 3.23341513250361
- 0.668506767349159
- 1.07165480982227
- 1.11966425997202
- 0.889983839323712
- 1.24165751028332
- 0.966998741092492
- 1.16278406509905
- 1.14097836096058
- 1.16522144346149
- 1.0860300190381
- 0.247258153630618
- 0.557565001553401
- 0.623533236941754
- 1.12342418170117
- 1.5662530469559
- 3.79612936903875
- 0.890922981852761
- 1.21709826359401
- 2.97377089052735
- 0.121058888506732
- 0.818712413769
- 1.55760969296228
- 0.983511868370858
- 1.42834253465713
- 0.921733315777211
- 1.43475256621052
- 3.05521455531098
- 1.62311927739587
- 0.950283562136222
- 0.868442377887097
- 0.976065423275205
- 1.0825975553536
- 1.18508081263065
- 1.4598259381772
- 0.979955186520481
- 0.538701552863407
- 0.560302846317376
- 0.852256196425593
- 0.0300515850478466
- 0.488045012537806
- 0.751230795407338
- 0.64773669434684
- 1.00260260215992
- 0.771623087693846
- 0.748727277845321
- 2.34971283879518
- 0.995665343619286
- 0.588550981672993
- 0.804453899499123
- 1.6505009570532
- 2.28619005542557
- 1.77678790956593
- 1.81424063290279
- 1.40194798042994
- 1.24860756789229
- 1.17171873015953
- 1.61764896527783
- 1.96787182948958
- 1.49340769589998
- 0.339972713394644
- 1.08263489564975
- 1.04456409052706
- 0.677565751940286
- 0.663654138266468
- 1.17761722029557
- 0.645235932540668
- 1.9706578676318
- 0.678863450562451
- 0.234007935845762
- 0.526479553352502
- 0.0618925072064546
- 0.657164807654459
- 0.970764689616877
- 1.82276552991008
- 1.1817841004251
- 1.23460918636633
- 0.208077108955954
- 0.769332625447758
- 1.19519699904218
- 0.630058052863272
- 0.213302594398992
- 0.733402264485352
- 1.23273490639081
- 0.829576664724567
- 1.38721343679162
- 0.99830304701413
- 2.32122057406262
- 0.922949061820402
- 0.879768028102588
- 0.802060420980154
- 0.762640473354771
- 1.00260902673512
- 0.880641658793471
- 0.730450466704234
- 0.921290521006903
- 1.02046008137591
- 0.869249656629914
- 0.397469310111113
- 0.99256260636637
- 1.34623152372177
- 1.3024012224266
- 1.11218317970622
- 0.512984037104919
- 1.14524041670286
- 1.9358048054551
- 1.04638149835417
- 0.702030711996353
- 0.0992750096847877
- 1.79196856023124
- 0.338303265368829
- 1.51159096558751
- 1.19710136273271
- 1.77819146141537
- 2.0189515577258
- 1.70834912264288
- 0.755020617721311
- 1.72113035592057
- 1.45949452351523
- 0.969483531581215
- 0.157800159186026
- 1.60326746487588
- 0.892675510555104
- 0.91589353977068
- 1.02158347282365
- 1.54213429744489
- 2.10179802757274
- 4.14301582046451
- 4.54408779433677
- 1.08628867684416
- 0.53056602036953
- 1.48744164551779
- 1.01136608836387
- 2.05227995737829
- 0.901246312316062
- 0.910533044323278
- 2.62245379674637
- 1.68613632105051
- 1.82987170071303
- 1.45787611888856
- 1.31785373680045
- 1.51940559359039
- 0.766634905868625
- 0.980903951366706
- 1.60991961277237
- 0.14880369415102
- 1.22030122763143
- 0.761199675590881
- 1.29544285764165
- 1.32105800531045
- $total
- 1.07726145079173
'dataset'] = 'Wikimath'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'rand'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Wikimath_results
block
<- fromJSON("./GNAR_weight_matrix/Wikimath_mindex.json") Wikimath_mindex
<- as.matrix(WikiMath[,2:ncol(WikiMath)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(WikiMath_w))
fixed_net_input <- 8
fixed_lags <- Wikimath_mindex
fixed_mindex
<- 0
total_length
for (i in seq_along(fixed_mindex)) {
<- total_length + length(fixed_mindex[[i]])
total_length
}
= total_length/(length(fixed_data[,])*0.8)
rate
<- data.frame(mrate = rate,
results_df mse = block_cal_mse(fixed_data, fixed_net_input, fixed_lags, fixed_mindex)[2])
results_df
mrate | total |
---|---|
<dbl> | <dbl> |
0.6002771 | 0.9083379 |
'dataset'] = 'Wikimath'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'block'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Wikimath_block_results
Windmillsmall
random
<-read.csv('./data/Windmillsmall.csv',header = TRUE) Windmillsmall
<-read.csv('./data/Windmillsmall_w.csv',header = FALSE)[2:12,2:12] Windmillsmall_w
계속 오류남;;
# fixed_data <- as.matrix(Windmillsmall[,2:ncol(Windmillsmall)])
# fixed_net_input <- GNAR::matrixtoGNAR(as.matrix(Windmillsmall_w))
# fixed_lags <- 8
# results_df <- data.frame(mrate = numeric(),
# mse = numeric())
# missing_rates <- c(0,0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,0.8)
# for (rate in missing_rates) {
# result <- cal_mse(fixed_data, fixed_net_input, fixed_lags, rate)
# results_df <- rbind(results_df, data.frame(mrate = rate, mse = result))
# }
# results_df
<- data.frame(
results_df mrate = c(0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0),
mse = c(0.980465007853614,0.980465007853614,0.980742615896619,0.980465007853614, 0.980529157673243, 0.980548927794843,0.980486712335988,0.980471934178215, 0.980486581012802)
)
'dataset'] = 'Windmillsmall'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'rand'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Windmillsmall_results
<- as.matrix(Windmillsmall[,2:ncol(Windmillsmall)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(Windmillsmall_w))
fixed_net_input <- 8 fixed_lags
WARNING: diagonal entries present in original matrix, these will be removed
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.8)[2]
$total = 0.980465007853614
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.7)[2]
$total = 0.980465007853614
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.6)[2]
$total = 0.980742615896619
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.5)[2]
$total = 0.980465007853614
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.4)[2]
$total = 0.980529157673243
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.3)[2]
$total = 0.980548927794843
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.2)[2]
$total = 0.980486712335988
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0.1)[2]
$total = 0.980471934178215
cal_mse(fixed_data, fixed_net_input, fixed_lags, 0)[2]
$total = 0.980486581012802
block
<- fromJSON("Windmillsmall_mindex.json") Windmillsmall_mindex
<- as.matrix(Windmillsmall[,2:ncol(Windmillsmall)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(Windmillsmall_w))
fixed_net_input <- 8
fixed_lags <- Windmillsmall_mindex
fixed_mindex
<- 0
total_length
for (i in seq_along(fixed_mindex)) {
<- total_length + length(fixed_mindex[[i]])
total_length
}
= total_length/(length(fixed_data[,])*0.8)
rate
<- data.frame(mrate = rate,
results_df mse = block_cal_mse(fixed_data, fixed_net_input, fixed_lags, fixed_mindex)[2])
results_df
WARNING: diagonal entries present in original matrix, these will be removed
mrate | total |
---|---|
<dbl> | <dbl> |
0.2861885 | 0.9804698 |
'dataset'] = 'Windmillsmall'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'block'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df Windmillsmall_block_results
MontevideoBus
random
<-read.csv('./data/MontevideoBus.csv',header = TRUE) MontevideoBus
<-read.csv('./data/MontevideoBus_w.csv',header = FALSE)[2:676,2:676] MontevideoBus_w
<- as.matrix(MontevideoBus[,2:ncol(MontevideoBus)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(MontevideoBus_w))
fixed_net_input <- 8
fixed_lags
<- data.frame(mrate = numeric(),
results_df mse = numeric())
<- c(0,0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,0.8)
missing_rates
for (rate in missing_rates) {
<- cal_mse(fixed_data, fixed_net_input, fixed_lags, rate)
result <- rbind(results_df, data.frame(mrate = rate, mse = result[2]))
results_df
} results_df
mrate | total |
---|---|
<dbl> | <dbl> |
0.0 | 1.002868 |
0.1 | 1.002744 |
0.2 | 1.002750 |
0.3 | 1.002771 |
0.4 | 1.001533 |
0.5 | 1.002278 |
0.6 | 1.002135 |
0.7 | 1.003126 |
0.8 | 1.003196 |
'dataset'] = 'MontevideoBus'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'rand'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df MontevideoBus_results
block
<- fromJSON("MontevideoBus_mindex.json") MontevideoBus_mindex
<- as.matrix(MontevideoBus[,2:ncol(MontevideoBus)])
fixed_data <- GNAR::matrixtoGNAR(as.matrix(MontevideoBus_w))
fixed_net_input <- 8
fixed_lags <- MontevideoBus_mindex
fixed_mindex
<- 0
total_length
for (i in seq_along(fixed_mindex)) {
<- total_length + length(fixed_mindex[[i]])
total_length
}
= total_length/(length(fixed_data[,])*0.8)
rate
<- data.frame(mrate = rate,
results_df mse = block_cal_mse(fixed_data, fixed_net_input, fixed_lags, fixed_mindex)[2])
results_df
mrate | total |
---|---|
<dbl> | <dbl> |
0.1495439 | 1.002894 |
'dataset'] = 'MontevideoBus'
results_df['method'] = 'GNAR'
results_df['mtype'] = 'block'
results_df['lags'] = fixed_lags
results_df['nof_filters'] = NA
results_df['inter_method'] = NA
results_df['epoch'] = NA
results_df['calculation_time'] = NA
results_df['model'] = 'GNAR'
results_df[colnames(results_df)[2] <- "mse"
<- results_df MontevideoBus_block_results
Final Data
rbind(FiveVTS_results,Chickenpox_results,Pedalme_results,Wikimath_results,Windmillsmall_results,MontevideoBus_results)
mrate | mse | dataset | method | mtype | lags | nof_filters | inter_method | epoch | calculation_time | model |
---|---|---|---|---|---|---|---|---|---|---|
<dbl> | <dbl> | <chr> | <chr> | <chr> | <dbl> | <lgl> | <lgl> | <lgl> | <lgl> | <chr> |
0.0 | 1.2577286 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.1 | 1.2527354 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.2 | 1.2655242 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.3 | 1.2509369 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.4 | 1.2714016 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.5 | 1.2787071 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.6 | 1.3015036 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.7 | 1.3015036 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.8 | 1.3015036 | FiveVTS | GNAR | rand | 2 | NA | NA | NA | NA | GNAR |
0.0 | 1.0163418 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.1 | 1.0164596 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.2 | 1.0158452 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.3 | 1.0184809 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.4 | 1.0208430 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.5 | 1.0191585 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.6 | 1.0216003 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.7 | 1.0214110 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.8 | 1.0200845 | Chickenpox | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.0 | 0.5016028 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.1 | 0.4971018 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.2 | 0.5027820 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.3 | 0.5148579 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.4 | 0.5226205 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.5 | 0.5917800 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.6 | 0.4917371 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.7 | 0.4917371 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.8 | 0.4917371 | Pedalme | GNAR | rand | 4 | NA | NA | NA | NA | GNAR |
0.0 | 0.9022260 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.1 | 0.9015769 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.2 | 0.9015677 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.3 | 0.9112567 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.4 | 0.9576448 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.5 | 0.9042646 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.6 | 0.9465203 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.7 | 0.9607108 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.8 | 1.0772615 | Wikimath | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.8 | 0.9804650 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.7 | 0.9804650 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.6 | 0.9807426 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.5 | 0.9804650 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.4 | 0.9805292 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.3 | 0.9805489 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.2 | 0.9804867 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.1 | 0.9804719 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.0 | 0.9804866 | Windmillsmall | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.0 | 1.0028680 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.1 | 1.0027435 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.2 | 1.0027498 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.3 | 1.0027708 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.4 | 1.0015333 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.5 | 1.0022778 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.6 | 1.0021350 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.7 | 1.0031262 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
0.8 | 1.0031961 | MontevideoBus | GNAR | rand | 8 | NA | NA | NA | NA | GNAR |
rbind(FiveVTS_block_results,Chickenpox_block_results,Pedalme_block_results,Wikimath_block_results,Windmillsmall_block_results,MontevideoBus_block_results)
mrate | mse | dataset | method | mtype | lags | nof_filters | inter_method | epoch | calculation_time | model |
---|---|---|---|---|---|---|---|---|---|---|
<dbl> | <dbl> | <chr> | <chr> | <chr> | <dbl> | <lgl> | <lgl> | <lgl> | <lgl> | <chr> |
0.12500000 | 1.2723690 | FiveVTS | GNAR | block | 2 | NA | NA | NA | NA | GNAR |
0.28846154 | 1.0171190 | Chickenpox | GNAR | block | 4 | NA | NA | NA | NA | GNAR |
0.29411765 | 0.4916068 | Pedalme | GNAR | block | 4 | NA | NA | NA | NA | GNAR |
0.12024781 | 0.9009986 | Wikimath | GNAR | block | 8 | NA | NA | NA | NA | GNAR |
0.03252143 | 0.9804863 | Windmillsmall | GNAR | block | 8 | NA | NA | NA | NA | GNAR |
0.14954389 | 1.0028939 | MontevideoBus | GNAR | block | 8 | NA | NA | NA | NA | GNAR |
<- rbind(FiveVTS_results,Chickenpox_results,Pedalme_results,Wikimath_results,Windmillsmall_results,MontevideoBus_results,
final_df FiveVTS_block_results,Chickenpox_block_results,Pedalme_block_results,Wikimath_block_results,Windmillsmall_block_results,MontevideoBus_block_results)
write.csv(final_df, file = "./R_GNAR_results.csv", row.names = FALSE)