Instructions to use Egrove/keyword-intent-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Egrove/keyword-intent-classifier with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Egrove/keyword-intent-classifier", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Download intent_preprocess.py from Egrove/keyword-intent-classifier: direct link, hf CLI and curl.
- Browser
- Download file 772 Bytes
-
https://huggingface.co/Egrove/keyword-intent-classifier/resolve/main/intent_preprocess.py
- Command line
-
hf download hf://Egrove/keyword-intent-classifier/intent_preprocess.py
-
curl -L -o intent_preprocess.py https://huggingface.co/Egrove/keyword-intent-classifier/resolve/main/intent_preprocess.py
772 Bytes
| """Preprocessing for the keyword intent classifier. | |
| Ship this module alongside keyword_intent_model.pkl. The pickled | |
| TfidfVectorizer references `intent_preprocess.preprocess_text`, so this | |
| module must be importable (on sys.path) before joblib.load(). | |
| """ | |
| import re | |
| import string | |
| def preprocess_text(text): | |
| """Must match the preprocessing used at training time.""" | |
| if text is None: | |
| return "" | |
| text = str(text).lower().strip() | |
| text = re.sub(r"\s+", " ", text) | |
| # keep '+', '#', '.' (e.g. "c++", "c#", ".net"); strip other punctuation | |
| punctuation_to_remove = ( | |
| string.punctuation.replace("+", "").replace("#", "").replace(".", "") | |
| ) | |
| text = text.translate(str.maketrans("", "", punctuation_to_remove)) | |
| return text.strip() | |