Time series prediction for multiple columns

Hi Knimers,

I am new to Knime and have been struggling to do time series prediction for multiple columns. I have close to 100 different products and the percentage sales data for current week Day-1, Day-2 and Day-3. I wish to predict the % sales on Day-7 current week, however in my data set, I have also provided the actual % sales on Day-7 current week, this is just to see how close are the predictions to the actuals. Ideally we need not use the Day-7 actuals while performing the data analysis and predictions, just want to keep it for the last, to compare my predictions with the actuals.

The % sales current week is basically the % of the sales that was made on Day-7 of Last week. In the dataset the percentage has been expressed in decimal terms.

I specifically wanted to use Keras LSTM network as it works best with time series data. Could someone please provide some guidance. I have also attached my data file herein.
Project Data.csv (3.3 KB)

Hello @mlauber71, could you please help me with this. Below is a snapshot of the workflow I have put together by referring to various posts but may be I am not configuring the nodes properly or my network architecture is not configured properly. Whatever the reason is, I am not able to generate the predictions. Would really appreciate your help on this.

Hover over the triangle. It should tell you more about the problem

Thanks @Daniel_Weikert ,I tried experimenting with the network architecture to get rid of the triangle and initially used the following architecture:


and the following configurations:




All the other configuration parameters were left at the default settings. However, the Keras network learner node recorded the following error in the log file:
β€œ2024-03-14 10:57:13,211 : ERROR : KNIME-Worker-5-Keras Network Learner 3:17 : : Node : Keras Network Learner : 3:17 : Execute failed: An error occured during training of the Keras deep learning network. See log for details.
java.lang.RuntimeException: An error occured during training of the Keras deep learning network. See log for details.
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.handleGeneralException(DLKerasLearnerNodeModel.java:751)
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.executeInternal(DLKerasLearnerNodeModel.java:721)
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.execute(DLKerasLearnerNodeModel.java:320)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:588)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1297)
at org.knime.core.node.Node.execute(Node.java:1059)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:595)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:98)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:201)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:117)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:367)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:221)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
Caused by: java.io.IOException: java.lang.ClassCastException: class org.knime.core.data.MissingCell cannot be cast to class org.knime.core.data.DoubleValue (org.knime.core.data.MissingCell and org.knime.core.data.DoubleValue are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @2c2a903f)
at org.knime.dl.python.core.DLPythonAbstractCommands.trainNetwork(DLPythonAbstractCommands.java:555)
at org.knime.dl.python.core.training.DLPythonAbstractNetworkTrainingSession.trainInternal(DLPythonAbstractNetworkTrainingSession.java:193)
at org.knime.dl.core.training.DLAbstractNetworkTrainingSession.run(DLAbstractNetworkTrainingSession.java:273)
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.executeInternal(DLKerasLearnerNodeModel.java:712)
… 14 more
Caused by: java.lang.ClassCastException: class org.knime.core.data.MissingCell cannot be cast to class org.knime.core.data.DoubleValue (org.knime.core.data.MissingCell and org.knime.core.data.DoubleValue are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @2c2a903f)
at org.knime.dl.core.data.convert.DLDoubleValueToFloatTensorConverterFactory$1.convert(DLDoubleValueToFloatTensorConverterFactory.java:95)
at org.knime.dl.core.data.convert.DLCollectionDataValueToTensorConverterFactory$1.convertInternal(DLCollectionDataValueToTensorConverterFactory.java:118)
at org.knime.dl.core.data.convert.DLCollectionDataValueToTensorConverterFactory$1.convertInternal(DLCollectionDataValueToTensorConverterFactory.java:1)
at org.knime.dl.core.data.convert.DLAbstractTensorDataValueToTensorConverter.convert(DLAbstractTensorDataValueToTensorConverter.java:78)
at org.knime.dl.core.DLAbstractKnimeNetworkInputPreparer.writeDataValuesInTensors(DLAbstractKnimeNetworkInputPreparer.java:110)
at org.knime.dl.core.training.DLKnimeNetworkTrainingInputPreparer.prepare(DLKnimeNetworkTrainingInputPreparer.java:109)
at org.knime.dl.core.training.DLAbstractNetworkTrainingSession$1.get(DLAbstractNetworkTrainingSession.java:193)
at org.knime.dl.python.core.DLPythonAbstractCommands$DLPythonNetworkTrainingTaskHandler.handleTrainingDataRequest(DLPythonAbstractCommands.java:1052)
at org.knime.dl.python.core.DLPythonAbstractCommands$DLPythonNetworkTrainingTaskHandler.handleCustomMessage(DLPythonAbstractCommands.java:1020)
at org.knime.dl.keras.core.DLKerasAbstractCommands$DLKerasNetworkTrainingTaskHandler.handleCustomMessage(DLKerasAbstractCommands.java:284)
at org.knime.python2.kernel.messaging.AbstractTaskHandler.handle(AbstractTaskHandler.java:95)
at org.knime.dl.python.core.DLPythonAbstractCommands$DLTrainingTask.runInternal(DLPythonAbstractCommands.java:931)
at org.knime.core.util.ThreadUtils$CallableWithContextImpl.callWithContext(ThreadUtils.java:383)
at org.knime.core.util.ThreadUtils$CallableWithContext.call(ThreadUtils.java:269)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
2024-03-14 10:57:13,218 : WARN : KNIME-Worker-5-Keras Network Learner 3:17 : : Node : Keras Network Executor : 3:26 : Selected output β€˜dense_5_0:0’ could not be found in the input deep learning network. Please reconfigure the node.”

Please note: I reduced my original data to just include 4 products.

Next, I tried changing the network architecture to the following:
image
and the following error showed up in Keras LSTM Layer node:
Invalid input specs. Expected an input with shape [time, input_dim].

LSTM requires a certain input shape. From your picture I see only β€œ12”
Maybe the node description for LSTM tells you how to specifiy the tuple correctly in KNIME for the input node feeding into LSTM
br

1 Like

@Daniel_Weikert , thanks for pointing this out. I rectified my input shape to 3,1, which represented 3 timestamps and 1 feature, this made my network architecture green but my network learner node is still giving me errors in the log. Presently, I am getting the following error:

2024-03-16 00:36:18,211 : ERROR : KNIME-Worker-8-Keras Network Learner 3:17 : : Node : Keras Network Learner : 3:17 : Execute failed: An error occured during training of the Keras deep learning network. See log for details.
java.lang.RuntimeException: An error occured during training of the Keras deep learning network. See log for details.
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.handleGeneralException(DLKerasLearnerNodeModel.java:751)
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.executeInternal(DLKerasLearnerNodeModel.java:721)
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.execute(DLKerasLearnerNodeModel.java:320)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:588)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1297)
at org.knime.core.node.Node.execute(Node.java:1059)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:595)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:98)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:201)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:117)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:367)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:221)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
Caused by: java.lang.IllegalArgumentException: The input shape does not match the tensor shape. [12] vs. [3, 1]
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:146)
at org.knime.dl.util.DLUtils$Shapes.calculateExecutionShape(DLUtils.java:411)
at org.knime.dl.core.DLExecutionSpecCreator.createExecutionTensorSpec(DLExecutionSpecCreator.java:97)
at org.knime.dl.core.DLExecutionSpecCreator.createExecutionSpecs(DLExecutionSpecCreator.java:80)
at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.executeInternal(DLKerasLearnerNodeModel.java:700)
… 14 more