'Is it possible to average the output of multiple classification models using pipeline in sklearn?

As an example, suppose there is a random forest and a logistic regression model that accept the same input data, and I want the inference result to be the average of the probabilities of these two models.

In this case, is it possible to create a pipeline that outputs the average probabilities of the two models as shown above?



Solution 1:[1]

A VotingClassifier with voting="soft" will work for this purpose.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ben Reiniger