r, _ = get_dimensions(X)
predictions = []
for i in range(r):
votes = self.get_votes_for_instance(X[i])
if votes == {}:
// Ensemble is empty, all classes equal, default to zero
predictions.append(0)
else:
predictions.append(max(votes, key=votes.get))return np.asarray(predictions)
def predict_proba(self, X):
Estimates the probability of each sample in X belonging to each of the class-labels.
After Change
A numpy.ndarray with all the predictions for the samples in X.
y_proba = self.predict_proba(X)
n_rows = y_proba.shape[0]
y_pred = np.zeros(n_rows, dtype=int)
for i in range(n_rows):
index = np.argmax(y_proba[i])
y_pred[i] = index
return y_pred
def predict_proba(self, X):
Estimates the probability of each sample in X belonging to each of the class-labels.