Text Classification
Scikit-learn
English
sklearn-tfidf-sgd
banking
intent-classification
tf-idf
scikit-learn
reproducible-research
skops
Instructions to use willykeenan/banking-intent-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use willykeenan/banking-intent-classifier with Scikit-learn:
# ⚠️ Model filename not specified in config.json
- Notebooks
- Google Colab
- Kaggle
Download predict.py from willykeenan/banking-intent-classifier: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/willykeenan/banking-intent-classifier/resolve/main/predict.py
- Command line
-
hf download hf://willykeenan/banking-intent-classifier/predict.py
-
curl -L -o predict.py https://huggingface.co/willykeenan/banking-intent-classifier/resolve/main/predict.py
976 Bytes
| """Predict banking intents with the adjacent local model.skops artifact.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import skops.io as sio | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("text", nargs="+") | |
| parser.add_argument("--model", type=Path, default=Path(__file__).with_name("model.skops")) | |
| args = parser.parse_args() | |
| unexpected = sio.get_untrusted_types(file=args.model) | |
| if unexpected: | |
| raise RuntimeError(f"Unexpected model types: {unexpected}") | |
| model = sio.load(args.model, trusted=[]) | |
| probabilities = model.predict_proba(args.text) | |
| for text, probability in zip(args.text, probabilities): | |
| order = sorted(range(len(model.classes_)), key=lambda i: (-probability[i], model.classes_[i]))[:3] | |
| print(json.dumps({"text": text, "top3": [{"label": str(model.classes_[i]), "score": float(probability[i])} for i in order]})) | |
| if __name__ == "__main__": | |
| main() | |