Skip to content

Add ML to automatically set operation category

sinopsysHK requested to merge sinopsysHK/kresus:autocategorize into master

I know there's been discussion on that topic (#41 (closed)) and ML wasn't the first priority.

I felt too lazy to setup manually formal rules to allocate the category based on patterns so I tried to have an algorythm to do to it automatically and letting me just validated its result.

Here are the added elements in the UI to manage it on a day to day: new_auto_categorization

Again I let you decide if you want it: it was for my own usage but if it is of any interest for broader audience...

So what I did:

Introduce a python module to setup a ML model that will be trained with all historical transactions with category set. Then it applies prediction on non categorized operations to propose one. Model is re-trained before each poll in order to fine-tune its setup. Bulk classification is done after each poll to predict all un-categorized operations in a row. Classification is performed also after each bank fetch.

Internally to manage it: it introduce a flag to keep track whether or not the category of an operation is a guessed one or a set one.

On the UI, it adds a specific visual to distinguish guessed/set category (thickness of the border). To be user friendly it adds a little button next to guessed categories allowing the user to validate the proposed category and set it definitely. For further convenience, it provides within the search panel a checkbox allowing to filter on guessed categories only.

*Limitation: when there is only a limited set of categorized operations,the Classifier cannot initialize properly (min ~10).

TODO: enhance charts to be able to filter out guessed categories ordistinguishing them from formal ones.*

Merge request reports