def weighted_vote(predictions, weights):
y_complete = np.sum(
[
self.one_hot.transform(p.reshape(-1, 1)) * wi
for p, wi in zip(predictions, weights)
],
0,
)
y_zeros = np.zeros(y_complete.shape)
y_zeros[np.arange(y_complete.shape[0]), y_complete.argmax(1)] = 1
return self.one_hot.inverse_transform(y_zeros).flatten()
predictions -> 2d array (instances, classes) weights -> 1d array (voters) one_hot -> A one hot encoder previous calculated with the classes
1d array (instances) with the votes