Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibrated the Regressor Model #3450

Merged
merged 13 commits into from
May 7, 2023
13 changes: 10 additions & 3 deletions bugbug/models/regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from bugbug import bugzilla, commit_features, db, feature_cleanup, repository, utils
from bugbug.model import CommitModel
from bugbug.model_calibration import IsotonicRegressionCalibrator

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -51,6 +52,7 @@ class RegressorModel(CommitModel):

def __init__(
self,
calibration: bool = True,
lemmatization: bool = False,
interpretable: bool = True,
use_finder: bool = False,
Expand Down Expand Up @@ -127,9 +129,14 @@ def __init__(
("union", ColumnTransformer(column_transformers)),
]
)

self.clf = xgboost.XGBClassifier(n_jobs=utils.get_physical_cpu_count())
self.clf.set_params(predictor="cpu_predictor")
base_clf = xgboost.XGBClassifier(n_jobs=utils.get_physical_cpu_count())
base_clf.set_params(predictor="cpu_predictor")
if calibration:
self.clf = IsotonicRegressionCalibrator(base_clf)
# This is a temporary workaround for the error : "Model type not yet supported by TreeExplainer"
self.calculate_importance = False
else:
self.clf = base_clf
WhiteWolf47 marked this conversation as resolved.
Show resolved Hide resolved

def get_labels(self):
classes = {}
Expand Down