Skip to content

Commit

Permalink
Impoved first task
Browse files Browse the repository at this point in the history
  • Loading branch information
jovoni committed Aug 22, 2024
1 parent 3f55637 commit 0602d0e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/fit_task0.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ find_breakpoints = function(d, avg_points_per_window, max_breakpoints, norm, n_t

max_breakpoints = min(max_breakpoints, as.integer(length(x) / avg_points_per_window))
available_breakpoints <- 1:max_breakpoints
message("Initial proposals")
message("Intializing breakpoints")
proposed_breakpoints <- parallel::mclapply(available_breakpoints, FUN = function(n_breakpoints) {
print(n_breakpoints)
convergence <<- FALSE
Expand Down Expand Up @@ -200,11 +200,12 @@ find_breakpoints = function(d, avg_points_per_window, max_breakpoints, norm, n_t
}

m <- biPOD:::get_model("fit_breakpoints")
message("Proposals' optimization")
message("Breakpoints optimization")
fits <- list()
plots <- list()
proposed_breakpoints$idx <- c(1:nrow(proposed_breakpoints)) + 1


loos <- lapply(0:nrow(proposed_breakpoints), function(j) {
#print(j)
if (j == 0) {
Expand Down Expand Up @@ -268,6 +269,8 @@ find_breakpoints = function(d, avg_points_per_window, max_breakpoints, norm, n_t
return(list(best_bp=NULL, best_fit=NULL))
}

message("Choosing optimal breakpoints")

bic_comp <- dplyr::tibble(bic = loos, n_breakpoints = 1:length(loos) - 1)
best_j <- bic_comp %>%
dplyr::filter(bic == min(bic)) %>%
Expand Down

0 comments on commit 0602d0e

Please sign in to comment.