I have a dataset with patient demographics, diagnosis history, hospital visit dates, drugs consumed etc.

All these events have time stamp information (except static info like demographics such gender, age, education etc).

My objective is to predict the next 3 visits to hospitals and risk factors for his next 3 visits based on his previous hospital records such as visit information, drug information, demographics, diagnosis information etc.

Can experts here let me know the list of steps that I need to follow so I can learn and try to achieve my project objective?


1 Answer 1


you need to define how many time steps you want to have in each time series block. then for each unique patient, you need to create these blocks so the training set going to be a 3D matrix, and the dimensions are:

number of blocks * number of time steps * number of features

in addition to time series data, you can also add another head to feed NN with the constant data like patient id, day of the week, and ...

for the time series part, you can use biLSTM or biGRU or and other RNN layers and then a Dense layer and then concatanate the results with the results coming from constant features.

for the output, you can also use an RNN layer to predict the sequence of future visits or simply use Dense layers.


consider below flow chart

if your other features (like drugs, lab tests) don't have the same time structure, consider it as groups of time series and for each one add other heads along with RNNs with different input shapes (for the number of time steps). the key is to bring all your features to the latent space and from there, do the decoding and predict the sequence of the future. enter image description here

  • $\begingroup$ hi, thanks upvoted. For ex: My visit data has columns like patient_id, visit_datetime, visit_reason, visit_type... for ex: Patient XYZ visited hospital on 12th Jan 2018 where he was diagnosed for 3 conditions such as high bp, neck pain, diabetes`... Similarly I have multiple records for same patient. So how do I prepare my dataset for ML problem? The above example was only for visit. bit I also have similar structured data for drugs, lab tests etc $\endgroup$
    – The Great
    May 4, 2021 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.