When using the model below for multi-class classification and passing y targets from LabelBinarizer, these get detected as task type: multilabel-indicator instead of task type: multiclass.
def get_model(hidden_layer_sizes, meta, compile_kwargs):
model = keras.Sequential()
inp = keras.layers.Input(shape=(meta["n_features_in_"]))
model.add(inp)
for hidden_layer_size in hidden_layer_sizes:
layer = keras.layers.Dense(hidden_layer_size, activation="relu")
model.add(layer)
if meta["target_type_"] == "binary":
n_output_units = 1
output_activation = "sigmoid"
loss = "binary_crossentropy"
elif meta["target_type_"] == "multiclass":
n_output_units = meta["n_classes_"]
output_activation = "softmax"
loss = "sparse_categorical_crossentropy"
else:
raise NotImplementedError(f"Unsupported task type: {meta['target_type_']}")
out = keras.layers.Dense(n_output_units, activation=output_activation)
model.add(out)
model.compile(loss=loss, optimizer=compile_kwargs["optimizer"])
return model
Can you include some sample data (not real data, it can be 1-2 rows of made up data with the same shape / types as your data) so that I can build a test notebook to try this in?
When using the model below for multi-class classification and passing
y
targets fromLabelBinarizer
, these get detected astask type: multilabel-indicator
instead oftask type: multiclass
.throws