document-classifier-xgb
1
license:mit
by
vidyasagar786
Other
OTHER
New
0 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
Unknown
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Code Examples
🚀 Quick Startpython
import joblib
# Load the model bundle
bundle = joblib.load("document_classifier_xgb.pkl")
model = bundle["model"]
word_vectorizer = bundle["word_vectorizer"]
char_vectorizer = bundle["char_vectorizer"]
scaler = bundle["scaler"]
from scipy.sparse import hstack, csr_matrix
import numpy as np
def predict(text: str) -> int:
word_feat = word_vectorizer.transform([text])
char_feat = char_vectorizer.transform([text])
num_feat = scaler.transform([[
len(text), # char_count
sum(c.isdigit() for c in text), # digit_count
sum(c.isupper() for c in text), # uppercase_count
text.count("$") + text.count("£"), # currency_count
text.count("\n"), # line_count
]])
features = hstack([word_feat, char_feat, csr_matrix(num_feat)])
return int(model.predict(features)[0])
label = predict("Invoice No. 12345 Total: $499.99 Date: 01/01/2024")
print("Predicted label:", label)Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.