preprocess_timeseries_data: Preprocess time series data prepare for learning bayesian...

Description Usage Arguments Value Examples

View source: R/main.R

Description

Preprocess time series data prepare for learning bayesian network

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
preprocess_timeseries_data(
  data,
  type,
  time_column,
  continuous_variable_names,
  discrete_variable_names,
  desire_layers,
  normalize_type = NULL,
  quantile_number = -1,
  na_omit = TRUE
)

Arguments

data

A data frame, each row is a time value and observations

type

Bayesian network type, "discrete" or "continuous"

time_column

Column name of "data", which values is time stamp

continuous_variable_names

Column names of continuous variables

discrete_variable_names

Column names of discrete variables

desire_layers

Number layers of bayesian network, at least is 2

normalize_type

Normalization type for continuous variables, "mean_normalization", "min_max" or "standardisation"

quantile_number

Number of quantile level for type "discrete"

na_omit

If true, NA/NaN values will be omit after preprocess

Value

An object with pre-processsed data and preprocess parameters

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
library(wrmbn)

data("data")
data("structure")

uncorelate_node <- c("MTL", "QMX", "HCL", "CMB", "CTL", "CDX", "CBT")
for(node in uncorelate_node) {
 data <- data[, -which(colnames(data) == node)]
}

for(node in uncorelate_node) {
  if(length(which(structure$from == node)) > 0) {
    structure <- structure[-which(structure$from == node), ]
  } else if(length(which(structure$to == node)) > 0) {
    structure <- structure[-which(structure$to == node), ]
  }
}
type <- "continuous"
time_column <- "date"
continuous_variable_names <- setdiff(colnames(data), time_column)
discrete_variable_names <- c()
desire_layers <- 3
normalize_type <- "mean_normalization"
preprocessed <- preprocess_timeseries_data(data, type, time_column,
                                           continuous_variable_names, discrete_variable_names, desire_layers,
                                           normalize_type, quantile_number = -1, na_omit = TRUE)

bayes-modeling/wrmbn documentation built on Dec. 19, 2021, 6:45 a.m.