I am trying to Predict Sum of the Sequence based on flag but my model is not able to converge.

for each time stamp, include the first element in sum if second number is 1 in Sequence.



Output Should be:


Which model should I use? I am trying lstm using tflearn but result doesn't seems to be good.

  • $\begingroup$ Treat these as four features and try LinearRegression. Add interaction features. It will converge. Then remove low importance features. Only AB and CD should come out as important features. Coeff. should come around 1. $\endgroup$
    – 10xAI
    Commented Jul 28, 2021 at 12:54
  • $\begingroup$ Actually this is a sample task... In original problem I have 10 TimeStep with size 24 at each step. However output will depend only on 2 feature at each timestamp. $\endgroup$
    – Anup Patel
    Commented Jul 28, 2021 at 13:52

1 Answer 1


Why don't you use mathematical operations to solve your problem?

[[50,1],[40,0]] becomes 50x1 + 40x0 = 50
[[150,1],[4,1]] becomes 150x1 + 41x0 = 154 etc.

To summarize, a function like:

[[A,B],[C,D]] becomes AxB + CxD

  • $\begingroup$ This is a downsample task. I am trying to solve a bigger problem and for that we need a good prediction model so that it can predict sum of sequences based on flag value $\endgroup$
    – Anup Patel
    Commented Jul 28, 2021 at 13:54
  • $\begingroup$ Understood. Have you tried a random forest? I could take different situations with flags, it could be a good solution. $\endgroup$ Commented Jul 28, 2021 at 14:34

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.