set.seed(123) # Setting a seed for reproducibility
data_part1 <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.7, 0.3))
# Introduce a change in data distribution
data_part2 <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.3, 0.7))
# Combine the two parts
data_stream <- c(data_part1, data_part2)
# Initialize the hddm_a object
hddm_a_instance <- HDDM_A$new()
# Iterate through the data stream
for(i in seq_along(data_stream)) {
hddm_a_instance$add_element(data_stream[i])
if(hddm_a_instance$warning_detected) {
message(paste("Warning detected at index:", i))
}
if(hddm_a_instance$change_detected) {
message(paste("Concept drift detected at index:", i))
}
}
Run the code above in your browser using DataLab