Мой итератор выглядит следующим образом
Код: Выделить всё
class IterForQDMatrix(xgb.core.DataIter):
def __init__(self, df, batch_size):
self.df = df
self.batch_size = batch_size
self.batches = np.ceil(len(df) // self.batch_size)
self.it = 0
super().__init__()
def reset(self):
self.it = 0
def next(self, input_data):
if self.it == self.batches:
print("done")
return 0
a = self.it * self.batch_size
b = min((self.it + 1) * self.batch_size, len(self.df))
input_data(data=self.df[a:b, : -1], label=self.df[a:b, -1])
self.it += 1
return 1
iterator = IterForQDMatrix(X, 30)
xgb_data = xgb.QuantileDMatrix(iterator)
Подробнее здесь: https://stackoverflow.com/questions/765 ... m-data-ite