{
  "id": "task_libraries:text-classification/python",
  "path": "/exapedia/python-text-classification-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python text classification libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python text classification libraries assign one or more labels to a piece of text, such as a topic, an intent, or a sentiment. A zero-shot model scores labels chosen at runtime rather than labels fixed during training. These libraries let support tools, content filters, and AI agents route text by what it says."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python text classification libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#scikit-learn",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F121"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F122"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F125"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F137"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#nltk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F154"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#spacy",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F172"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#catboost",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F190"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#textblob",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F209"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#fasttext",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#keras-hub",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F243"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F252"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F247"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#scikit-learn",
          "label": [
            {
              "t": "text",
              "text": "scikit-learn"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F122"
        },
        {
          "t": "text",
          "text": ", a count that covers all its machine learning work."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Zero-shot custom labels",
            "CSR feature input"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#scikit-learn",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F121"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F137"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#nltk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F154"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#spacy",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F172"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#catboost",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F190"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#textblob",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F209"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#fasttext",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#keras-hub",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F243"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F253"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F254"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "scikit-learn",
          "name": [
            {
              "t": "fact",
              "fact": "F121"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/scikit-learn/scikit-learn"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/scikit-learn"
            },
            {
              "label": "Docs",
              "href": "https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F11"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F122"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F124"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F121"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F12"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F135"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/mozilla/bugbug",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F135"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __init__(self, lemmatization=False):\n    BugModel.__init__(self, lemmatization)\n\n    self.cross_validation_enabled = False\n    self.calculate_importance = False\n    # The test set is made of the most recent bugs (see train_test_split), so\n    # retrain on all bugs after the evaluation.\n    self.entire_dataset_training = True\n\n    feature_extractors = [\n        bug_features.HasSTR(),\n        bug_features.Severity(),\n        bug_features.Keywords(),\n        bug_features.HasCrashSignature(),\n        bug_features.HasURL(),\n        bug_features.HasW3CURL(),\n        bug_features.HasGithubURL(),\n        bug_features.Whiteboard(),\n        bug_features.Patches(),\n        bug_features.Landings(),\n        bug_features.BugReporter(),\n        # Bugs are rolled back to their creation, so this is the product the bug\n        # was filed in.\n        bug_features.Product(),\n        bug_features.OpSys(),\n        bug_features.Platform(),\n        bug_features.MentionedPathsComponents(),\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    )\n\n    # A linear model on sparse n-gram features is more accurate (and faster\n    # to train) than gradient boosted trees for this task. The L1 penalty\n    # keeps the weights sparse, so the model stays small despite the large\n    # vocabulary. Probabilities are calibrated on out-of-fold predictions.\n    estimator = CalibratedClassifierCV(\n        LinearSVC(penalty=\"l1\", dual=False),\n        method=\"isotonic\",\n        cv=3,\n        ensemble=False,\n        n_jobs=3,\n    )\n\n    self.clf = Pipeline(\n        [\n            (\n                \"union\",\n                ColumnTransformer(\n                    [\n                        (\"data\", DictVectorizer(), \"data\"),\n                        (\n                            \"title\",\n                            self.text_vectorizer(\n                                min_df=2,\n                                ngram_range=(1, 2),\n                                sublinear_tf=True,\n                                max_features=30000,\n                            ),\n                            \"title\",\n                        ),\n                        (\n                            \"title_char\",\n                            TfidfVectorizer(\n                                min_df=3,\n                                analyzer=\"char_wb\",\n                                ngram_range=(2, 5),\n                                sublinear_tf=True,\n                                max_features=30000,\n                            ),\n                            \"title\",\n                        ),\n                        (\n                            \"comments\",\n                            self.text_vectorizer(\n                                min_df=2,\n                                ngram_range=(1, 2),\n                                sublinear_tf=True,\n                                max_features=80000,\n                            ),\n                            \"comments\",\n                        ),\n                    ]\n                ),\n            ),\n            (\n                \"estimator\",\n                estimator,\n            ),\n        ]\n    )",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/mozilla/bugbug/blob/a28668766fc58c0b4564fcfbe981eada71058313/bugbug/models/component.py#L43-L147",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F134"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20scikit-learn%20for%20custom%20document%20labels%20multilabel%20classification%20training%20evaluation%20and%20zero%20shot%20inference&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F121"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from sklearn.pipeline import Pipeline\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.linear_model import LogisticRegression\n\nmodel = Pipeline([(\"text\", TfidfVectorizer()), (\"classifier\", LogisticRegression())])\nmodel.fit([\"invoice due\", \"pay invoice\", \"reset password\", \"forgot password\"],\n          [\"billing\", \"billing\", \"account\", \"account\"])\nprint(model.predict([\"invoice\"]))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "plot_grid_search_text_feature_extraction.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F126"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "transformers",
          "name": [
            {
              "t": "fact",
              "fact": "F137"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/huggingface/transformers"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/transformers"
            },
            {
              "label": "Docs",
              "href": "https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F34"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F140"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F137"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F35"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F36"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F37"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F152"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/deepset-ai/haystack",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F152"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def run(self, text: str) -> dict[str, str]:\n    \"\"\"\n    Routes the text strings to different connections based on a category label.\n\n    :param text: A string of text to route.\n    :returns:\n        A dictionary with the label as key and the text as value.\n\n    :raises TypeError:\n        If the input is not a str.\n    :raises RuntimeError:\n        If the pipeline has not been loaded because warm_up() was not called before.\n    \"\"\"\n    if self.pipeline is None:\n        raise RuntimeError(\n            \"The component TransformersZeroShotTextRouter wasn't warmed up. Run 'warm_up()' before calling 'run()'.\"\n        )\n\n    if not isinstance(text, str):\n        raise TypeError(\"TransformersZeroShotTextRouter expects a str as input.\")\n\n    prediction = self.pipeline([text], candidate_labels=self.labels, multi_label=self.multi_label)\n    predicted_scores = prediction[0][\"scores\"]\n    max_score_index = max(range(len(predicted_scores)), key=predicted_scores.__getitem__)\n    label = prediction[0][\"labels\"][max_score_index]\n    return {label: text}\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/deepset-ai/haystack/blob/dc1d72228adeaac8e657d3a4946c3e246d45784d/haystack/components/routers/zero_shot_text_router.py#L192-L217",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F151"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20transformers%20for%20custom%20document%20labels%20multilabel%20classification%20training%20evaluation%20and%20zero%20shot%20inference&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F137"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from transformers import pipeline\n\nclassifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-large-mnli\", device=-1)\nprint(classifier(\"Please reset my password\", candidate_labels=[\"billing\", \"account\"]))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/transformers/v5.23.0/en/main_classes/pipelines",
                  "label": [
                    {
                      "t": "text",
                      "text": "zero_shot_classification.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F142"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "nltk",
          "name": [
            {
              "t": "fact",
              "fact": "F154"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/nltk/nltk"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/nltk"
            },
            {
              "label": "Docs",
              "href": "https://www.nltk.org/api/nltk.classify.naivebayes.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F161"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://www.nltk.org/api/nltk.classify.naivebayes.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F154"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F171"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/sloria/TextBlob",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F170"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def train(self, *args, **kwargs):\n    \"\"\"Train the classifier with a labeled feature set and return\n    the classifier. Takes the same arguments as the wrapped NLTK class.\n    This method is implicitly called when calling ``classify`` or\n    ``accuracy`` methods and is included only to allow passing in arguments\n    to the ``train`` method of the wrapped NLTK class.\n\n    .. versionadded:: 0.6.2\n\n    :rtype: A classifier\n    \"\"\"\n    try:\n        self.classifier = self.nltk_class.train(\n            self.train_features, *args, **kwargs\n        )\n        return self.classifier\n    except AttributeError as error:\n        raise ValueError(\n            \"NLTKClassifier must have a nltk_class variable that is not None.\"\n        ) from error",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/sloria/TextBlob/blob/629e60e0b1cfc5fa6d7df4bed9ccc7b98ac8917d/src/textblob/classifiers.py#L235-L254",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F169"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=nltk%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F154"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from nltk.classify import NaiveBayesClassifier\n\ntraining = [({\"invoice\": True}, \"billing\"), ({\"password\": True}, \"account\")]\nclassifier = NaiveBayesClassifier.train(training)\nprint(classifier.classify({\"invoice\": True}))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://www.nltk.org/api/nltk.classify.naivebayes.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "nltk.classify.naivebayes.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F159"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "spacy",
          "name": [
            {
              "t": "fact",
              "fact": "F172"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/explosion/spaCy"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/spacy"
            },
            {
              "label": "Docs",
              "href": "https://spacy.io/api/textcategorizer"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F179"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://spacy.io/api/textcategorizer",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F172"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/explosion/prodigy-recipes",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F188"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@prodigy.recipe(\n    \"textcat.teach\",\n    dataset=(\"The dataset to use\", \"positional\", None, str),\n    spacy_model=(\"The base model\", \"positional\", None, str),\n    source=(\"The source data as a JSONL file\", \"positional\", None, str),\n    label=(\"One or more comma-separated labels\", \"option\", \"l\", split_string),\n    patterns=(\"Optional match patterns\", \"option\", \"p\", str),\n    exclude=(\"Names of datasets to exclude\", \"option\", \"e\", split_string),\n)\ndef textcat_teach(\n    dataset: str,\n    spacy_model: str,\n    source: str,\n    label: Optional[List[str]] = None,\n    patterns: Optional[str] = None,\n    exclude: Optional[List[str]] = None,\n):\n    \"\"\"\n    Collect the best possible training data for a text classification model\n    with the model in the loop. Based on your annotations, Prodigy will decide\n    which questions to ask next.\n    \"\"\"\n    labels = label\n    # Load the stream from a JSONL file and return a generator that yields a\n    # dictionary for each example in the data.\n    stream = JSONL(source)\n\n    # Load the spaCy model\n    nlp = spacy.load(spacy_model)\n\n    # Specify the name of the classifier pipeline.\n    name = \"textcat_multilabel\"\n\n    # Initialize classification pipeline from scratch (using a dummy training example) or from the base model if available.\n    if name not in nlp.pipe_names:\n        pipe = nlp.add_pipe(name)\n        # dummy doc\n        doc = nlp.make_doc(\"hello\")\n        # dummy weights\n        cats = {label: 0.5 for label in labels} \n        pipe.initialize(get_examples=lambda: [Example.from_dict(doc, {\"cats\":cats})])\n    else:\n        pipe = nlp.get_pipe(name)\n\n    # Initialize Prodigy's text classifier model, which outputs\n    # (score, example) tuples\n    model = TextClassifier(nlp, labels, name)\n\n    if patterns is None:\n        # No patterns are used, so just use the model to suggest examples\n        # and only use the model's update method as the update callback\n        predict = model\n        update = model.update\n    else:\n        # Initialize the pattern matcher and load in the JSONL patterns.\n        # Set the matcher to not label the highlighted spans, only the text.\n        matcher = PatternMatcher(\n            nlp,\n            prior_correct=5.0,\n            prior_incorrect=5.0,\n            label_span=False,\n            label_task=True,\n        )\n        matcher = matcher.from_disk(patterns)\n        # Combine the NER model and the matcher and interleave their\n        # suggestions and update both at the same time\n        predict, update = combine_models(model, matcher)\n\n    # Use the prefer_uncertain sorter to focus on suggestions that the model\n    # is most uncertain about (i.e. with a score closest to 0.5). The model\n    # yields (score, example) tuples and the sorter yields just the example\n    stream = prefer_uncertain(predict(stream))\n\n    return {\n        \"view_id\": \"classification\",  # Annotation interface to use\n        \"dataset\": dataset,  # Name of dataset to save annotations\n        \"stream\": stream,  # Incoming stream of examples\n        \"update\": update,  # Update callback, called with batch of answers\n        \"exclude\": exclude,  # List of dataset names to exclude\n        \"config\": {\"lang\": nlp.lang},  # Additional config settings, mostly for app UI\n    }",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/explosion/prodigy-recipes/blob/428bccb5a04ecfe6211049824aaf735a5907861c/textcat/textcat_teach.py#L15-L95",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F187"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=spacy%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F172"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import spacy\nfrom spacy.training import Example\n\nnlp = spacy.blank(\"en\")\nnlp.add_pipe(\"textcat\")\nsamples = [(\"invoice payment\", {\"billing\": 1.0, \"account\": 0.0}),\n           (\"reset password\", {\"billing\": 0.0, \"account\": 1.0})]\nexamples = [Example.from_dict(nlp.make_doc(text), {\"cats\": cats}) for text, cats in samples]\noptimizer = nlp.initialize(get_examples=lambda: examples)\nnlp.update(examples, sgd=optimizer)\nprint(nlp(\"invoice\").cats)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://spacy.io/api/textcategorizer",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F177"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "catboost",
          "name": [
            {
              "t": "fact",
              "fact": "F190"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/catboost/catboost"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/catboost"
            },
            {
              "label": "Docs",
              "href": "https://catboost.ai/docs/en/features/text-features"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F197"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://catboost.ai/docs/en/features/text-features",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F190"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/catboost/tutorials",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F207"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def fit_catboost_one_column(X_train, X_test, y_train, y_test, catboost_params={}, verbose=0):\n    learn_pool = Pool(X_train, y_train, text_features=[0])\n    test_pool = Pool(X_test, y_test, text_features=[0])\n    \n    catboost_default_params = {\n        'iterations': 1000,\n        'learning_rate': 0.03,\n        'eval_metric': 'Accuracy',\n    }\n    \n    catboost_default_params.update(catboost_params)\n    \n    model = CatBoostClassifier(**catboost_default_params)\n    model.fit(learn_pool, eval_set=test_pool, verbose=verbose)\n\n    return model",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/catboost/tutorials/blob/1409fb3faab40861542f7962b4310833305ed2c0/text_features/text_features_in_catboost.ipynb?plain=1#L1647-L1664",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F206"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=catboost%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F190"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from catboost import CatBoostClassifier\n\ntexts = [[\"invoice payment\"]] * 10 + [[\"password login\"]] * 10\nlabels = [\"billing\"] * 10 + [\"account\"] * 10\nmodel = CatBoostClassifier(iterations=5, text_features=[0], verbose=False)\nmodel.fit(texts, labels)\nprint(model.predict([[\"invoice payment\"]]))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://catboost.ai/docs/en/concepts/python-reference_catboostclassifier",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F195"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "textblob",
          "name": [
            {
              "t": "fact",
              "fact": "F209"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/sloria/TextBlob"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/textblob"
            },
            {
              "label": "Docs",
              "href": "https://textblob.readthedocs.io/en/dev/classifiers.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F216"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://textblob.readthedocs.io/en/dev/classifiers.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F209"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def get_tweet_sentiment(self, tweet):\n    '''\n    Utility function to classify sentiment of passed tweet\n    using textblob's sentiment method\n    '''\n    # create TextBlob object of passed tweet text\n    analysis = TextBlob(self.clean_tweet(tweet))\n    # set sentiment\n    if analysis.sentiment.polarity > 0:\n        return 'positive'\n    elif analysis.sentiment.polarity == 0:\n        return 'neutral'\n    else:\n        return 'negative'\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance/blob/6cd9f639ac7f9d914d556738ca3aeeef53618146/Crypto-Trading-Bots/Crypto_Sentiment_Analysis_SocialMedia_Bot.py#L79-L92",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F224"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=textblob%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F209"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from textblob.classifiers import NaiveBayesClassifier\n\ntraining = [(\"invoice payment\", \"billing\"), (\"reset password\", \"account\")]\nclassifier = NaiveBayesClassifier(training)\nprint(classifier.classify(\"invoice\"))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://textblob.readthedocs.io/en/dev/classifiers.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "classifiers.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F214"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "fasttext",
          "name": [
            {
              "t": "fact",
              "fact": "F227"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/facebookresearch/fastText"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/fasttext"
            },
            {
              "label": "Docs",
              "href": "https://fasttext.cc/docs/en/python-module.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F59"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F230"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://fasttext.cc/docs/en/python-module.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F227"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F60"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F61"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F62"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F63"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F241"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/mlfoundations/dclm",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F241"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def main():\n    args = get_args()\n    random.seed(args.seed)\n    train_input = args.input\n\n    train_was_split = False\n    if args.valid_input:\n        valid_input = args.valid_input\n    elif args.valid_frac > 0:\n        train_input, valid_input = split_train_val(train_input, args.valid_frac)\n        train_was_split = True\n    else:\n        valid_input = None\n\n    hyperparams = {'lr': args.lr, 'dim': args.dim, 'ws': args.ws, 'epoch': args.epoch, 'minCount': args.minCount, 'wordNgrams': args.wordNgrams}\n    model = fasttext.train_supervised(input=train_input, **hyperparams)\n\n    print(\"Training results\")\n    print_results(*model.test(train_input))\n\n    if valid_input is not None:\n        print(\"Validation results\")\n        print_results(*model.test(valid_input))\n\n    # Save the model\n    output = args.name if args.name.endswith(\".bin\") else args.name + \".bin\"\n    model.save_model(os.path.join(args.output_dir, output))\n\n    if train_was_split:\n        os.remove(train_input)\n        os.remove(valid_input)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/mlfoundations/dclm/blob/361714bdd60bb9b7f4b2d8354cebbf0dec0c329e/baselines/train_fasttext_classifier.py#L55-L85",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F240"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20fasttext%20for%20custom%20document%20labels%20multilabel%20classification%20training%20evaluation%20and%20zero%20shot%20inference&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F227"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from pathlib import Path\nfrom tempfile import TemporaryDirectory\nimport fasttext\n\nwith TemporaryDirectory() as directory:\n    training = Path(directory) / \"train.txt\"\n    training.write_text(\"__label__billing invoice payment\\n__label__account reset password\\n\", encoding=\"utf-8\")\n    model = fasttext.train_supervised(str(training), minCount=1)\n    print(model.get_labels())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://fasttext.cc/docs/en/python-module.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F232"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "keras-hub",
          "name": [
            {
              "t": "fact",
              "fact": "F243"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/keras-team/keras-hub"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/keras-hub"
            },
            {
              "label": "Docs",
              "href": "https://keras.io/keras_hub/api/base_classes/text_classifier/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F250"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F252"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://keras.io/keras_hub/api/base_classes/text_classifier/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F243"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F260"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F261"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/keras-team/keras-io",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F260"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def preprocess(x, y=None, sequence_length=256):\n    x = tokenizer(x)\n    x = packer(x, sequence_length=sequence_length)\n    x = {\n        \"token_ids\": x,\n        \"padding_mask\": x != tokenizer.pad_token_id,\n    }\n    return keras.utils.pack_x_y_sample_weight(x, y)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/keras-team/keras-io/blob/f5891b3cd4df69f6bd5a3c26ea92310f3a973626/guides/keras_hub/getting_started.py#L637-L644",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F259"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=keras-hub%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F243"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import os\nos.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\nimport tensorflow as tf\nimport keras_hub\n\ntraining = tf.data.Dataset.from_tensor_slices(\n    ([\"invoice payment\", \"reset password\"], [0, 1])\n).batch(2)\nclassifier = keras_hub.models.TextClassifier.from_preset(\"bert_tiny_en_uncased\", num_classes=2)\nclassifier.fit(training, epochs=1)\nprint(classifier.predict([\"invoice\"]))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://keras.io/keras_hub/api/base_classes/text_classifier/",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F248"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python text classification library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#scikit-learn",
          "label": [
            {
              "t": "text",
              "text": "scikit-learn"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits pipelines that combine text features with a classifier and structured data. "
        },
        {
          "t": "link",
          "href": "#transformers",
          "label": [
            {
              "t": "text",
              "text": "Transformers"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits fine-tuned sequence classifiers and zero-shot labels chosen at prediction time. "
        },
        {
          "t": "link",
          "href": "#fasttext",
          "label": [
            {
              "t": "text",
              "text": "fastText"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits compact supervised classifiers trained from labeled examples."
        }
      ]
    },
    {
      "q": "What is fastText?",
      "a": [
        {
          "t": "link",
          "href": "#fasttext",
          "label": [
            {
              "t": "text",
              "text": "fastText"
            }
          ]
        },
        {
          "t": "text",
          "text": " trains supervised text classifiers that return labels with probabilities. It can compress trained classifier files, and its upstream repository is archived."
        }
      ]
    },
    {
      "q": "What is zero-shot classification?",
      "a": [
        {
          "t": "text",
          "text": "A zero-shot pipeline in "
        },
        {
          "t": "link",
          "href": "#transformers",
          "label": [
            {
              "t": "text",
              "text": "Transformers"
            }
          ]
        },
        {
          "t": "text",
          "text": " scores candidate labels chosen at runtime. It needs a model fine-tuned for natural language inference rather than an arbitrary language model."
        }
      ]
    },
    {
      "q": "How does scikit-learn classify text?",
      "a": [
        {
          "t": "link",
          "href": "#scikit-learn",
          "label": [
            {
              "t": "text",
              "text": "scikit-learn"
            }
          ]
        },
        {
          "t": "text",
          "text": " combines a text feature vectorizer with a classifier in one pipeline. Unigram bag-of-words features disregard word order."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, scikit-learn",
      "display": "scikit-learn",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, scikit-learn",
      "display": "211.6M",
      "asOf": "2026-11-17"
    },
    "F3": {
      "label": "License, scikit-learn",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, scikit-learn",
      "display": "1.9.1, Sep 2026",
      "asOf": "2026-09-10"
    },
    "F5": {
      "label": "Package release date, scikit-learn",
      "display": "Sep 2026",
      "asOf": "2026-09-10"
    },
    "F6": {
      "label": "Repository stars, scikit-learn",
      "display": "68.2K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Custom label training, scikit-learn",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Multi-label output, scikit-learn",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Batch prediction, scikit-learn",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Install, scikit-learn",
      "display": "pip install scikit-learn",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "What it does, scikit-learn",
      "display": "Combines a text feature vectorizer with a classifier in a pipeline.",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "strengths lead, scikit-learn",
      "display": "Combines text with structured features",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths, scikit-learn",
      "display": "Transform separate input columns and concatenate their features before classification.",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths lead, scikit-learn",
      "display": "Tunes complete text pipelines",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths, scikit-learn",
      "display": "Search vectorizer and classifier settings together.",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "limitations lead, scikit-learn",
      "display": "Unigrams lose word order",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations, scikit-learn",
      "display": "Use word n-grams when short phrases carry the label.",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "Quickstart, scikit-learn",
      "display": "\"\"\"\n==========================================================\nSample pipeline for text feature extraction and evaluation\n==========================================================\n\nThe dataset used in this example is :ref:`20newsgroups_dataset` which will be\nautomatically downloaded, cached and reused for the document classification\nexample.\n\nIn this example, we tune the hyperparameters of a particular classifier using a\n:class:`~sklearn.model_selection.RandomizedSearchCV`. For a demo on the\nperformance of some other classifiers, see the\n:ref:`sphx_glr_auto_examples_text_plot_document_classification_20newsgroups.py`\nnotebook.\n\"\"\"\n\n# Authors: The scikit-learn developers\n# SPDX-License-Identifier: BSD-3-Clause\n\n# %%\n# Data loading\n# ------------\n# We load two categories from the training set. You can adjust the number of\n# categories by adding their names to the list or setting `categories=None` when\n# calling the dataset loader :func:`~sklearn.datasets.fetch_20newsgroups` to get\n# the 20 of them.\n\nfrom sklearn.datasets import fetch_20newsgroups\n\ncategories = [\n    \"alt.atheism\",\n    \"talk.religion.misc\",\n]\n\ndata_train = fetch_20newsgroups(\n    subset=\"train\",\n    categories=categories,\n    shuffle=True,\n    random_state=42,\n    remove=(\"headers\", \"footers\", \"quotes\"),\n)\n\ndata_test = fetch_20newsgroups(\n    subset=\"test\",\n    categories=categories,\n    shuffle=True,\n    random_state=42,\n    remove=(\"headers\", \"footers\", \"quotes\"),\n)\n\nprint(f\"Loading 20 newsgroups dataset for {len(data_train.target_names)} categories:\")\nprint(data_train.target_names)\nprint(f\"{len(data_train.data)} documents\")\n\n# %%\n# Pipeline with hyperparameter tuning\n# -----------------------------------\n#\n# We define a pipeline combining a text feature vectorizer with a simple\n# classifier yet effective for text classification.\n\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.naive_bayes import ComplementNB\nfrom sklearn.pipeline import Pipeline\n\npipeline = Pipeline(\n    [\n        (\"vect\", TfidfVectorizer()),\n        (\"clf\", ComplementNB()),\n    ]\n)\npipeline\n\n# %%\n# We define a grid of hyperparameters to be explored by the\n# :class:`~sklearn.model_selection.RandomizedSearchCV`. Using a\n# :class:`~sklearn.model_selection.GridSearchCV` instead would explore all the\n# possible combinations on the grid, which can be costly to compute, whereas the\n# parameter `n_iter` of the :class:`~sklearn.model_selection.RandomizedSearchCV`\n# controls the number of different random combination that are evaluated. Notice\n# that setting `n_iter` larger than the number of possible combinations in a\n# grid would lead to repeating already-explored combinations. We search for the\n# best parameter combination for both the feature extraction (`vect__`) and the\n# classifier (`clf__`).\n\nimport numpy as np\n\nparameter_grid = {\n    \"vect__max_df\": (0.2, 0.4, 0.6, 0.8, 1.0),\n    \"vect__min_df\": (1, 3, 5, 10),\n    \"vect__ngram_range\": ((1, 1), (1, 2)),  # unigrams or bigrams\n    \"vect__norm\": (\"l1\", \"l2\"),\n    \"clf__alpha\": np.logspace(-6, 6, 13),\n}\n\n# %%\n# In this case `n_iter=40` is not an exhaustive search of the hyperparameters'\n# grid. In practice it would be interesting to increase the parameter `n_iter`\n# to get a more informative analysis. As a consequence, the computional time\n# increases. We can reduce it by taking advantage of the parallelisation over\n# the parameter combinations evaluation by increasing the number of CPUs used\n# via the parameter `n_jobs`.\n\nfrom pprint import pprint\n\nfrom sklearn.model_selection import RandomizedSearchCV\n\nrandom_search = RandomizedSearchCV(\n    estimator=pipeline,\n    param_distributions=parameter_grid,\n    n_iter=40,\n    random_state=0,\n    n_jobs=2,\n    verbose=1,\n)\n\nprint(\"Performing grid search...\")\nprint(\"Hyperparameters to be evaluated:\")\npprint(parameter_grid)\n\n# %%\nfrom time import time\n\nt0 = time()\nrandom_search.fit(data_train.data, data_train.target)\nprint(f\"Done in {time() - t0:.3f}s\")\n\n# %%\nprint(\"Best parameters combination found:\")\nbest_parameters = random_search.best_estimator_.get_params()\nfor param_name in sorted(parameter_grid.keys()):\n    print(f\"{param_name}: {best_parameters[param_name]}\")\n\n# %%\ntest_accuracy = random_search.score(data_test.data, data_test.target)\nprint(\n    \"Accuracy of the best parameters using the inner CV of \"\n    f\"the random search: {random_search.best_score_:.3f}\"\n)\nprint(f\"Accuracy on test set: {test_accuracy:.3f}\")\n\n# %%\n# The prefixes `vect` and `clf` are required to avoid possible ambiguities in\n# the pipeline, but are not necessary for visualizing the results. Because of\n# this, we define a function that will rename the tuned hyperparameters and\n# improve the readability.\n\nimport pandas as pd\n\n\ndef shorten_param(param_name):\n    \"\"\"Remove components' prefixes in param_name.\"\"\"\n    if \"__\" in param_name:\n        return param_name.rsplit(\"__\", 1)[1]\n    return param_name\n\n\ncv_results = pd.DataFrame(random_search.cv_results_)\ncv_results = cv_results.rename(shorten_param, axis=1)\n\n# %%\n# We can use a `plotly.express.scatter\n# <https://plotly.com/python-api-reference/generated/plotly.express.scatter.html>`_\n# to visualize the trade-off between scoring time and mean test score (i.e. \"CV\n# score\"). Passing the cursor over a given point displays the corresponding\n# parameters. Error bars correspond to one standard deviation as computed in the\n# different folds of the cross-validation.\n\nimport plotly.express as px\n\nparam_names = [shorten_param(name) for name in parameter_grid.keys()]\nlabels = {\n    \"mean_score_time\": \"CV Score time (s)\",\n    \"mean_test_score\": \"CV score (accuracy)\",\n}\nfig = px.scatter(\n    cv_results,\n    x=\"mean_score_time\",\n    y=\"mean_test_score\",\n    error_x=\"std_score_time\",\n    error_y=\"std_test_score\",\n    hover_data=param_names,\n    labels=labels,\n)\nfig.update_layout(\n    title={\n        \"text\": \"trade-off between scoring time and mean test score\",\n        \"y\": 0.95,\n        \"x\": 0.5,\n        \"xanchor\": \"center\",\n        \"yanchor\": \"top\",\n    }\n)\nfig\n\n# %%\n# Notice that the cluster of models in the upper-left corner of the plot have\n# the best trade-off between accuracy and scoring time. In this case, using\n# bigrams increases the required scoring time without improving considerably the\n# accuracy of the pipeline.\n#\n# .. note:: For more information on how to customize an automated tuning to\n#    maximize score and minimize scoring time, see the example notebook\n#    :ref:`sphx_glr_auto_examples_model_selection_plot_grid_search_digits.py`.\n#\n# We can also use a `plotly.express.parallel_coordinates\n# <https://plotly.com/python-api-reference/generated/plotly.express.parallel_coordinates.html>`_\n# to further visualize the mean test score as a function of the tuned\n# hyperparameters. This helps finding interactions between more than two\n# hyperparameters and provide intuition on their relevance for improving the\n# performance of a pipeline.\n#\n# We apply a `math.log10` transformation on the `alpha` axis to spread the\n# active range and improve the readability of the plot. A value :math:`x` on\n# said axis is to be understood as :math:`10^x`.\n\nimport math\n\ncolumn_results = param_names + [\"mean_test_score\", \"mean_score_time\"]\n\ntransform_funcs = dict.fromkeys(column_results, lambda x: x)\n# Using a logarithmic scale for alpha\ntransform_funcs[\"alpha\"] = math.log10\n# L1 norms are mapped to index 1, and L2 norms to index 2\ntransform_funcs[\"norm\"] = lambda x: 2 if x == \"l2\" else 1\n# Unigrams are mapped to index 1 and bigrams to index 2\ntransform_funcs[\"ngram_range\"] = lambda x: x[1]\n\nfig = px.parallel_coordinates(\n    cv_results[column_results].apply(transform_funcs),\n    color=\"mean_test_score\",\n    color_continuous_scale=px.colors.sequential.Viridis_r,\n    labels=labels,\n)\nfig.update_layout(\n    title={\n        \"text\": \"Parallel coordinates plot of text classifier pipeline\",\n        \"y\": 0.99,\n        \"x\": 0.5,\n        \"xanchor\": \"center\",\n        \"yanchor\": \"top\",\n    }\n)\nfig\n\n# %%\n# The parallel coordinates plot displays the values of the hyperparameters on\n# different columns while the performance metric is color coded. It is possible\n# to select a range of results by clicking and holding on any axis of the\n# parallel coordinate plot. You can then slide (move) the range selection and\n# cross two selections to see the intersections. You can undo a selection by\n# clicking once again on the same axis.\n#\n# In particular for this hyperparameter search, it is interesting to notice that\n# the top performing models do not seem to depend on the regularization `norm`,\n# but they do depend on a trade-off between `max_df`, `min_df` and the\n# regularization strength `alpha`. The reason is that including noisy features\n# (i.e. `max_df` close to :math:`1.0` or `min_df` close to :math:`0`) tend to\n# overfit and therefore require a stronger regularization to compensate. Having\n# less features require less regularization and less scoring time.\n#\n# The best accuracy scores are obtained when `alpha` is between :math:`10^{-6}`\n# and :math:`10^0`, regardless of the hyperparameter `norm`.\n",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "Project function, scikit-learn",
      "display": "def __init__(self, lemmatization=False):\n    BugModel.__init__(self, lemmatization)\n\n    self.cross_validation_enabled = False\n    self.calculate_importance = False\n    # The test set is made of the most recent bugs (see train_test_split), so\n    # retrain on all bugs after the evaluation.\n    self.entire_dataset_training = True\n\n    feature_extractors = [\n        bug_features.HasSTR(),\n        bug_features.Severity(),\n        bug_features.Keywords(),\n        bug_features.HasCrashSignature(),\n        bug_features.HasURL(),\n        bug_features.HasW3CURL(),\n        bug_features.HasGithubURL(),\n        bug_features.Whiteboard(),\n        bug_features.Patches(),\n        bug_features.Landings(),\n        bug_features.BugReporter(),\n        # Bugs are rolled back to their creation, so this is the product the bug\n        # was filed in.\n        bug_features.Product(),\n        bug_features.OpSys(),\n        bug_features.Platform(),\n        bug_features.MentionedPathsComponents(),\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    )\n\n    # A linear model on sparse n-gram features is more accurate (and faster\n    # to train) than gradient boosted trees for this task. The L1 penalty\n    # keeps the weights sparse, so the model stays small despite the large\n    # vocabulary. Probabilities are calibrated on out-of-fold predictions.\n    estimator = CalibratedClassifierCV(\n        LinearSVC(penalty=\"l1\", dual=False),\n        method=\"isotonic\",\n        cv=3,\n        ensemble=False,\n        n_jobs=3,\n    )\n\n    self.clf = Pipeline(\n        [\n            (\n                \"union\",\n                ColumnTransformer(\n                    [\n                        (\"data\", DictVectorizer(), \"data\"),\n                        (\n                            \"title\",\n                            self.text_vectorizer(\n                                min_df=2,\n                                ngram_range=(1, 2),\n                                sublinear_tf=True,\n                                max_features=30000,\n                            ),\n                            \"title\",\n                        ),\n                        (\n                            \"title_char\",\n                            TfidfVectorizer(\n                                min_df=3,\n                                analyzer=\"char_wb\",\n                                ngram_range=(2, 5),\n                                sublinear_tf=True,\n                                max_features=30000,\n                            ),\n                            \"title\",\n                        ),\n                        (\n                            \"comments\",\n                            self.text_vectorizer(\n                                min_df=2,\n                                ngram_range=(1, 2),\n                                sublinear_tf=True,\n                                max_features=80000,\n                            ),\n                            \"comments\",\n                        ),\n                    ]\n                ),\n            ),\n            (\n                \"estimator\",\n                estimator,\n            ),\n        ]\n    )\n",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "Project function reference, scikit-learn",
      "display": "component.py · __init__()",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Project repository, scikit-learn",
      "display": "mozilla/bugbug",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project stars, mozilla/bugbug",
      "display": "581",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project push date, mozilla/bugbug",
      "display": "Nov 2026",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Library name, transformers",
      "display": "Transformers",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Monthly downloads, transformers",
      "display": "118.0M",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "License, transformers",
      "display": "Apache 2.0 License",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Package release, transformers",
      "display": "5.23.0, Nov 2026",
      "asOf": "2026-11-13"
    },
    "F28": {
      "label": "Package release date, transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-13"
    },
    "F29": {
      "label": "Repository stars, transformers",
      "display": "169.1K",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Custom label training, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F31": {
      "label": "Multi-label output, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Batch prediction, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Install, transformers",
      "display": "pip install transformers",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "What it does, transformers",
      "display": "Scores runtime candidate labels through sequence models trained for natural language inference.",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "strengths lead, transformers",
      "display": "Accepts labels at prediction time",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "strengths, transformers",
      "display": "Choose candidate classes without fixing the output labels during model training.",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "strengths lead, transformers",
      "display": "Fine-tunes sequence classifiers",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths, transformers",
      "display": "Train a classification model with the task’s label mappings.",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "limitations lead, transformers",
      "display": "Zero-shot needs entailment models",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "limitations, transformers",
      "display": "Use models trained to judge whether text supports a candidate label.",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "limitations lead, transformers",
      "display": "Long zero-shot inputs are truncated",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "limitations, transformers",
      "display": "Split long documents before candidate-label scoring.",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "Quickstart, transformers",
      "display": "from transformers import pipeline\noracle = pipeline(model=\"facebook/bart-large-mnli\")\noracle(\n    \"I have a problem with my iphone that needs to be resolved asap!!\",\n    candidate_labels=[\"urgent\", \"not urgent\", \"phone\", \"tablet\", \"computer\"],\n)\noracle(\n    \"I have a problem with my iphone that needs to be resolved asap!!\",\n    candidate_labels=[\"english\", \"german\"],\n)\n",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "Project function, transformers",
      "display": "def run(self, text: str) -> dict[str, str]:\n    \"\"\"\n    Routes the text strings to different connections based on a category label.\n\n    :param text: A string of text to route.\n    :returns:\n        A dictionary with the label as key and the text as value.\n\n    :raises TypeError:\n        If the input is not a str.\n    :raises RuntimeError:\n        If the pipeline has not been loaded because warm_up() was not called before.\n    \"\"\"\n    if self.pipeline is None:\n        raise RuntimeError(\n            \"The component TransformersZeroShotTextRouter wasn't warmed up. Run 'warm_up()' before calling 'run()'.\"\n        )\n\n    if not isinstance(text, str):\n        raise TypeError(\"TransformersZeroShotTextRouter expects a str as input.\")\n\n    prediction = self.pipeline([text], candidate_labels=self.labels, multi_label=self.multi_label)\n    predicted_scores = prediction[0][\"scores\"]\n    max_score_index = max(range(len(predicted_scores)), key=predicted_scores.__getitem__)\n    label = prediction[0][\"labels\"][max_score_index]\n    return {label: text}\n",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "Project function reference, transformers",
      "display": "zero_shot_text_router.py · run()",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Project repository, transformers",
      "display": "deepset-ai/haystack",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project stars, deepset-ai/haystack",
      "display": "27.0K",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project push date, deepset-ai/haystack",
      "display": "Nov 2026",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Library name, fasttext",
      "display": "fastText",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Monthly downloads, fasttext",
      "display": "2.2M",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "License, fasttext",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F52": {
      "label": "Package release, fasttext",
      "display": "0.9.3, Jun 2024",
      "asOf": "2024-06-12"
    },
    "F53": {
      "label": "Package release date, fasttext",
      "display": "Jun 2024",
      "asOf": "2024-06-12"
    },
    "F54": {
      "label": "Repository stars, fasttext",
      "display": "26.5K",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Custom label training, fasttext",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Multi-label output, fasttext",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "Batch prediction, fasttext",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Install, fasttext",
      "display": "pip install fasttext",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "What it does, fasttext",
      "display": "Trains supervised text classifiers through train_supervised.",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "strengths lead, fasttext",
      "display": "Returns labels with probabilities",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "strengths, fasttext",
      "display": "Use predict to retrieve labels and their corresponding probabilities.",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "strengths lead, fasttext",
      "display": "Compresses trained classifier files",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "strengths, fasttext",
      "display": "Quantize supervised models after training to reduce their stored size.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "limitations lead, fasttext",
      "display": "Upstream repository is archived",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "limitations, fasttext",
      "display": "The original repository is now read-only.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "limitations lead, fasttext",
      "display": "Needs labeled training examples",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "limitations, fasttext",
      "display": "Supply documents with their corresponding category labels before training.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "Quickstart, fasttext",
      "display": "import fasttext\n\nmodel = fasttext.train_supervised('data.train.txt')\n",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "Project function, fasttext",
      "display": "def main():\n    args = get_args()\n    random.seed(args.seed)\n    train_input = args.input\n\n    train_was_split = False\n    if args.valid_input:\n        valid_input = args.valid_input\n    elif args.valid_frac > 0:\n        train_input, valid_input = split_train_val(train_input, args.valid_frac)\n        train_was_split = True\n    else:\n        valid_input = None\n\n    hyperparams = {'lr': args.lr, 'dim': args.dim, 'ws': args.ws, 'epoch': args.epoch, 'minCount': args.minCount, 'wordNgrams': args.wordNgrams}\n    model = fasttext.train_supervised(input=train_input, **hyperparams)\n\n    print(\"Training results\")\n    print_results(*model.test(train_input))\n\n    if valid_input is not None:\n        print(\"Validation results\")\n        print_results(*model.test(valid_input))\n\n    # Save the model\n    output = args.name if args.name.endswith(\".bin\") else args.name + \".bin\"\n    model.save_model(os.path.join(args.output_dir, output))\n\n    if train_was_split:\n        os.remove(train_input)\n        os.remove(valid_input)\n",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Project function reference, fasttext",
      "display": "train_fasttext_classifier.py · main()",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "Project repository, fasttext",
      "display": "mlfoundations/dclm",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Project stars, mlfoundations/dclm",
      "display": "1.5K",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project push date, mlfoundations/dclm",
      "display": "Sep 2025",
      "asOf": "2025-09-09"
    },
    "F74": {
      "label": "Library name, setfit",
      "display": "SetFit",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Monthly downloads, setfit",
      "display": "133.6K",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "License, setfit",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Package release, setfit",
      "display": "1.2.0, Sep 2026",
      "asOf": "2026-09-04"
    },
    "F78": {
      "label": "Package release date, setfit",
      "display": "Sep 2026",
      "asOf": "2026-09-04"
    },
    "F79": {
      "label": "Repository stars, setfit",
      "display": "2.9K",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Custom label training, setfit",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Multi-label output, setfit",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "Batch prediction, setfit",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "Install, setfit",
      "display": "pip install setfit",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "What it does, setfit",
      "display": "Pairs a sentence-embedding model with a separate classification head.",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "strengths lead, setfit",
      "display": "Adapts pretrained sentence embeddings",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "strengths, setfit",
      "display": "Fine-tune the encoder to align its embeddings with the classification task.",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "strengths lead, setfit",
      "display": "Assigns multiple labels per text",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "strengths, setfit",
      "display": "Choose a multilabel strategy when several categories can apply.",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "limitations lead, setfit",
      "display": "Differentiable heads need numeric labels",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "limitations, setfit",
      "display": "Encode class names as consecutive integers before training that head.",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "Quickstart, setfit",
      "display": "from setfit import SetFitModel, Trainer, TrainingArguments, sample_dataset\nfrom datasets import load_dataset\n\n# Initializing a new SetFit model\nmodel = SetFitModel.from_pretrained(\"BAAI/bge-small-en-v1.5\", labels=[\"negative\", \"positive\"])\n\n# Preparing the dataset\ndataset = load_dataset(\"SetFit/sst2\")\ntrain_dataset = sample_dataset(dataset[\"train\"], label_column=\"label\", num_samples=8)\ntest_dataset = dataset[\"test\"]\n\n# Preparing the training arguments\nargs = TrainingArguments(\n    batch_size=32,\n    num_epochs=10,\n)\n\n# Preparing the trainer\ntrainer = Trainer(\n    model=model,\n    args=args,\n    train_dataset=train_dataset,\n)\ntrainer.train()\n\n# Evaluating\nmetrics = trainer.evaluate(test_dataset)\nprint(metrics)\n# => {'accuracy': 0.8511806699615596}\n\n# Saving the trained model\nmodel.save_pretrained(\"setfit-bge-small-v1.5-sst2-8-shot\")\n# or\nmodel.push_to_hub(\"tomaarsen/setfit-bge-small-v1.5-sst2-8-shot\")\n\n# Loading a trained model\nmodel = SetFitModel.from_pretrained(\"tomaarsen/setfit-bge-small-v1.5-sst2-8-shot\") # Load from the Hugging Face Hub\n# or\nmodel = SetFitModel.from_pretrained(\"setfit-bge-small-v1.5-sst2-8-shot\") # Load from a local directory\n\n# Performing inference\npreds = model.predict([\n    \"It's a charming and often affecting journey.\",\n    \"It's slow -- very, very slow.\",\n    \"A sometimes tedious film.\",\n])\nprint(preds)\n# => [\"positive\", \"negative\", \"negative\"]\n",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "Developer need",
      "display": "Combining text with structured features",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "Why choose scikit-learn",
      "display": "native column transforms and sparse features",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "Developer need in introduction",
      "display": "combining text with structured features",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "When to consider transformers",
      "display": "candidate categories must change at prediction time",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Developer need",
      "display": "Selecting new labels at prediction time",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Why choose transformers",
      "display": "runtime candidate-label inference",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Developer need in introduction",
      "display": "selecting new labels at prediction time",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "When to consider scikit-learn",
      "display": "structured columns accompany text",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Developer need",
      "display": "Training and compressing file-based classifiers",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Why choose fasttext",
      "display": "native supervised-model quantization",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "Developer need in introduction",
      "display": "training and compressing file-based classifiers",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "When to consider setfit",
      "display": "adapting pretrained sentence embeddings",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need",
      "display": "Adapting pretrained sentence embeddings",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Why choose setfit",
      "display": "task-specific sentence embedding fine-tuning",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Developer need in introduction",
      "display": "adapting pretrained sentence embeddings",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "When to consider transformers",
      "display": "choosing unseen labels at inference time",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Page introduction",
      "display": "Python text classification libraries let text-processing developers assign categories to text.",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "FAQ: Can scikit-learn combine document text with other columns?",
      "display": "ColumnTransformer transforms input columns separately and joins their generated features.",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "FAQ: Do unigram classifiers retain phrase order?",
      "display": "Unigram bag-of-words features disregard word order and cannot capture multi-word expressions.",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "FAQ: How can scikit-learn assign multiple labels?",
      "display": "MultiOutputClassifier fits one classifier per target to extend ordinary classifiers to multilabel output.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: Can Transformers candidate labels change at prediction time?",
      "display": "The zero-shot classification pipeline accepts classes chosen at runtime.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: Does Transformers zero-shot classification accept any language model?",
      "display": "Use a model fine-tuned for natural language inference, rather than an arbitrary language model.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: What changes when Transformers multi_label is enabled?",
      "display": "The pipeline considers labels independently instead of normalizing their scores across the candidate set.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: What training data does fastText classification need?",
      "display": "Training requires documents paired with their category labels.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Can fastText handle multiple labels independently?",
      "display": "Choose the one-vs-all loss for independent binary classifiers per label.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Can fastText predict labels for a batch of texts?",
      "display": "Pass an array of strings to predict several texts.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: What parts of a SetFit model are trained?",
      "display": "SetFit separately fine-tunes sentence embeddings and trains its classifier head.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Which classifier head does SetFit use by default?",
      "display": "A new model uses a scikit-learn logistic regression classification head by default.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Can a SetFit differentiable head train on string labels?",
      "display": "Its differentiable head requires consecutive integer class IDs; the default logistic regression head differs.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "Library name, scikit-learn",
      "display": "scikit-learn",
      "asOf": "2026-11-20"
    },
    "F122": {
      "label": "Monthly downloads, scikit-learn",
      "display": "214.9M",
      "asOf": "2026-11-20"
    },
    "F123": {
      "label": "License, scikit-learn",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F124": {
      "label": "Package release, scikit-learn",
      "display": "1.9.1",
      "asOf": "2026-11-20"
    },
    "F125": {
      "label": "Package release date, scikit-learn",
      "display": "Sep 2026",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "Install, scikit-learn",
      "display": "python -m pip install scikit-learn==1.9.1",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "Quickstart, scikit-learn",
      "display": "from sklearn.pipeline import Pipeline\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.linear_model import LogisticRegression\n\nmodel = Pipeline([(\"text\", TfidfVectorizer()), (\"classifier\", LogisticRegression())])\nmodel.fit([\"invoice due\", \"pay invoice\", \"reset password\", \"forgot password\"],\n          [\"billing\", \"billing\", \"account\", \"account\"])\nprint(model.predict([\"invoice\"]))\n",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Repository stars, scikit-learn",
      "display": "68.2K",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Zero-shot custom labels, scikit-learn",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "CSR feature input, scikit-learn",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Input representation, scikit-learn",
      "display": "Text vectorizers produce sparse document features; ColumnTransformer combines separate feature columns",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Learning/labels, scikit-learn",
      "display": "Estimator fit learns the supplied target categories; native sparse linear classifiers and calibration are available",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Project function, scikit-learn",
      "display": "def __init__(self, lemmatization=False):\n    BugModel.__init__(self, lemmatization)\n\n    self.cross_validation_enabled = False\n    self.calculate_importance = False\n    # The test set is made of the most recent bugs (see train_test_split), so\n    # retrain on all bugs after the evaluation.\n    self.entire_dataset_training = True\n\n    feature_extractors = [\n        bug_features.HasSTR(),\n        bug_features.Severity(),\n        bug_features.Keywords(),\n        bug_features.HasCrashSignature(),\n        bug_features.HasURL(),\n        bug_features.HasW3CURL(),\n        bug_features.HasGithubURL(),\n        bug_features.Whiteboard(),\n        bug_features.Patches(),\n        bug_features.Landings(),\n        bug_features.BugReporter(),\n        # Bugs are rolled back to their creation, so this is the product the bug\n        # was filed in.\n        bug_features.Product(),\n        bug_features.OpSys(),\n        bug_features.Platform(),\n        bug_features.MentionedPathsComponents(),\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    )\n\n    # A linear model on sparse n-gram features is more accurate (and faster\n    # to train) than gradient boosted trees for this task. The L1 penalty\n    # keeps the weights sparse, so the model stays small despite the large\n    # vocabulary. Probabilities are calibrated on out-of-fold predictions.\n    estimator = CalibratedClassifierCV(\n        LinearSVC(penalty=\"l1\", dual=False),\n        method=\"isotonic\",\n        cv=3,\n        ensemble=False,\n        n_jobs=3,\n    )\n\n    self.clf = Pipeline(\n        [\n            (\n                \"union\",\n                ColumnTransformer(\n                    [\n                        (\"data\", DictVectorizer(), \"data\"),\n                        (\n                            \"title\",\n                            self.text_vectorizer(\n                                min_df=2,\n                                ngram_range=(1, 2),\n                                sublinear_tf=True,\n                                max_features=30000,\n                            ),\n                            \"title\",\n                        ),\n                        (\n                            \"title_char\",\n                            TfidfVectorizer(\n                                min_df=3,\n                                analyzer=\"char_wb\",\n                                ngram_range=(2, 5),\n                                sublinear_tf=True,\n                                max_features=30000,\n                            ),\n                            \"title\",\n                        ),\n                        (\n                            \"comments\",\n                            self.text_vectorizer(\n                                min_df=2,\n                                ngram_range=(1, 2),\n                                sublinear_tf=True,\n                                max_features=80000,\n                            ),\n                            \"comments\",\n                        ),\n                    ]\n                ),\n            ),\n            (\n                \"estimator\",\n                estimator,\n            ),\n        ]\n    )",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Project source file, scikit-learn",
      "display": "bugbug/models/component.py",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Project full_name, scikit-learn",
      "display": "mozilla/bugbug",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Project stargazers_count, scikit-learn",
      "display": "581",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Library name, transformers",
      "display": "Transformers",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Monthly downloads, transformers",
      "display": "120.5M",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "License, transformers",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Package release, transformers",
      "display": "5.23.0",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Package release date, transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Install, transformers",
      "display": "python -m pip install 'transformers[torch]==5.23.0'",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Quickstart, transformers",
      "display": "from transformers import pipeline\n\nclassifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-large-mnli\", device=-1)\nprint(classifier(\"Please reset my password\", candidate_labels=[\"billing\", \"account\"]))\n",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Repository stars, transformers",
      "display": "169.1K",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Zero-shot custom labels, transformers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "CSR feature input, transformers",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Input representation, transformers",
      "display": "NLI-backed zero-shot pipeline takes whole text and runtime candidate_labels",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Output contract, transformers",
      "display": "Labels are sorted by likelihood and aligned with numeric scores; multi_label changes normalization",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Model boundary, transformers",
      "display": "Pipeline requires an NLI-trained sequence classifier with entailment in label2id, not an arbitrary embedding model",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Project function, transformers",
      "display": "def run(self, text: str) -> dict[str, str]:\n    \"\"\"\n    Routes the text strings to different connections based on a category label.\n\n    :param text: A string of text to route.\n    :returns:\n        A dictionary with the label as key and the text as value.\n\n    :raises TypeError:\n        If the input is not a str.\n    :raises RuntimeError:\n        If the pipeline has not been loaded because warm_up() was not called before.\n    \"\"\"\n    if self.pipeline is None:\n        raise RuntimeError(\n            \"The component TransformersZeroShotTextRouter wasn't warmed up. Run 'warm_up()' before calling 'run()'.\"\n        )\n\n    if not isinstance(text, str):\n        raise TypeError(\"TransformersZeroShotTextRouter expects a str as input.\")\n\n    prediction = self.pipeline([text], candidate_labels=self.labels, multi_label=self.multi_label)\n    predicted_scores = prediction[0][\"scores\"]\n    max_score_index = max(range(len(predicted_scores)), key=predicted_scores.__getitem__)\n    label = prediction[0][\"labels\"][max_score_index]\n    return {label: text}\n",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Project source file, transformers",
      "display": "haystack/components/routers/zero_shot_text_router.py",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Project full_name, transformers",
      "display": "deepset-ai/haystack",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Project stargazers_count, transformers",
      "display": "27.0K",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Library name, nltk",
      "display": "nltk",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Monthly downloads, nltk",
      "display": "48.7M",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "License, nltk",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Package release, nltk",
      "display": "3.10.4",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Package release date, nltk",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Install, nltk",
      "display": "python -m pip install nltk==3.10.4",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Quickstart, nltk",
      "display": "from nltk.classify import NaiveBayesClassifier\n\ntraining = [({\"invoice\": True}, \"billing\"), ({\"password\": True}, \"account\")]\nclassifier = NaiveBayesClassifier.train(training)\nprint(classifier.classify({\"invoice\": True}))\n",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Official description, nltk",
      "display": "Provides a natural language toolkit.",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Quickstart source file, nltk",
      "display": "nltk.classify.naivebayes.html",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Repository stars, nltk",
      "display": "14.8K",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Zero-shot custom labels, nltk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "CSR feature input, nltk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Input representation, nltk",
      "display": "Classifier training samples couple extracted feature sets with category labels",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Model interface, nltk",
      "display": "Naive Bayes estimates category likelihoods from labeled feature dictionaries",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Project function, nltk",
      "display": "def train(self, *args, **kwargs):\n    \"\"\"Train the classifier with a labeled feature set and return\n    the classifier. Takes the same arguments as the wrapped NLTK class.\n    This method is implicitly called when calling ``classify`` or\n    ``accuracy`` methods and is included only to allow passing in arguments\n    to the ``train`` method of the wrapped NLTK class.\n\n    .. versionadded:: 0.6.2\n\n    :rtype: A classifier\n    \"\"\"\n    try:\n        self.classifier = self.nltk_class.train(\n            self.train_features, *args, **kwargs\n        )\n        return self.classifier\n    except AttributeError as error:\n        raise ValueError(\n            \"NLTKClassifier must have a nltk_class variable that is not None.\"\n        ) from error",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Project source file, nltk",
      "display": "src/textblob/classifiers.py",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Project full_name, nltk",
      "display": "sloria/TextBlob",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Project stargazers_count, nltk",
      "display": "9.6K",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Library name, spacy",
      "display": "spacy",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Monthly downloads, spacy",
      "display": "25.2M",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "License, spacy",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Package release, spacy",
      "display": "3.8.18",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Package release date, spacy",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Install, spacy",
      "display": "python -m pip install spacy==3.8.18",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Quickstart, spacy",
      "display": "import spacy\nfrom spacy.training import Example\n\nnlp = spacy.blank(\"en\")\nnlp.add_pipe(\"textcat\")\nsamples = [(\"invoice payment\", {\"billing\": 1.0, \"account\": 0.0}),\n           (\"reset password\", {\"billing\": 0.0, \"account\": 1.0})]\nexamples = [Example.from_dict(nlp.make_doc(text), {\"cats\": cats}) for text, cats in samples]\noptimizer = nlp.initialize(get_examples=lambda: examples)\nnlp.update(examples, sgd=optimizer)\nprint(nlp(\"invoice\").cats)\n",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Official description, spacy",
      "display": "Processes natural language in Python.",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Quickstart source file, spacy",
      "display": "TextCategorizer; Language",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Repository stars, spacy",
      "display": "34.0K",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Zero-shot custom labels, spacy",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "CSR feature input, spacy",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Input representation, spacy",
      "display": "Whole-document classifier is a trainable pipeline component and writes categories to Doc.cats",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Label semantics, spacy",
      "display": "textcat is exclusive; textcat_multilabel supports independent categories",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Project function, spacy",
      "display": "@prodigy.recipe(\n    \"textcat.teach\",\n    dataset=(\"The dataset to use\", \"positional\", None, str),\n    spacy_model=(\"The base model\", \"positional\", None, str),\n    source=(\"The source data as a JSONL file\", \"positional\", None, str),\n    label=(\"One or more comma-separated labels\", \"option\", \"l\", split_string),\n    patterns=(\"Optional match patterns\", \"option\", \"p\", str),\n    exclude=(\"Names of datasets to exclude\", \"option\", \"e\", split_string),\n)\ndef textcat_teach(\n    dataset: str,\n    spacy_model: str,\n    source: str,\n    label: Optional[List[str]] = None,\n    patterns: Optional[str] = None,\n    exclude: Optional[List[str]] = None,\n):\n    \"\"\"\n    Collect the best possible training data for a text classification model\n    with the model in the loop. Based on your annotations, Prodigy will decide\n    which questions to ask next.\n    \"\"\"\n    labels = label\n    # Load the stream from a JSONL file and return a generator that yields a\n    # dictionary for each example in the data.\n    stream = JSONL(source)\n\n    # Load the spaCy model\n    nlp = spacy.load(spacy_model)\n\n    # Specify the name of the classifier pipeline.\n    name = \"textcat_multilabel\"\n\n    # Initialize classification pipeline from scratch (using a dummy training example) or from the base model if available.\n    if name not in nlp.pipe_names:\n        pipe = nlp.add_pipe(name)\n        # dummy doc\n        doc = nlp.make_doc(\"hello\")\n        # dummy weights\n        cats = {label: 0.5 for label in labels} \n        pipe.initialize(get_examples=lambda: [Example.from_dict(doc, {\"cats\":cats})])\n    else:\n        pipe = nlp.get_pipe(name)\n\n    # Initialize Prodigy's text classifier model, which outputs\n    # (score, example) tuples\n    model = TextClassifier(nlp, labels, name)\n\n    if patterns is None:\n        # No patterns are used, so just use the model to suggest examples\n        # and only use the model's update method as the update callback\n        predict = model\n        update = model.update\n    else:\n        # Initialize the pattern matcher and load in the JSONL patterns.\n        # Set the matcher to not label the highlighted spans, only the text.\n        matcher = PatternMatcher(\n            nlp,\n            prior_correct=5.0,\n            prior_incorrect=5.0,\n            label_span=False,\n            label_task=True,\n        )\n        matcher = matcher.from_disk(patterns)\n        # Combine the NER model and the matcher and interleave their\n        # suggestions and update both at the same time\n        predict, update = combine_models(model, matcher)\n\n    # Use the prefer_uncertain sorter to focus on suggestions that the model\n    # is most uncertain about (i.e. with a score closest to 0.5). The model\n    # yields (score, example) tuples and the sorter yields just the example\n    stream = prefer_uncertain(predict(stream))\n\n    return {\n        \"view_id\": \"classification\",  # Annotation interface to use\n        \"dataset\": dataset,  # Name of dataset to save annotations\n        \"stream\": stream,  # Incoming stream of examples\n        \"update\": update,  # Update callback, called with batch of answers\n        \"exclude\": exclude,  # List of dataset names to exclude\n        \"config\": {\"lang\": nlp.lang},  # Additional config settings, mostly for app UI\n    }",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Project source file, spacy",
      "display": "textcat/textcat_teach.py",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Project full_name, spacy",
      "display": "explosion/prodigy-recipes",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Project stargazers_count, spacy",
      "display": "512",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Library name, catboost",
      "display": "catboost",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Monthly downloads, catboost",
      "display": "6.9M",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "License, catboost",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Package release, catboost",
      "display": "1.2.10",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Package release date, catboost",
      "display": "Feb 2026",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Install, catboost",
      "display": "python -m pip install catboost==1.2.10",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Quickstart, catboost",
      "display": "from catboost import CatBoostClassifier\n\ntexts = [[\"invoice payment\"]] * 10 + [[\"password login\"]] * 10\nlabels = [\"billing\"] * 10 + [\"account\"] * 10\nmodel = CatBoostClassifier(iterations=5, text_features=[0], verbose=False)\nmodel.fit(texts, labels)\nprint(model.predict([[\"invoice payment\"]]))\n",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Official description, catboost",
      "display": "Provides the CatBoost Python package.",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Quickstart source file, catboost",
      "display": "CatBoostClassifier",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Repository stars, catboost",
      "display": "9.2K",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Zero-shot custom labels, catboost",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "CSR feature input, catboost",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Input representation, catboost",
      "display": "Native feature matrices can combine numeric, categorical, text, and embedding columns",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Text preprocessing, catboost",
      "display": "Tokenizers, dictionaries, and feature calcers turn text columns into numeric features",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Vector alternative, catboost",
      "display": "Classifier also accepts precomputed SciPy sparse feature matrices; raw text columns need the documented dense/list/DataFrame input route",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Project function, catboost",
      "display": "def fit_catboost_one_column(X_train, X_test, y_train, y_test, catboost_params={}, verbose=0):\n    learn_pool = Pool(X_train, y_train, text_features=[0])\n    test_pool = Pool(X_test, y_test, text_features=[0])\n    \n    catboost_default_params = {\n        'iterations': 1000,\n        'learning_rate': 0.03,\n        'eval_metric': 'Accuracy',\n    }\n    \n    catboost_default_params.update(catboost_params)\n    \n    model = CatBoostClassifier(**catboost_default_params)\n    model.fit(learn_pool, eval_set=test_pool, verbose=verbose)\n\n    return model",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Project source file, catboost",
      "display": "text_features/text_features_in_catboost.ipynb",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Project full_name, catboost",
      "display": "catboost/tutorials",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Project stargazers_count, catboost",
      "display": "1.1K",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Library name, textblob",
      "display": "textblob",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Monthly downloads, textblob",
      "display": "3.2M",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "License, textblob",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Package release, textblob",
      "display": "0.20.1",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Package release date, textblob",
      "display": "Jul 2026",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Install, textblob",
      "display": "python -m pip install textblob==0.20.1 && python -m textblob.download_corpora",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Quickstart, textblob",
      "display": "from textblob.classifiers import NaiveBayesClassifier\n\ntraining = [(\"invoice payment\", \"billing\"), (\"reset password\", \"account\")]\nclassifier = NaiveBayesClassifier(training)\nprint(classifier.classify(\"invoice\"))\n",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Official description, textblob",
      "display": "Processes text with sentiment analysis, part-of-speech tagging, and noun phrase parsing.",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Quickstart source file, textblob",
      "display": "classifiers.html",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Repository stars, textblob",
      "display": "9.6K",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Zero-shot custom labels, textblob",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "CSR feature input, textblob",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Input representation, textblob",
      "display": "Custom classifier accepts labeled text samples or supported labeled files and a feature_extractor",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Underlying estimator, textblob",
      "display": "NLTKClassifier wraps nltk.classify estimators; this is distinct from default sentiment analysis",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Project function, textblob",
      "display": "def get_tweet_sentiment(self, tweet):\n    '''\n    Utility function to classify sentiment of passed tweet\n    using textblob's sentiment method\n    '''\n    # create TextBlob object of passed tweet text\n    analysis = TextBlob(self.clean_tweet(tweet))\n    # set sentiment\n    if analysis.sentiment.polarity > 0:\n        return 'positive'\n    elif analysis.sentiment.polarity == 0:\n        return 'neutral'\n    else:\n        return 'negative'\n",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Project source file, textblob",
      "display": "Crypto-Trading-Bots/Crypto_Sentiment_Analysis_SocialMedia_Bot.py",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Project full_name, textblob",
      "display": "Roibal/Cryptocurrency-Trading-Bots-Python-Beginner-Advance",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Project stargazers_count, textblob",
      "display": "1.4K",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Library name, fasttext",
      "display": "fastText",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Monthly downloads, fasttext",
      "display": "2.2M",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "License, fasttext",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Package release, fasttext",
      "display": "0.9.3",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Package release date, fasttext",
      "display": "Jun 2024",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Install, fasttext",
      "display": "python -m pip install fasttext==0.9.3",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Quickstart, fasttext",
      "display": "from pathlib import Path\nfrom tempfile import TemporaryDirectory\nimport fasttext\n\nwith TemporaryDirectory() as directory:\n    training = Path(directory) / \"train.txt\"\n    training.write_text(\"__label__billing invoice payment\\n__label__account reset password\\n\", encoding=\"utf-8\")\n    model = fasttext.train_supervised(str(training), minCount=1)\n    print(model.get_labels())\n",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Repository stars, fasttext",
      "display": "26.5K",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Zero-shot custom labels, fasttext",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "CSR feature input, fasttext",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Input representation, fasttext",
      "display": "Supervised training consumes UTF-8 text files with __label__ category prefixes",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Artifacts/evaluation, fasttext",
      "display": "Native supervised models expose test, save_model, and quantization operations",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Project function, fasttext",
      "display": "def main():\n    args = get_args()\n    random.seed(args.seed)\n    train_input = args.input\n\n    train_was_split = False\n    if args.valid_input:\n        valid_input = args.valid_input\n    elif args.valid_frac > 0:\n        train_input, valid_input = split_train_val(train_input, args.valid_frac)\n        train_was_split = True\n    else:\n        valid_input = None\n\n    hyperparams = {'lr': args.lr, 'dim': args.dim, 'ws': args.ws, 'epoch': args.epoch, 'minCount': args.minCount, 'wordNgrams': args.wordNgrams}\n    model = fasttext.train_supervised(input=train_input, **hyperparams)\n\n    print(\"Training results\")\n    print_results(*model.test(train_input))\n\n    if valid_input is not None:\n        print(\"Validation results\")\n        print_results(*model.test(valid_input))\n\n    # Save the model\n    output = args.name if args.name.endswith(\".bin\") else args.name + \".bin\"\n    model.save_model(os.path.join(args.output_dir, output))\n\n    if train_was_split:\n        os.remove(train_input)\n        os.remove(valid_input)\n",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Project source file, fasttext",
      "display": "baselines/train_fasttext_classifier.py",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Project full_name, fasttext",
      "display": "mlfoundations/dclm",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Project stargazers_count, fasttext",
      "display": "1.5K",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Library name, keras-hub",
      "display": "keras-hub",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Monthly downloads, keras-hub",
      "display": "471.7K",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "License, keras-hub",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Package release, keras-hub",
      "display": "0.33.0",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "Package release date, keras-hub",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Install, keras-hub",
      "display": "python -m pip install keras-hub==0.33.0 tensorflow==2.21.0",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Quickstart, keras-hub",
      "display": "import os\nos.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\nimport tensorflow as tf\nimport keras_hub\n\ntraining = tf.data.Dataset.from_tensor_slices(\n    ([\"invoice payment\", \"reset password\"], [0, 1])\n).batch(2)\nclassifier = keras_hub.models.TextClassifier.from_preset(\"bert_tiny_en_uncased\", num_classes=2)\nclassifier.fit(training, epochs=1)\nprint(classifier.predict([\"invoice\"]))\n",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "Official description, keras-hub",
      "display": "Provides pretrained models for Keras.",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Quickstart source file, keras-hub",
      "display": "TextClassifier",
      "asOf": "2026-11-20"
    },
    "F252": {
      "label": "Repository stars, keras-hub",
      "display": "999",
      "asOf": "2026-11-20"
    },
    "F253": {
      "label": "Zero-shot custom labels, keras-hub",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F254": {
      "label": "CSR feature input, keras-hub",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F255": {
      "label": "Input representation, keras-hub",
      "display": "TextClassifier combines a backbone and preprocessor; fit takes string examples with integer class targets",
      "asOf": "2026-11-20"
    },
    "F256": {
      "label": "New-label boundary, keras-hub",
      "display": "Passing num_classes creates a randomly initialized classification head and requires fitting the new categories",
      "asOf": "2026-11-20"
    },
    "F257": {
      "label": "Composable stages, keras-hub",
      "display": "Tokenizer and StartEndPacker can build labeled input batches for a custom classifier head",
      "asOf": "2026-11-20"
    },
    "F258": {
      "label": "Project function, keras-hub",
      "display": "def preprocess(x, y=None, sequence_length=256):\n    x = tokenizer(x)\n    x = packer(x, sequence_length=sequence_length)\n    x = {\n        \"token_ids\": x,\n        \"padding_mask\": x != tokenizer.pad_token_id,\n    }\n    return keras.utils.pack_x_y_sample_weight(x, y)",
      "asOf": "2026-11-20"
    },
    "F259": {
      "label": "Project source file, keras-hub",
      "display": "guides/keras_hub/getting_started.py",
      "asOf": "2026-11-20"
    },
    "F260": {
      "label": "Project full_name, keras-hub",
      "display": "keras-team/keras-io",
      "asOf": "2026-11-20"
    },
    "F261": {
      "label": "Project stargazers_count, keras-hub",
      "display": "3.0K",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python text classification libraries custom labels multilabel zero shot scikit-learn Transformers fastText SetFit code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
