#make predictions preds = [] for i in range(0,104): a = train['close'][len(train)-104+i:].sum() + sum(preds) b = a/103 preds.append(b) #calculate rmse rms=np.sqrt(np.mean(np.power((np.array(valid['close'])-preds),2))) rms代码的流程图怎么画
时间: 2024-03-04 08:47:52 浏览: 17
下面是代码的流程图:
```
Start
|
|__ Initialize an empty list called preds
|
|__ Loop 104 times:
| |
| |__ Select the most recent 104 days of the training set and add any previous predictions to it
| |
| |__ Calculate the sum of the closing prices of these 104 days and add to the sum of previous predictions
| |
| |__ Calculate the average by dividing the sum by 103
| |
| |__ Add the average to the list preds
|
|__ Calculate the root mean squared error (RMSE) between the predicted values and the actual values of the validation set
|
End
```
这个流程图描述了代码的每个步骤以及它们之间的关系。开始时,我们初始化一个空列表 `preds`。然后我们进入一个循环,循环104次。在每次循环中,我们选择最近的104天作为训练集,并将之前的预测结果添加到其中。然后,我们计算这104天的收盘价总和,并将其与之前的预测结果相加。接着我们计算平均值,并将其添加到 `preds` 列表中。在循环结束后,我们计算预测值与验证集实际值之间的 RMSE。最后,程序结束。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)