λ akhil
← Back to Blog

KrypticTrack — an ML-powered expense tracker that actually works

I built an expense tracker in Python that uses machine learning to categorize transactions. It's surprisingly accurate (94%) and surprisingly useful. Here's the architecture.

pythonmlopen-source

Every expense tracker I've used has the same flaw: they make you categorize transactions manually. "Is this Amazon purchase 'Shopping' or 'Electronics'?" Who cares. Just tell me where my money went.

KrypticTrack solves this with a simple ML pipeline. Feed it your bank CSV exports (or connect via Plaid), and it categorizes everything automatically. It learns your patterns over time.

the pipeline

Input → Clean → Feature Extract → Classify → Detect Anomalies → Output

Cleaning is the hidden hard part. Bank CSVs are a mess — different formats, different column names, encoding issues, duplicate transactions. I spent more time on this than the ML model.

Feature extraction uses:

  • Merchant name (obviously)
  • Transaction amount
  • Time of day / day of week
  • Merchant category if available (Plaid provides this)
  • Historical category for the same merchant

The merchant name is tokenized and vectorized. "AMAZON" and "AMZN" and "Amazon.com" all map to the same merchant via fuzzy matching (Levenshtein distance with a threshold).

the model

A simple random forest classifier. Nothing fancy. I tried XGBoost, transformers (way overkill for this), and even a tiny neural net. Random forest won on accuracy/speed/complexity trade-off.

Accuracy: ~94% on known categories
F1-score: 0.91
Training time: ~30 seconds on laptop

The 6% error rate is mostly edge cases — refunds, weird merchant names, or genuinely ambiguous transactions. Those get flagged for manual review.

For anomaly detection, I use isolation forest on the feature vectors. It catches things like "you normally spend $50 on groceries but this week it's $500" or "you bought coffee at 3 AM" (which is either an anomaly or a really bad night).

the CLI

I wanted this to be pleasant to use from the terminal:

kryptic track --month may --category food
# Output: May food spending: $1,234 (↑12% from April)

kryptic import ~/Downloads/statement.csv
# Imported 342 transactions. 321 categorized automatically. 21 need review.

kryptic check
# ⚠  Possible anomalies found:
#   - $500 at "WALMART" on May 3 (typical: $85-120)
#   - $12 at "STARBUCKS" at 03:14 AM on May 17

is it useful?

Honestly? Yes. The auto-categorization saves me about 10 minutes per week. The anomaly detection caught a fraudulent charge once ($3 test transaction before a bigger one). The CLI means I can check my spending without opening a web app.

It's open source on GitHub. The Plaid integration requires API keys but the CSV import works out of the box.

AKhil Raghav — iOS/OSX Swift Developer