【发布时间】:2016-03-17 13:28:38
【问题描述】:
我正在努力处理从sklearn.cross_validation 提出的IndexError。我解决了这个问题,似乎是sklearn 的错误。
我在 ipython 并行引擎上运行以下代码:
kf = cross_validation.KFold(num_data, k_fold)
for k, (train, test) in enumerate(kf):
# do something
发生错误
IndexError: arrays used as indices must be of integer (or boolean) type
发生错误的地方是:
def _iter_test_masks(self):
"""Generates boolean masks corresponding to test sets.
By default, delegates to _iter_test_indices()
"""
for test_index in self._iter_test_indices():
test_mask = self._empty_mask()
test_mask[test_index] = True # <============= Here error occurs
yield test_mask
如何解决?
【问题讨论】:
标签: python scikit-learn