correct this: DMResult=[] for i in range(losses.shape[1]): for j in…
- User
correct this: DMResult=[]
for i in range(losses.shape[1]): for j in range(losses.shape[1]): DMResult[i,j]=dm_test(actual, Predictions[COLUMNS[i]], Predictions[COLUMNS[j]], h = 1, crit="MSE")['DM']
- Assistant
DMResult = np.zeros((losses.shape[1], losses.shape[1]))
for i in range(losses.shape[1]): for j in range(losses.shape[1]): DMResult[i,j] = dm_test(actual, Predictions[COLUMNS[i]], Predictions[COLUMNS[j]], h = 1, crit="MSE")['DM']
- User
TypeError: tuple indices must be integers or slices, not str
- Assistant
It seems like the issue is that the
COLUMNS[i]andCOLUMNS[j]variables are not integers but string values. You can convert them to integers before using them as indices. Here's the corrected code:DMResult = np.zeros((losses.shape[1], losses.shape[1])) for i in range(losses.shape[1]): for j in range(losses.shape[1]): DMResult[i, j] = dm_test(actual, Predictions[int(COLUMNS[i])], Predictions[int(COLUMNS[j])], h=1, crit="MSE")['DM']By converting
COLUMNS[i]andCOLUMNS[j]to integers usingint(), you should no longer get theTypeError.