0
$\begingroup$

i'm working on a multi class classification problem which classifies jellyfish and plastic pollution so basically i have 6 classes (barrel_jellyfish, compass_jellyfish, lions_mane_jellyfish, mauve_stinger_jellyfish, moon_jellyfish, plastic pollution) according to the description of the competition the evaluation is this

Correct Classification Upon making the correct class prediction, no penalty will be applied.

Classifying Plastic Pollution as any Class of Jellyfish: This error will incur a heavy penalty. Misclassifying plastic pollution as jellyfish has more significant consequences in the context of our mission to raise awareness about the impact of plastic on marine ecosystems.

Misclassifying any Class of Jellyfish as Plastic Pollution: This error will incur a moderate penalty. This will emphasize the need to maintain a balanced approach in the classification task.

Confusing Different Classes of Jellyfish: Errors within the spectrum of jellyfish classes will incur a minor penalty. While accuracy in distinguishing between jellyfish types is valued, our primary focus remains on minimizing the misclassification of plastic pollution.

i made a simple multi class classification neural net which gave me great results (accuracy of around 95%) however i believe penalizing miss classification of plastic pollution will give me better results so far i tried weight class in keras and it didn't help. here's the model:

def build_model(hp):
    base_models = [keras.applications.Xception(include_top=False, weights="imagenet", input_shape=(224,224,3)), keras.applications.ResNet50(include_top=False, weights="imagenet", input_shape=(224,224,3)), keras.applications.ResNet50V2(include_top=False, weights="imagenet", input_shape=(224,224,3))]
    base_model = base_models[0]
    for layer in base_model.layers:
        layer.trainable=False
    model = Sequential()
    model.add(base_model)
    model.add(layers.Flatten())
    model.add(layers.Dense(hp.Int("units1", min_value=32, max_value=256, step=32), activation=hp.Choice("activation1",["relu", "tanh", "sigmoid"])))
    model.add(layers.Dropout(0.3))
    model.add(layers.Dense(hp.Int("units2", min_value=32, max_value=256, step=32), activation=hp.Choice("activation2",["relu", "tanh", "sigmoid"])))
    model.add(layers.Dense(6, activation="softmax"))
    optimizer = keras.optimizers.Adam(hp.Choice("lr", [0.001, 0.01]))
    model.layers[0].trainable = False
    model.compile(optimizer=optimizer, loss=keras.losses.categorical_crossentropy, metrics="accuracy")
    return model



hp = keras_tuner.HyperParameters()
tuner = keras_tuner.RandomSearch(hypermodel=build_model, objective="val_accuracy", max_trials=5, executions_per_trial = 1, directory="tuner")
tuner.search(train_generator, validation_data=val_generator, epochs=12)

best_hp=tuner.get_best_hyperparameters()[0]
h_model = tuner.hypermodel.build(best_hp)
h_model.summary()
weight_class = {0:0.1, 1:0.1, 2:0.1, 3:0.1, 4:0.1, 5:0.5}
h_model.fit(train_generator, validation_data=val_generator, epochs=12, class_weight=weight_class)

if you believe in my case weighted class is useless let me know what else can improve my model

$\endgroup$

0

You must log in to answer this question.