# XGBoost for multi-label image classification

I am trying to use the xgboost classifier for a multi-label and multi-class image classification task. I have a list of images that can have up to 5 different labels in each of them. Before I use the classifier I want to also apply image augmentation.

import keras
from sklearn.model_selection import train_test_split
from keras.preprocessing.image import ImageDataGenerator
from xgboost.sklearn import XGBClassifier

train_datagen=ImageDataGenerator(zoom_range=0.1,
fill_mode='constant',
rotation_range=10,
height_shift_range=0.1,
width_shift_range=0.1,
horizontal_flip=True,
vertical_flip=True,
rescale=1/255.)

train_generator=train_datagen.flow_from_dataframe(
directory="home/DATA/train_images/",
x_col="ImageId",
y_col=columns,
color_mode='grayscale',
batch_size=32,
seed=32,
shuffle=True,
class_mode="other",
target_size=(100,100))

model = XGBClassifier()
history=model.fit_generator(generator=train_generator,
steps_per_epoch=100,
validation_data=validation_generator,
validation_steps=100,
epochs=5)


The last command gives me an error:

AttributeError                            Traceback (most recent call last)
<ipython-input-8-8c4c0504d559> in <module>
----> 1 history=model.fit_generator(generator=train_generator,
2                     steps_per_epoch=100,
3                     validation_data=validation_generator,
4                     validation_steps=100,
5                     epochs=5

AttributeError: 'XGBClassifier' object has no attribute 'fit_generator'


Does anyone have any advice on how to proceed since I can not use the fit_generator?

• 'XGBClassifier' object has no attribute 'fit_generator'... it is exactly what it says. Nov 4, 2019 at 6:41
• I was hoping if someone knows how to use this classifier with the data augmentation, maybe another way.
– AL B
Nov 4, 2019 at 6:58

history=model.fit(generator=train_generator,