Looks like a pandas error to me, i.e., I think you are trying to look up a column that doesn’t exist. Have you checked that self.ytrain[index] is a numpy array? otherwise, I think in pandas you need to use sth like self.ytrain.irow[index]