This message was deleted.
# ask-for-help
s
This message was deleted.
f
I solved it by creating a subclass of
MultiOutputClassifier
as follows:
Copy code
class MultiOutputClassifierWithNormalizedOutput(MultiOutputClassifier):
    """MultiOutputClassifier with normalized output.
    We need this because MultiOutputClassifier returns a list of arrays with the probabilities of each class.
    Instead, we want a single array with the probabilities of the positive class in the format (n_samples, n_classes)
    because BentoML expects this format.
    """

    def predict_proba(self, X) -> np.ndarray:
        classes_probas = super().predict_proba(X)
        classes_pos_probas = np.array(
            [classes_proba[:, 1] for classes_proba in classes_probas]
        )
        return classes_pos_probas.T
👍 1
s
Hi @Fernando Camargo, I think this is because you are saving the model with
batchable
as True so the first dimension is treated as the batch dimension.
f
Yeah. I wanted to have it batchable. The problem is the weird API from MultiOutputClassifier, that doesn't follow the normal
(n_samples, n_classes)
format
👍 1
s
Got it. Your solution works then.