Skip to main content

Hooks for the beangulp importer.

Project description

hoostus-beangulp-hooks

This uses machine learning, trained on your previous postings, to predict what the second leg of an imported transaction should be.

How to use it with beangulp.

The package name in pypi is hoostus-beangulp-hooks so install it with pypi or add to pyproject.toml with that name.

pip install hoostus-beangulp-hooks

or

dependencies = [
    "hoostus-beangulp-hooks"
]

The easiest way.

  1. Import it: from hoostus.beangulp.hooks import predict_posting
  2. Add the simple_hook to the list of hooks you send to beangulp.

In the importer.py you use with beangulp this might look something like:

from hoostus.beangulp.hooks import predict_posting
if __name__ == '__main__':
    importers = [ ... ]
    hooks = [predict_posting.simple_hook]
    ingest = beangulp.Ingest(importers, hooks)
    ingest()

If you want to configure it.

Use predict_posting.hook directly and pass in a map of weights and a list of denied accounts -- accounts you don't want to use for training the machine learning model. Note that beangulp expects hooks to take 2 parameters but predict_posting.hook takes 4 paramters. This means you will need to use functools.partial (or similar) to wrap it.

In the importer.py you use with beangulp this might look something like:

from hoostus.beangulp.hooks import predict_posting
import functools
if __name__ == '__main__':
    importers = [ ... ]
    
    my_weights = {'payee': 0.5, 'narration': 0.9, 'date.day': 0.2}
    my_denied_accounts = ['Expenses:Donuts']
    my_hook = functools.partial(predict_posting.hook, my_weights, my_denied_accounts)
    hooks = [my_hook]
    ingest = beangulp.Ingest(importers, hooks)
    ingest()

If you want to reuse the default weights (e.g. to only provide a denied_list) it is at predict_posting.default_weights.

Implementation Notes

The training is done on a per-account basis. Only transactions from the impoted_account are considered.

Transactions involving closed accounts are removed from the training data.

Any transactions in the training data with a single leg are removed. This isn't valid beancount syntax anyway and is an artifact of (what I believe to be) a bug in beangulp which adds all of the recently imported transactions into the list of existing entries provided to hooks. This muddies the training data, in some cases making it useless.

This is basically recycled from https://github.com/beancount/smart_importer but adapted to the beangulp framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hoostus_beangulp_hooks-1.0.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hoostus_beangulp_hooks-1.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file hoostus_beangulp_hooks-1.0.2.tar.gz.

File metadata

File hashes

Hashes for hoostus_beangulp_hooks-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e9bc7e3966d04227586c45964f598502f91dde132f7aa197f51ae7fde32a11f2
MD5 b757202e0b63e0159b6a32f939fc9531
BLAKE2b-256 b6b5f6354fb67f61ee2106a3088327cf17d031a4006d9c09cff3ee390b9239bb

See more details on using hashes here.

File details

Details for the file hoostus_beangulp_hooks-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hoostus_beangulp_hooks-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5cda85492dbe38cdff8acd227a5ae634ba185d506c3e99362ede14a15a12b883
MD5 3c77a9deb47ce03711328fb1f9b90fc9
BLAKE2b-256 29cb8ea8b440aab25c80baac7b59988eb241bf9cba475a9f69e55e7ff3e77cbb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page