I have a time series data having more than one record in a single date. Number of records in a single date is not consistent.

I have 3 input features namely phrase, cost and weight. My goal is to predict 'Cost'. I have used Keras texts_to_sequences to deal with the text input 'phrase' column.

I have following concerns

  1. how to incorporate Phrase column in the LSTM model
  2. how to deal with multiple records in a single date
  3. what will be the shape of input data
  4. How do I structure the model like 1st layer to be Embedding layer, 2nd to Dense and so on.

Here is the sample of the data:

enter image description here

Here is the processed data:

enter image description here

Kindly assist me.

  • $\begingroup$ I think you should pivot the data so you have one row per date then use the columns as features. The phrases can be tokenized for each phrase column $\endgroup$ Jul 26, 2022 at 15:21

1 Answer 1

  1. Your phrases are very short, you will be fine with a bag of words encoding instead of sequence.

2-3. If you want total cost over day prediction, you can just sum all the features including BoW per date and then do time series prediction on the resulting data.

  1. Try just LSTM predicting next date from the sequence of past dates
  • $\begingroup$ Predicting 'Cost' on specific 'phrase' is a requirement, if I aggregate it on a date, then I will loose both input and output $\endgroup$ Oct 22, 2019 at 14:33

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.