My question is about ensemble learning. I am a beginner in ML field and wondering whether there exists a way to print all the metrics(such as accuracy) for each and every ML algorithm inside the Voting Classifier object seen below. What I mean is an output I have written in bold:
- lr_model accuracy => 0.70
- lgb_model accuracy => 0.72
- xgb_model accuracy => 0.71
lr_model=LogisticRegression()
lgb_model=lgb.LGBMClassifier()
xgb_model=xgb.XGBClassifier()
model=VotingClassifier(estimators=[("lr",lr_model), ("lgbm",lgb_model),
("xgb",xgb_model)],voting='soft')
model.fit(X,y)
You could access fitted sub-estimators of model by model.named_estimators_.{name}
. for example:
from sklearn.metrics import accuracy_score
y_pred = model.named_estimators_.lr.predict(x)
lr_accuracy=accuracy_score(y_true, y_pred)
Also, model.transform(X) return "probabilities per label" or "predicted label" of each classifier for all X, make it easy to compute any metrics for each classifier.