Search code examples
pythondeep-learningjupyter-notebooklstmforecasting

Different time points for deep learning model inputs


I want to ask if it is possible to create a model where I have 2 inputs, which are Temperature and Status, but the inputs start at different times? For example, the temperature starts at t=0 and the status starts at t=1. The output for this model will only be the temperature at t=15. I'm really new to deep learning and really appreciate the guidance.

This is my dataset example. Below is the model that I currently have,

def df_to_X_y(df, window_size=15):
  df_as_np = df.to_numpy()
  X = []
  y = []
  for i in range(len(df_as_np)-window_size):
    row = [r for r in df_as_np[i:i+window_size]]
    X.append(row)
    label = [df_as_np[i+window_size][0]]
    y.append(label)
  return np.array(X), np.array(y)

How do I change this model to take in the temperature starts at t=0 but the status starts at t=1?


Solution

  • I think to solve this issue we have to change the df in a way 'Z1_S1(degC)' starts at t=0 and 'Status' starts at t=1, so we will define a new df as follows:

    new_df=pd.DataFrame({'Z1_S1(degC)': [df['Z1_S1(degC)'][i] for i in range(len(df)-1)],   #last value not included
                         'Status': [df['Status'][i] for i in range(1, len(df))]             #first value not included
                        })
    

    And we continue the remaining piece of code:

    def df_to_X_y(df, window_size=15):
      df_as_np = df.to_numpy()
      X = []
      y = []
      for i in range(len(df_as_np)-window_size):
        row = [r for r in df_as_np[i:i+window_size]]
        X.append(row)
        label = [df_as_np[i+window_size][0]]
        y.append(label)
      return np.array(X), np.array(y)
    

    And we apply the function to the new_df instead of df

    X, y = df_to_X_y(new_df, window_size=15)