Project

General

Profile

« Previous | Next » 

Revision bd5b6cd5

Added by Benoit Parmentier over 11 years ago

raster prediction script, adding recording of training metric fits for paper analyses

View differences:

climate/research/oregon/interpolation/GAM_fusion_analysis_raster_prediction_multisampling.R
311 311
  
312 312
  #################### ASSESSMENT OF PREDICTIONS: PLOTS OF ACCURACY METRICS ###########
313 313
  
314
  ##Create data.frame with valiation metrics for a full year
315
  tb_diagnostic_v<-extract_from_list_obj(validation_mod_obj,"metrics_v")
314
  ##Create data.frame with validation and fit metrics for a full year/full numbe of runs
315
  tb_diagnostic_v<-extract_from_list_obj(validation_mod_obj,"metrics_v") 
316
  #tb_diagnostic_v contains accuracy metrics for models sample and proportion for every run...if full year then 365 rows maximum
316 317
  rownames(tb_diagnostic_v)<-NULL #remove row names
318
  tb_diagnostic_v$method_interp <- interpolation_method
319
  tb_diagnostic_s<-extract_from_list_obj(validation_mod_obj,"metrics_s")
320
  rownames(tb_diagnostic_s)<-NULL #remove row names
321
  tb_diagnostic_s$method_interp <- interpolation_method #add type of interpolation...out_prefix too??
317 322
  
318 323
  #Call functions to create plots of metrics for validation dataset
319 324
  metric_names<-c("rmse","mae","me","r","m50")
320
  summary_metrics_v<- boxplot_from_tb(tb_diagnostic_v,metric_names,out_prefix,out_path)
325
  summary_metrics_v<- boxplot_from_tb(tb_diagnostic_v,metric_names,out_prefix,out_path) #if adding for fit need to change outprefix
321 326
  names(summary_metrics_v)<-c("avg","median")
322 327
  summary_month_metrics_v<- boxplot_month_from_tb(tb_diagnostic_v,metric_names,out_prefix,out_path)
323 328
  
......
338 343
  
339 344
  if (interpolation_method %in% c("gam_CAI","kriging_CAI","gwr_CAI","gam_fusion","kriging_fusion","gwr_fusion")){
340 345
    raster_prediction_obj<-list(clim_method_mod_obj,method_mod_obj,validation_mod_obj,tb_diagnostic_v,
341
                                summary_metrics_v,summary_month_metrics_v)
346
                                tb_diagnostic_s,summary_metrics_v,summary_month_metrics_v)
342 347
    names(raster_prediction_obj)<-c("clim_method_mod_obj","method_mod_obj","validation_mod_obj","tb_diagnostic_v",
343
                                    "summary_metrics_v","summary_month_metrics_v")  
348
                                    "tb_diagnostic_s","summary_metrics_v","summary_month_metrics_v")  
344 349
    save(raster_prediction_obj,file= file.path(out_path,paste("raster_prediction_obj_",interpolation_method,"_", y_var_name,out_prefix,".RData",sep="")))
345 350
    
346 351
  }
......
348 353
  #use %in% instead of "|" operator
349 354
  if (interpolation_method=="gam_daily" | interpolation_method=="kriging_daily" | interpolation_method=="gwr_daily"){
350 355
    raster_prediction_obj<-list(method_mod_obj,validation_mod_obj,tb_diagnostic_v,
351
                                summary_metrics_v,summary_month_metrics_v)
356
                                tb_diagnostic_s,summary_metrics_v,summary_month_metrics_v)
352 357
    names(raster_prediction_obj)<-c("method_mod_obj","validation_mod_obj","tb_diagnostic_v",
353
                                    "summary_metrics_v","summary_month_metrics_v")  
358
                                    "tb_diagnostic_s","summary_metrics_v","summary_month_metrics_v")  
354 359
    save(raster_prediction_obj,file= file.path(out_path,paste("raster_prediction_obj_",interpolation_method,"_", y_var_name,out_prefix,".RData",sep="")))
355 360
    
356 361
  }

Also available in: Unified diff