STAYCHARTED BLOG · PROCUREMENT · SPEND CLASSIFICATION
Spend classification with machine learning: categorize new spend from your own reviewed history
How spend classification with machine learning works: train on spend you've already categorized, classify new lines, and review the unsure ones. Steps and examples.
What spend classification is, and why it matters
Most organizations can say how much they paid each supplier. Fewer can say how much they spent on cloud software, temporary labor or packaging across every supplier, entity and card. That second view is what procurement needs to negotiate, consolidate suppliers and find spend that went around a contract.
Getting there means giving every line a category. Some of that information is already in your systems:
- The GL account says how the line was booked. It's an accounting view, and often too broad ("6200 Professional services").
- The supplier says who was paid, but not what for. One distributor can sell laptops, toner and installation services.
- The description says what was bought, in whatever words the requester or supplier used: "EDR licence 500 seats", "Annual endpoint protection renewal", "CrowdStrike Falcon Insight – yr 2".
Spend classification is turning those three into one consistent category per line.
Why rules stop working
Most teams start with rules: if the supplier is X, the category is Y; if the description contains "license", it's software. Rules are a fine start, and they break in predictable ways:
- Suppliers sell more than one thing, so supplier rules misfile part of their spend.
- Descriptions vary. Every new spelling, abbreviation or language needs another rule.
- Rules collide. "Software license audit services" matches both software and consulting, and whichever rule runs first wins.
- Nobody owns them. After a year, few people know why rule 214 exists.
A machine-learning model works from the other direction. Rather than someone writing down the logic, it learns from the lines your team has already categorized, including the exceptions. It also returns a confidence with each answer, so the lines it isn't sure about can go to a person.
Choosing a spend taxonomy
The model learns whatever categories your examples use, so the taxonomy is your decision, not the tool's.
| Option | Good for | Watch out for |
|---|---|---|
| Your own categories (10–60 categories, often in two levels) | Reports your procurement and finance teams already use; categories that match how you buy | Keep definitions written down so reviewers agree |
| UNSPSC (a standard 8-digit code with four levels) | Benchmarking, public-sector reporting, sharing data with others | Thousands of codes; most teams classify to segment or family level, not commodity |
| A hybrid: your categories, mapped to a UNSPSC family | Internal reports plus a standard view | Maintain the mapping as a separate table, not as more model categories |
Two levels at once. A spend taxonomy usually has a category and a subcategory (IT → Software, IT → Hardware). StayCharted can learn an answer with several parts, so one model returns both and you can check them together.
Start with fewer categories than you think. Ten to twenty well-defined categories that cover most of your spend beat 200 categories where half have three examples. Add detail where the money is.
If you're classifying to UNSPSC specifically, see UNSPSC classification with AI.
Vendor classification or line-item classification?
| Vendor classification | Line-item classification | |
|---|---|---|
| What gets a category | Each supplier, once | Each purchase or invoice line |
| Effort | Low: one row per supplier | Higher: many rows |
| Accuracy for multi-category suppliers | Poor: all of a distributor's spend lands in one category | Good: each line is categorized by what was bought |
| Best for | A quick first view; suppliers that sell one thing | Accurate category spend, contract compliance, savings analysis |
A practical approach is both: classify suppliers first for a quick view, then classify line items for the suppliers whose spend crosses categories.
How to classify spend with machine learning: 10 steps
This uses StayCharted AI Model Trainer, but the steps are the same for any tool that learns from your examples.
1. Pick a scope you can check
One entity, one year of accounts-payable or purchase-order lines, one level of your taxonomy. A model you can check in an afternoon is worth more than a full-scope project that takes a quarter to evaluate.
2. Export lines with the information a person would use
One row per line. Typical columns:
| Column | Use it as model input? |
|---|---|
| Line description | Yes, the most useful field |
| Supplier name | Yes, it helps, but never alone |
| PO category text or requester's department | Yes, if it's there for new lines too |
| GL account | Yes, if it's assigned before you classify |
| Amount, date, invoice number | No. Keep them in the file for reporting |
| Your category (and subcategory) | The answer the model learns |
Only use a column as input if new lines will have it when you classify them. A column that's filled in later, such as the category a reviewer assigned last month, will make the test results look better than real use.
3. Clean the answers before you train
- Merge renamed categories. "IT – Software" and "Software & SaaS" should be one answer.
- Decide what "Other" means. A catch-all category teaches the model to put anything unclear there. Either define it narrowly or leave those rows out.
- Fix the obvious mistakes. The model learns your history, mistakes included.
4. No categorized history? Start from uncategorized rows
If your spend has never been categorized, StayCharted can start from rows with no categories. Give it your category names, and it groups similar lines and suggests a category for each. You confirm or correct the suggestions, and it learns from what you've reviewed as you go. The reviewed rows then train the first model. This is available on Essentials and Business.
5. Upload and let the checks run
Upload the file (Excel, CSV or JSON), then choose the input columns and the answer column. Before training, StayCharted checks the data:
- duplicate lines;
- the same description with two different categories;
- categories with too few examples to test;
- personal or sensitive values in the text, which it can mask before training. Card numbers and bank details have no place in a spend model.
6. Train, and compare two models
- A Classifier Model learns the words that go with each category. It's fast and works well when descriptions are consistent.
- An AI Classifier Model uses a pre-trained AI to read meaning. It handles different wording and many languages ("Reinigungsdienst" and "cleaning service" end up in the same place).
Train both on the same file and keep the one with fewer mistakes on your important categories. On Business, a Dedicated AI Model trains an AI on your own lines, which can help with long, messy or mixed-language descriptions.
7. Read the test results by category
StayCharted holds back part of your rows that the model never trains on, and reports how often it was right on them. Don't stop at the overall number:
- Look at your biggest categories by spend. A 2% error rate on travel matters less than a 2% error rate on your largest IT contracts.
- Read the mistakes. Many will be between neighboring categories (software vs SaaS subscriptions). That often means the two definitions overlap, not that the model is broken.
8. Choose what a person reviews
Each answer comes with a confidence. Set a review cutoff: answers below it go to the Review Queue on Essentials and Business, where a person confirms or corrects them, with the model's top suggestions and similar past lines beside each one. Start strict, so more lines get reviewed, then relax it once you've seen how the confident answers hold up. See AI confidence scores and human review.
9. Classify the new period's lines
Give it next month's export and choose the column to fill. You get the same file back with the category and a confidence column filled in, and every other column unchanged, so your pivot table or spend cube works as before. You can also:
- fill rows directly in Google Sheets with the add-on;
- call the model from your procurement or AP system through the API (Essentials and Business), so lines are categorized when they arrive rather than at month end.
10. Feed corrections back
Reviewed and corrected lines become training examples for the next version. Retrain monthly or quarterly, and always after you change the taxonomy: a model only knows the categories it was trained on.
A worked example
Five new lines, after training on a year of categorized spend:
| Supplier | Description | Category · Subcategory | Confidence | Goes to |
|---|---|---|---|---|
| Northwind IT | Falcon Insight renewal – 500 endpoints | IT · Software | 0.97 | Accepted |
| Northwind IT | Dell Latitude 5450 ×12 | IT · Hardware | 0.95 | Accepted |
| Northwind IT | On-site install, 2 days | IT · Services | 0.71 | Review |
| CleanCo GmbH | Reinigungsdienst Oktober, Standort Köln | Facilities · Cleaning | 0.93 | Accepted |
| Acme Supplies | Misc. – see attached | Office · Supplies | 0.38 | Review |
The same supplier lands in three categories, which a supplier rule would miss. The last line gives the model almost nothing to go on, and its low confidence sends it to a person rather than into the report.
Illustrative; your categories and confidences depend on your data.
Measuring it the way finance will
Line accuracy ("92% of lines correct") is how models are usually scored. Finance cares about money in the right place. After a test month, add one column to the filled file: the reviewer's final category. Then compare:
- Line accuracy: correct lines ÷ all lines.
- Spend accuracy: amount on correct lines ÷ total amount.
- Review effort: lines below the cutoff ÷ all lines.
If spend accuracy is lower than line accuracy, the model is getting large lines wrong. Add an amount-based review rule in your finance workflow, or add more examples for those categories. StayCharted’s model review cutoff applies to the model, not a different amount threshold per line.
What it doesn't do
- It doesn't read invoices. It classifies lines you've already exported or extracted. If invoices arrive as PDFs, use your AP or document-capture tool to get the lines out first.
- It doesn't calculate totals. It gives each line a category; your spreadsheet, BI tool or procurement system adds them up.
- It doesn't invent categories. A new kind of purchase gets the closest category it knows, sometimes with high confidence. Review unfamiliar purchases as well as low-confidence answers.
- It doesn't post anything. It returns suggestions; your system and your reviewers decide what's recorded.
Common questions
What is spend classification?
Sorting each purchase, invoice or card line into a spend category, so you can see spending by what was bought rather than only by supplier or GL account.
How is machine learning used in spend classification?
A model learns from lines your team has already categorized, then suggests a category and a confidence for each new line. People review the low-confidence ones, and their corrections train the next version.
What is a spend taxonomy?
The agreed list of spend categories, usually in two or three levels (for example IT → Software → Security software). It can be your own or a standard such as UNSPSC.
Is machine learning better than rules for spend classification?
It can help when suppliers sell many things and descriptions vary, because it learns from your past decisions instead of needing a rule for each case. Compare both on your reviewed test rows. Rules still work well for a few fixed cases, such as a single-purpose supplier.
How many categorized lines do I need?
Start with about 20 reviewed lines per category, and more for categories that look alike. Test on lines the model hasn't seen, and add examples where it gets things wrong. See how many examples to train an AI classifier.
Can it classify vendors as well as line items?
Yes. Train on one row per supplier with its category for vendor classification, or on line items for line-level classification. Many teams do both.
Can I classify to UNSPSC?
Yes, if your training lines carry UNSPSC codes. Most teams classify to segment or family level. See UNSPSC classification with AI.
Do I need a data scientist or developer?
No, not to train and fill files. A developer is only needed to connect the model to your procurement system through the API.