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
File size: 1,011 Bytes
d9d3b1c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | """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()
|