impute_with_model: impute invalid data with defined model

Description Usage Arguments Examples

Description

impute invalid data with models created by define_model_rf

Usage

1
2
3
4
impute_with_model(db, id, rmsle_max = 0.03, h2o_port = 54321,
  h2o_ip = "localhost")

update_learning_db(db, target = "CTY")

Arguments

db

aggregated load dataset

id

model id

rmsle_max

error max of a model, if less, model will be used to replace invalid data.

h2o_port

port number of the H2O server

h2o_ip

IP address of the server where H2O is running

target

to be removed, model target

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
load_dir <- "/Users/davidgohel/Documents/consulting/RTE/load_files"

load_data <- anta_load(data_dir = load_dir )
load_data <- augment_validation(load_data)

aggregated_db <- agg_data(load_data)
aggregated_db <- augment_validation(aggregated_db)
aggregated_db <- data_correct_with_rules(aggregated_db)
aggregated_db <- augment_process_summary(aggregated_db)

dat <- as_learning_db(aggregated_db )

x_vars <- c(
  "year.iso", "week.iso", "hour.iso",
  "day.iso", "light_time", "is_off", "likely_off",
  "DAILY_MIN_CTY_MINUS_1", "DAILY_AVG_CTY_MINUS_1", "DAILY_MAX_CTY_MINUS_1",
  "HOUR_SHIFT_CTY_MINUS_1")

dat <- define_model_rf( data = dat, x_vars = x_vars, y_var = "CTY",
                        save_model_dir = file.path( getwd(), "ttt"),
                        id = "BACKWARD" )

x_vars <- c(
  "year.iso", "week.iso", "hour.iso", "day.iso", "light_time",
  "is_off", "likely_off", "DAILY_MIN_CTY_PLUS_1",
  "DAILY_AVG_CTY_PLUS_1", "DAILY_MAX_CTY_PLUS_1", "HOUR_SHIFT_CTY_PLUS_1")

dat <- define_model_rf( data = dat, x_vars = x_vars, y_var = "CTY",
                        save_model_dir = file.path( getwd(), "ttt"),
                        id = "FORWARD" )
for(i in 1:10 ){
  dat <- impute_with_model(dat, id = "FORWARD")
  dat <- impute_with_model(dat, id = "BACKWARD")
  dat <- update_learning_db(dat)
}

## End(Not run)

rte-antares-rpackage/antaDraft documentation built on May 14, 2019, 2:59 p.m.