prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Log number of spam/non-spam bugs in SpamBug get_labels
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bugbug/models/spambug.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # This Source Code Form is subject to the terms of the Mozilla Public
  3 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4 # You can obtain one at http://mozilla.org/MPL/2.0/.
  5 
  6 import xgboost
  7 from imblearn.under_sampling import RandomUnderSampler
  8 from sklearn.compose import ColumnTransformer
  9 from sklearn.feature_extraction import DictVectorizer
  10 from sklearn.pipeline import Pipeline
  11 
  12 from bugbug import bug_features, bugzilla, feature_cleanup
  13 from bugbug.model import BugModel
  14 
  15 
  16 class SpamBugModel(BugModel):
  17     def __init__(self, lemmatization=False):
  18         BugModel.__init__(self, lemmatization)
  19 
  20         self.sampler = RandomUnderSampler(random_state=0)
  21 
  22         feature_extractors = [
  23             bug_features.has_str(),
  24             bug_features.has_regression_range(),
  25             bug_features.severity(),
  26             bug_features.is_coverity_issue(),
  27             bug_features.has_crash_signature(),
  28             bug_features.has_url(),
  29             bug_features.has_w3c_url(),
  30             bug_features.has_github_url(),
  31             bug_features.whiteboard(),
  32             bug_features.patches(),
  33             bug_features.landings(),
  34             bug_features.product(),
  35             bug_features.component(),
  36             bug_features.num_words_title(),
  37             bug_features.num_words_comments(),
  38             bug_features.keywords(),
  39         ]
  40 
  41         cleanup_functions = [
  42             feature_cleanup.fileref(),
  43             feature_cleanup.url(),
  44             feature_cleanup.synonyms(),
  45         ]
  46 
  47         self.extraction_pipeline = Pipeline(
  48             [
  49                 (
  50                     "bug_extractor",
  51                     bug_features.BugExtractor(
  52                         feature_extractors, cleanup_functions, rollback=True
  53                     ),
  54                 ),
  55                 (
  56                     "union",
  57                     ColumnTransformer(
  58                         [
  59                             ("data", DictVectorizer(), "data"),
  60                             ("title", self.text_vectorizer(), "title"),
  61                             ("comments", self.text_vectorizer(), "comments"),
  62                         ]
  63                     ),
  64                 ),
  65             ]
  66         )
  67 
  68         self.clf = xgboost.XGBClassifier(n_jobs=16)
  69         self.clf.set_params(predictor="cpu_predictor")
  70 
  71     def get_labels(self):
  72         classes = {}
  73 
  74         for bug_data in bugzilla.get_bugs(include_invalid=True):
  75             bug_id = bug_data["id"]
  76 
  77             # Legitimate bugs
  78             if bug_data["resolution"] == "FIXED":
  79                 classes[bug_id] = 0
  80 
  81             # Spam bugs
  82             elif (
  83                 bug_data["product"] == "Invalid Bugs"
  84                 and bug_data["component"] == "General"
  85             ):
  86                 classes[bug_id] = 1
  87 
  88         return classes, [0, 1]
  89 
  90     def items_gen(self, classes):
  91         # Overwriting this method to add include_invalid=True to get_bugs to
  92         # include spam bugs.
  93         return (
  94             (bug, classes[bug["id"]])
  95             for bug in bugzilla.get_bugs(include_invalid=True)
  96             if bug["id"] in classes
  97         )
  98 
  99     def get_feature_names(self):
  100         return self.extraction_pipeline.named_steps["union"].get_feature_names()
  101 
  102     def overwrite_classes(self, bugs, classes, probabilities):
  103         for (i, bug) in enumerate(bugs):
  104             if "@mozilla" in bug["creator"]:
  105                 if probabilities:
  106                     classes[i] = [1.0, 0.0]
  107                 else:
  108                     classes[i] = 0
  109 
  110         return classes
  111
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/bugbug/models/spambug.py b/bugbug/models/spambug.py
  --- a/bugbug/models/spambug.py
  +++ b/bugbug/models/spambug.py
  @@ -85,6 +85,17 @@
               ):
                   classes[bug_id] = 1
   
  +        print(
  +            "{} bugs are classified as non-spam".format(
  +                sum(1 for label in classes.values() if label == 0)
  +            )
  +        )
  +        print(
  +            "{} bugs are classified as spam".format(
  +                sum(1 for label in classes.values() if label == 1)
  +            )
  +        )
  +
           return classes, [0, 1]
   
       def items_gen(self, classes):
  
verification_info: {"golden_diff": "diff --git a/bugbug/models/spambug.py b/bugbug/models/spambug.py\n--- a/bugbug/models/spambug.py\n+++ b/bugbug/models/spambug.py\n@@ -85,6 +85,17 @@\n             ):\n                 classes[bug_id] = 1\n \n+        print(\n+            \"{} bugs are classified as non-spam\".format(\n+                sum(1 for label in classes.values() if label == 0)\n+            )\n+        )\n+        print(\n+            \"{} bugs are classified as spam\".format(\n+                sum(1 for label in classes.values() if label == 1)\n+            )\n+        )\n+\n         return classes, [0, 1]\n \n     def items_gen(self, classes):\n", "issue": "Log number of spam/non-spam bugs in SpamBug get_labels\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this file,\n# You can obtain one at http://mozilla.org/MPL/2.0/.\n\nimport xgboost\nfrom imblearn.under_sampling import RandomUnderSampler\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.feature_extraction import DictVectorizer\nfrom sklearn.pipeline import Pipeline\n\nfrom bugbug import bug_features, bugzilla, feature_cleanup\nfrom bugbug.model import BugModel\n\n\nclass SpamBugModel(BugModel):\n    def __init__(self, lemmatization=False):\n        BugModel.__init__(self, lemmatization)\n\n        self.sampler = RandomUnderSampler(random_state=0)\n\n        feature_extractors = [\n            bug_features.has_str(),\n            bug_features.has_regression_range(),\n            bug_features.severity(),\n            bug_features.is_coverity_issue(),\n            bug_features.has_crash_signature(),\n            bug_features.has_url(),\n            bug_features.has_w3c_url(),\n            bug_features.has_github_url(),\n            bug_features.whiteboard(),\n            bug_features.patches(),\n            bug_features.landings(),\n            bug_features.product(),\n            bug_features.component(),\n            bug_features.num_words_title(),\n            bug_features.num_words_comments(),\n            bug_features.keywords(),\n        ]\n\n        cleanup_functions = [\n            feature_cleanup.fileref(),\n            feature_cleanup.url(),\n            feature_cleanup.synonyms(),\n        ]\n\n        self.extraction_pipeline = Pipeline(\n            [\n                (\n                    \"bug_extractor\",\n                    bug_features.BugExtractor(\n                        feature_extractors, cleanup_functions, rollback=True\n                    ),\n                ),\n                (\n                    \"union\",\n                    ColumnTransformer(\n                        [\n                            (\"data\", DictVectorizer(), \"data\"),\n                            (\"title\", self.text_vectorizer(), \"title\"),\n                            (\"comments\", self.text_vectorizer(), \"comments\"),\n                        ]\n                    ),\n                ),\n            ]\n        )\n\n        self.clf = xgboost.XGBClassifier(n_jobs=16)\n        self.clf.set_params(predictor=\"cpu_predictor\")\n\n    def get_labels(self):\n        classes = {}\n\n        for bug_data in bugzilla.get_bugs(include_invalid=True):\n            bug_id = bug_data[\"id\"]\n\n            # Legitimate bugs\n            if bug_data[\"resolution\"] == \"FIXED\":\n                classes[bug_id] = 0\n\n            # Spam bugs\n            elif (\n                bug_data[\"product\"] == \"Invalid Bugs\"\n                and bug_data[\"component\"] == \"General\"\n            ):\n                classes[bug_id] = 1\n\n        return classes, [0, 1]\n\n    def items_gen(self, classes):\n        # Overwriting this method to add include_invalid=True to get_bugs to\n        # include spam bugs.\n        return (\n            (bug, classes[bug[\"id\"]])\n            for bug in bugzilla.get_bugs(include_invalid=True)\n            if bug[\"id\"] in classes\n        )\n\n    def get_feature_names(self):\n        return self.extraction_pipeline.named_steps[\"union\"].get_feature_names()\n\n    def overwrite_classes(self, bugs, classes, probabilities):\n        for (i, bug) in enumerate(bugs):\n            if \"@mozilla\" in bug[\"creator\"]:\n                if probabilities:\n                    classes[i] = [1.0, 0.0]\n                else:\n                    classes[i] = 0\n\n        return classes\n", "path": "bugbug/models/spambug.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this file,\n# You can obtain one at http://mozilla.org/MPL/2.0/.\n\nimport xgboost\nfrom imblearn.under_sampling import RandomUnderSampler\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.feature_extraction import DictVectorizer\nfrom sklearn.pipeline import Pipeline\n\nfrom bugbug import bug_features, bugzilla, feature_cleanup\nfrom bugbug.model import BugModel\n\n\nclass SpamBugModel(BugModel):\n    def __init__(self, lemmatization=False):\n        BugModel.__init__(self, lemmatization)\n\n        self.sampler = RandomUnderSampler(random_state=0)\n\n        feature_extractors = [\n            bug_features.has_str(),\n            bug_features.has_regression_range(),\n            bug_features.severity(),\n            bug_features.is_coverity_issue(),\n            bug_features.has_crash_signature(),\n            bug_features.has_url(),\n            bug_features.has_w3c_url(),\n            bug_features.has_github_url(),\n            bug_features.whiteboard(),\n            bug_features.patches(),\n            bug_features.landings(),\n            bug_features.product(),\n            bug_features.component(),\n            bug_features.num_words_title(),\n            bug_features.num_words_comments(),\n            bug_features.keywords(),\n        ]\n\n        cleanup_functions = [\n            feature_cleanup.fileref(),\n            feature_cleanup.url(),\n            feature_cleanup.synonyms(),\n        ]\n\n        self.extraction_pipeline = Pipeline(\n            [\n                (\n                    \"bug_extractor\",\n                    bug_features.BugExtractor(\n                        feature_extractors, cleanup_functions, rollback=True\n                    ),\n                ),\n                (\n                    \"union\",\n                    ColumnTransformer(\n                        [\n                            (\"data\", DictVectorizer(), \"data\"),\n                            (\"title\", self.text_vectorizer(), \"title\"),\n                            (\"comments\", self.text_vectorizer(), \"comments\"),\n                        ]\n                    ),\n                ),\n            ]\n        )\n\n        self.clf = xgboost.XGBClassifier(n_jobs=16)\n        self.clf.set_params(predictor=\"cpu_predictor\")\n\n    def get_labels(self):\n        classes = {}\n\n        for bug_data in bugzilla.get_bugs(include_invalid=True):\n            bug_id = bug_data[\"id\"]\n\n            # Legitimate bugs\n            if bug_data[\"resolution\"] == \"FIXED\":\n                classes[bug_id] = 0\n\n            # Spam bugs\n            elif (\n                bug_data[\"product\"] == \"Invalid Bugs\"\n                and bug_data[\"component\"] == \"General\"\n            ):\n                classes[bug_id] = 1\n\n        print(\n            \"{} bugs are classified as non-spam\".format(\n                sum(1 for label in classes.values() if label == 0)\n            )\n        )\n        print(\n            \"{} bugs are classified as spam\".format(\n                sum(1 for label in classes.values() if label == 1)\n            )\n        )\n\n        return classes, [0, 1]\n\n    def items_gen(self, classes):\n        # Overwriting this method to add include_invalid=True to get_bugs to\n        # include spam bugs.\n        return (\n            (bug, classes[bug[\"id\"]])\n            for bug in bugzilla.get_bugs(include_invalid=True)\n            if bug[\"id\"] in classes\n        )\n\n    def get_feature_names(self):\n        return self.extraction_pipeline.named_steps[\"union\"].get_feature_names()\n\n    def overwrite_classes(self, bugs, classes, probabilities):\n        for (i, bug) in enumerate(bugs):\n            if \"@mozilla\" in bug[\"creator\"]:\n                if probabilities:\n                    classes[i] = [1.0, 0.0]\n                else:\n                    classes[i] = 0\n\n        return classes\n", "path": "bugbug/models/spambug.py"}]}