Text Classification
Scikit-learn
Portuguese
ncm
classificacao-fiscal
agronegocio
scikit-learn
skops
tfidf
Instructions to use AmandaGondra/ncm-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use AmandaGondra/ncm-classifier with Scikit-learn:
# ⚠️ Model filename not specified in config.json
- Notebooks
- Google Colab
- Kaggle
Download inference/predict.py from AmandaGondra/ncm-classifier: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/AmandaGondra/ncm-classifier/resolve/main/inference/predict.py
- Command line
-
hf download hf://AmandaGondra/ncm-classifier/inference/predict.py
-
curl -L -o predict.py https://huggingface.co/AmandaGondra/ncm-classifier/resolve/main/inference/predict.py
1.01 kB
| """Suggest NCM positions for product descriptions with this model. | |
| Usage (from the downloaded model folder): | |
| pip install -r requirements.txt | |
| python inference/predict.py "Ureia agrícola saco 50 kg" "Arame farpado 500 m" | |
| Each description gets the three most likely positions, the calibrated | |
| confidence of the first one, whether it should go to manual review and | |
| whether the 31.05 small-package rule changed it. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from ncm_classifier.inference.predictor import NcmPredictor | |
| EXAMPLES = ["Ureia agrícola granulada, saco 50 kg", "Ureia agrícola, pacote 1 kg"] | |
| def main() -> None: | |
| texts = sys.argv[1:] or EXAMPLES | |
| predictor = NcmPredictor.from_directory(Path(__file__).resolve().parents[1]) | |
| for text, prediction in zip(texts, predictor.predict(texts), strict=True): | |
| print(json.dumps({"text": text, **prediction.to_dict()}, ensure_ascii=False, indent=2)) | |
| if __name__ == "__main__": | |
| main() | |