Skip to content

Commit

Permalink
Attempt to move conversion to data frame earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Apr 15, 2024
1 parent 7ef6b54 commit 9ad4e0d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docker-resources/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ function(
results_minors <- h2o.predict(ml_model_minor, h2o_predict_frame_minors)
on.exit(h2o.rm(results_minors))

results_adults_df <- as.data.frame(results_adults)
results_minors_df <- as.data.frame(results_minors)

# for the case where we need this, it should be safe to assume
# that the start week has the correct values
cohort <- clock::date_format(clock::add_weeks(start_date, -1), format="%Y-W%U")

# 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)) %>%
bind_cols(results_adults_df) %>%
# reduce data frame and rename the result
select(person_id, encounter_id, location_id, rtc_date, predicted_prob_disengage = Disengaged) %>%
# calculate the patient's risk category
Expand All @@ -153,8 +155,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)) %>%
bind_cols(results_minors_df) %>%
# reduce data frame and rename the result
select(person_id, encounter_id, location_id, rtc_date, predicted_prob_disengage = Disengaged) %>%
# calculate the patient's risk category
Expand Down

0 comments on commit 9ad4e0d

Please sign in to comment.