将数组与在for循环python中创建的新数组连接起来

将数组与在for循环python中创建的新数组连接起来,python,arrays,numpy,for-loop,concatenation,Python,Arrays,Numpy,For Loop,Concatenation,我有以下类型的数据,我正在做预测: Input: 1 | 2 | 3 | 4 | 5 1 | 2 | 3 | 4 | 5 1 | 2 | 3 | 4 | 5 Output: 6 7 8 我希望一次预测一个,并将其作为最后一列的值反馈给输入。我使用此功能,但效果不佳: def moving_window(num_future_pred): preds_moving = [] moving_test_window = [

我有以下类型的数据,我正在做预测:

Input: 1 | 2 | 3 | 4 | 5
       1 | 2 | 3 | 4 | 5
       1 | 2 | 3 | 4 | 5

Output: 6
        7
        8
我希望一次预测一个,并将其作为最后一列的值反馈给输入。我使用此功能,但效果不佳:

def moving_window(num_future_pred):
    preds_moving = []
    moving_test_window = [test_X[0,:].tolist()]
    moving_test_window = np.array(moving_test_window)
    for j in range(1, len(test_Y)):
        moving_test_window = [test_X[j,:].tolist()]
        moving_test_window = np.array(moving_test_window)
        pred_one_step = model.predict(moving_test_window[:,:,:])
        preds_moving.append(pred_one_step[0,0])
        pred_one_step = pred_one_step.reshape((1,1,1))
        moving_test_window = 
        np.concatenate((moving_test_window[:,:4,:], pred_one_step), axis= 1)
    return preds_moving

preds_moving = moving_window(len(test_Y))
我想要的是:

Input: 1 | 2 | 3 | 4 | 5
       1 | 2 | 3 | 4 | 6
       1 | 2 | 3 | 4 | 17

Output: 6
        17
        18
基本上是进行第一次预测
[1,2,3,4,5]-->6
,然后从下一次输入中删除最后一列
[5]
,每次添加预测值

它现在所做的是,它只接受所有的输入,并对每一行进行预测。任何想法都值得赞赏