Skip to content

Commit

Permalink
Revert joining clean-up attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Apr 15, 2024
1 parent 7b24332 commit 7ef6b54
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions docker-resources/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,10 @@ function(

# run the predictions
# TODO Why does this seem to claim we're running in train / validate mode?
maybe_o2_delete <- function (obj) {
if (is.h2o(obj)) h2o.rm(obj)
}

results_adults_h2o <- results_adults <- h2o.predict(ml_model_adult, h2o_predict_frame_adults)
on.exit(maybe_o2_delete(results_adults_h2o))
results_minors_h2o <- results_minors <- h2o.predict(ml_model_minor, h2o_predict_frame_minors)
on.exit(maybe_o2_delete(results_adults_h2o))

results_adults <- as.data.frame(results_adults)
results_minors <- as.data.frame(results_minors)
results_adults <- h2o.predict(ml_model_adult, h2o_predict_frame_adults)
on.exit(h2o.rm(results_adults))
results_minors <- h2o.predict(ml_model_minor, h2o_predict_frame_minors)
on.exit(h2o.rm(results_minors))

# for the case where we need this, it should be safe to assume
# that the start week has the correct values
Expand All @@ -142,6 +135,7 @@ function(
# enrich the table of predictors with the results
prediction_results_adults <- predictors %>%
filter(Age >= 18) %>%
bind_cols(as.data.frame(results_adults)) %>%
left_join(results_adults, by = join_by(person_id, encounter_id, location_id)) %>%
# reduce data frame and rename the result
select(person_id, encounter_id, location_id, rtc_date, predicted_prob_disengage = Disengaged) %>%
Expand All @@ -159,6 +153,7 @@ function(

prediction_results_minors <- predictors %>%
filter(Age < 18) %>%
bind_cols(as.data.frame(results_minors)) %>%
left_join(results_minors, by = join_by(person_id, encounter_id, location_id)) %>%
# reduce data frame and rename the result
select(person_id, encounter_id, location_id, rtc_date, predicted_prob_disengage = Disengaged) %>%
Expand Down

0 comments on commit 7ef6b54

Please sign in to comment.