Search in sources :

Example 1 with BayesClassifier

use of jgnash.bayes.BayesClassifier in project jgnash by ccavanaugh.

the class BayesImportClassifier method generateClassifier.

private static BayesClassifier<Account> generateClassifier(List<Transaction> transactions, final Account baseAccount) {
    final BayesClassifier<Account> classifier = new BayesClassifier<>(baseAccount);
    for (final Transaction t : transactions) {
        final Set<Account> accountSet = t.getAccounts();
        accountSet.remove(baseAccount);
        for (final Account account : accountSet) {
            if (!t.getPayee().isEmpty()) {
                classifier.train(t.getPayee(), account);
            }
            if (!t.getMemo().isEmpty()) {
                classifier.train(t.getMemo(), account);
            }
        }
    }
    return classifier;
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) BayesClassifier(jgnash.bayes.BayesClassifier)

Aggregations

BayesClassifier (jgnash.bayes.BayesClassifier)1 Account (jgnash.engine.Account)1 Transaction (jgnash.engine.Transaction)1