def reg_interval_size(self, prediction, y, significance):
idx = int(significance * 100 - 1)
prediction = prediction[:, idx]
prediction_size = prediction[:, 1] - prediction[:, 0]
return prediction_size这是我在应用函数时遇到的错误:
IndexError: index 4 is out of bounds for axis 1 with size 2我的预测区间
[[-0.08654671 0.7144939 ]
[-0.61418434 0.18685626]
[ 0.16648421 0.96752482]
...
[ 0.01177342 0.81281403]
[ 0.44408509 1.2451257 ]
[ 0.37012494 1.17116555]]示例
prediction_size = reg_interval_size(self, prediction, y, significance= 0.05):预期输出(它只是一个一维数组,用于计算预测间隔数组每一行之间的大小差异)
[0.80104061 0.80104061 0.80104061 ... 0.80104061 0.80104061 0.80104061]发布于 2020-07-15 15:07:44
idx是一个int,所以idx[0]没有任何意义。
prediction是一个2d数组,所以不能使用以下3个索引访问它:
prediction = prediction[:, :, idx] # error我不知道你想做什么,但是你可以这样做:
prediction = prediction[:, idx]https://stackoverflow.com/questions/62917785
复制相似问题