Slackbot
05/01/2023, 6:40 PMFernando Camargo
05/01/2023, 7:26 PMMultiOutputClassifier
as follows:
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
Sean
05/02/2023, 5:51 AMbatchable
as True so the first dimension is treated as the batch dimension.Fernando Camargo
05/02/2023, 3:23 PM(n_samples, n_classes)
formatSean
05/02/2023, 8:07 PM