-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/marco-c/bugbug into cleanup
- Loading branch information
Showing
4 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import xgboost | ||
from sklearn.feature_extraction import DictVectorizer | ||
from sklearn.pipeline import FeatureUnion | ||
from sklearn.pipeline import Pipeline | ||
|
||
from bugbug import bug_features | ||
from bugbug import labels | ||
from bugbug.model import Model | ||
from bugbug.utils import DictSelector | ||
|
||
|
||
class UpliftModel(Model): | ||
def __init__(self, lemmatization=False): | ||
Model.__init__(self, lemmatization) | ||
|
||
self.classes = labels.get_uplift_labels() | ||
|
||
feature_extractors = [ | ||
bug_features.has_str(), | ||
bug_features.has_regression_range(), | ||
bug_features.severity(), | ||
bug_features.keywords(), | ||
bug_features.is_coverity_issue(), | ||
bug_features.has_crash_signature(), | ||
bug_features.has_url(), | ||
bug_features.has_w3c_url(), | ||
bug_features.has_github_url(), | ||
bug_features.whiteboard(), | ||
bug_features.patches(), | ||
bug_features.landings(), | ||
bug_features.title(), | ||
bug_features.comments(), | ||
] | ||
|
||
self.extraction_pipeline = Pipeline([ | ||
('bug_extractor', bug_features.BugExtractor(feature_extractors)), | ||
('union', FeatureUnion( | ||
transformer_list=[ | ||
('data', Pipeline([ | ||
('selector', DictSelector(key='data')), | ||
('vect', DictVectorizer()), | ||
])), | ||
|
||
('title', Pipeline([ | ||
('selector', DictSelector(key='title')), | ||
('tfidf', self.text_vectorizer(stop_words='english')), | ||
])), | ||
|
||
('comments', Pipeline([ | ||
('selector', DictSelector(key='comments')), | ||
('tfidf', self.text_vectorizer(stop_words='english')), | ||
])), | ||
], | ||
)), | ||
]) | ||
|
||
self.clf = xgboost.XGBClassifier(n_jobs=16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters