Rule Mining

AND-rules for GL code and approver, mined live with _relate from the fields known when an invoice arrives (vendor, category, vendor country, amount band), as rule candidates. A person promotes a candidate with sign-off and an audit-trail entry; the ERP demo can also dismiss one.

Rule Mining: screenshot from the ERP demo
📋 ERP🧾 Accounting_relateAccountingERP
Production anchorAND-rules for GL code and approver mined live with _relate $patterns in the accounting demo, each priced with exact invoice counts; strong candidates (right in at least 95% of the invoices they match) carry Promote, which writes an audit-trail entry. The ERP demo mines supplier and category patterns for the account code the same way, and each candidate carries Promote (explicit sign-off, audit-trail entry) and Dismiss.

The problem

Most business systems have a layer of authored rules that handle the long tail of decisions the application cannot decide for itself. "If vendor X and category Y, route to approver Z." "If amount > €5,000 and project = construction, require CFO sign-off." Authored rules are auditable and well-understood, but they have a discoverability problem: someone has to know that the rule should exist before they can write it.

The patterns the rules should encode are already in the data. Vendor X plus category Y has routed to approver Z 47 times out of the last 50 occurrences — that is a statistically significant pattern with 94% support. Nobody has written it as a rule yet, but the system could surface it as a candidate. Once surfaced, the team can promote it to a rule or dismiss it, and the decision is recorded.

Rule mining solves the discoverability problem. The system finds the patterns hiding in the operational data and presents them for human review.

How it works

Aito's _relate operator returns conditional probabilities between attributes — and crucially, ranks them by lift. Lift is the ratio of conditional probability to base probability; a lift of 10× means the outcome is ten times more likely when the pattern holds than on average. Lift alone is not enough: a high lift over three invoices is still thin evidence, so each candidate also carries its support, how many invoices it covers and how many of those it gets right.

The accounting demo's rule-mining view runs _relate with $patterns once per frequent GL code and approver, over the fields known when an invoice arrives, then counts each candidate's support exactly with _search. Each candidate becomes a row with the conditional pattern, its lift and its support. In both the accounting and ERP demos, Promote requires explicit sign-off and writes an audit-trail entry, and the ERP demo's Dismiss records a rejection; nothing mined is policy until someone promotes it.

{
  "from": {
    "from": "invoices",
    "where": {
      "customer_id": "CUST-0000"
    }
  },
  "where": {
    "gl_code": "1600"
  },
  "relate": {
    "$patterns": {
      "$related": {
        "relate": [
          "vendor",
          "category",
          "vendor_country",
          "amount_band"
        ],
        "k": 8,
        "to": {
          "gl_code": "1600"
        }
      }
    }
  },
  "select": [
    "related",
    "condition",
    "lift"
  ],
  "orderBy": "lift",
  "limit": 6
}

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application.

See it live

This use case runs in 2 live demos today, the 📋 ERP and 🧾 Accounting demos. Each link opens the view that shows it, where you can inspect the queries that produce the result.

Frequently asked

How is this different from association rule mining (Apriori, FP-growth)?

Same conceptual family — find statistically significant patterns in transaction data. The difference is that classical algorithms run in batch, produce a frozen rule set, and need to be re-run when data changes. _relate runs at query time over the live index, so the candidate list reflects the current state of the data on every refresh.

Will this surface a lot of patterns that are too specific to be useful?

That is what the support and lift thresholds handle. The accounting demo keeps patterns with lift above 1 and at least three supporting invoices, and marks a candidate strong, and promotable, only when it is right in at least 95% of the invoices it matches. Lower thresholds produce more noise; higher thresholds miss real patterns. Mature deployments tune the thresholds per domain.

What happens to existing rules when the data shifts and the pattern weakens?

Re-run the mining: _relate reads the live data, so a weakened pattern shows a lower lift and support the next time. Measuring each promoted rule against the posted values, as the accounting demo's rule performance view does, shows when a rule has started to disagree with what people actually post.

Can dismissed candidates resurface later?

The mining itself has no memory; it reads the current data. Whether a dismissed candidate is hidden next time is the application's choice, made from the recorded decision.

Does this work outside accounting and ERP?

Yes. The pattern is "find statistically significant relationships between attributes in operational data" — applicable to support ticket routing, e-commerce product co-occurrence, customer-segment behavior, anywhere conditional patterns matter. The threshold tuning differs per domain but the mechanism is the same.