使用机器学习功能增加beancount导入程序。

smart-importer的Python项目详细描述


增强 Beancount进口商 具有机器学习功能。

状态

工作原型,开发状态:alpha

https://travis-ci.org/beancount/smart_importer.svg?branch=master

安装

尚未在pypi上发布smart_importer包 因此必须从源安装:

git clone https://github.com/beancount/smart_importer.git
pip install --editable smart_importer

快速启动

此包提供可以修改导入项的导入挂钩。什么时候? 运行进口商,现有条目将被用作训练数据。 机器学习模型,然后预测条目属性。

下面的示例演示如何将PredictPostingshook应用于 现有CSV进口商:

frombeancount.ingest.importersimportcsvfrombeancount.ingest.importers.csvimportColfromsmart_importerimportapply_hooks,PredictPostingsclassMyBankImporter(csv.Importer):'''Conventional importer for MyBank'''def__init__(self,*,account):super().__init__({Col.DATE:'Date',Col.PAYEE:'Transaction Details',Col.AMOUNT_DEBIT:'Funds Out',Col.AMOUNT_CREDIT:'Funds In'},account,'EUR',['Filename: .*MyBank.*\.csv','Contents:\n.*Date, Transaction Details, Funds Out, Funds In'])CONFIG=[apply_hooks(MyBankImporter(account='Assets:MyBank:MyAccount'),[PredictPostings()])]

文档

本节详细解释了相关的概念和工件 需要使用机器学习来增强Beancount进口商。

Beancount进口商

假设您为“mybank”创建了一个名为 MyBankImporter

classMyBankImporter(importer.ImporterProtocol):"""My existing importer"""# the actual importer logic would be here...

注: 本文档假设您已经知道如何创建beancount导入程序。 相关文档可以在beancount ingest下找到。使用beancount.insert,用户可以 编写自己的导入程序并使用它们转换下载的银行对账单 进入beancount条目列表。 下面是beancount源代码的一部分 beancount/ingest/office

应用智能导入程序

任何beancount导入程序都可以通过应用一个 下列钩子中的一个:

  • PredictPostings-预测投递列表。
  • PredictPayees-预测交易的收款人。
  • DuplicateDetector-检测重复项
例如,要将现有的转换为一个智能导入器,请将其转换为:
fromyour_custom_importerimportMyBankImporterfromsmart_importerimportapply_hooks,PredictPayees,PredictPostingsmy_bank_importer=MyBankImporter('whatever','config','is','needed')apply_hooks(my_bank_importer,[PredictPostings(),PredictPayees()])CONFIG=[my_bank_importer,]

注意,导入器钩子需要应用于导入器实例,如 如上图所示。

指定培训数据

^ {tt1}$钩子需要训练数据,即现有列表 为了有效的交易。培训数据可由 用引用现有BeaCeNT的参数调用bean提取 事务,例如bean-extract-f existing_transactions.beancount。什么时候? 使用FAWA中的进口商,将现有条目用作训练数据。 自动。

与fava一起使用

聪明的进口商与Fava玩得很好。 这意味着你可以用与fava完全相同的方式使用智能进口商。 就像你对待传统进口商一样。有关详细信息,请参见Fava’s help on importers 信息。

开发

拉请求欢迎!

执行单元测试

简单运行(需要TOX):

make test

配置日志

python的日志记录模块由smart_importer模块使用。 相应的日志级别可以更改如下:

importlogginglogging.getLogger('smart_importer').setLevel(logging.DEBUG)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java OutOfMemoryError以及如何使运行继续   java树映射内存使用率   使用带有java spark的javascript获取api的挂起承诺状态(POST请求)   java Android:存储用户单击的CardView   输入了有关拖动的java信息   单元测试中的java DecimalFormat(“·#,##0”)前缀   来自客户端的java超时webservice调用   java未使用的超类变量   如何在Java中的参数提示中强制执行整数限制   启动期间Tomcat中出现java错误:找不到DB名称   java Marshall/Unmarshall地图   一个类在另一个类中的java访问变量   如何在java中对字符数组的文本进行对齐?   从jenkins运行时,使用selenium上传excel文件的java不起作用   java将double转换为BigInteger   java Android键盘问题与按键释放   旋转java在两个旋转矩形之间的碰撞检测   在TestNG中执行时,XML中出现java启动错误无法继续执行测试