Skip to content

Improve performance of PostnatalSupervisor#1836

Open
tamuri wants to merge 3 commits intomasterfrom
tamuri/postnatal-supervisor-perf
Open

Improve performance of PostnatalSupervisor#1836
tamuri wants to merge 3 commits intomasterfrom
tamuri/postnatal-supervisor-perf

Conversation

@tamuri
Copy link
Copy Markdown
Collaborator

@tamuri tamuri commented Mar 1, 2026

@joehcollins - the previous code for predict_early_onset_neonatal_sepsis_week_1 allowed operating on multiple individuals but it looks like it is only called by apply_risk_of_neonatal_complications_in_week_one for single individuals. I've updated the both caller and callee in light of that.

Improve performance by reducing unnecessary data access:

  • don't convert mother+newborn info dictionaries to dataframe (we only need one entry)
  • don't create unnecessary series/dataframes
  • get only the required properties for the model's predict function
  • update predict function to operate on single individual

Also optimised PostnatalWeekOneMaternalEvent.apply() by removing unnecessary data access.

- don't convert mother+newborn info dictionaries to dataframe (we only need one entry)
- don't create unnecessary series/dataframes
- get only the required properties for the model's predict function
- update predict function to operate on single individual
@tamuri tamuri requested a review from joehcollins March 1, 2026 22:35
@tamuri tamuri changed the title Improve performance PostnatalSupervisor's apply_risk_of_neonatal_complications_in_week_one Improve performance of PostnatalSupervisor apply_risk_of_neonatal_complications_in_week_one Mar 2, 2026
@tamuri tamuri changed the title Improve performance of PostnatalSupervisor apply_risk_of_neonatal_complications_in_week_one Improve performance of PostnatalSupervisor Mar 2, 2026
… reducing data access

- Access mother_and_newborn_info dict directly per person instead of DataFrame
- Build Series from lists rather than creating intermediate DataFrames
- Remove redundant Series wrapper for DataFrame column access
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant