Using resource-heavy classifiers like RandomForestClassifier for standard classification tasks can result in longer execution times and higher carbon emissions.
XGBoost offers a more optimized and eco-friendly alternative with competitive accuracy.
| Classifier | Accuracy | Time (s) | Carbon Emission (kg CO₂) |
|---|---|---|---|
RandomForestClassifier |
0.88 |
1.24 |
0.00091 |
XGBClassifier |
0.89 |
0.47 |
0.00035 |
XGBoost not only matches or exceeds the accuracy of RandomForest but also runs significantly faster and emits less CO₂.
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
from xgboost import XGBClassifier
model = XGBClassifier(eval_metric="logloss")
model.fit(X_train, y_train)
This article explains in detail what XGBoost can do : https://arxiv.org/pdf/1603.02754