项目介绍

j-convey/BankTextCategorizer 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,目前获得 146 个 Star、27 次 Fork。

仓库全名
j-convey/BankTextCategorizer
Star 数
146
Fork 数
27
未关闭 Issue
3

README 摘要

Bank Transaction Categorization A simple and powerful tool that uses a neural network to categorize bank transaction descriptions into respective categories and subcategories. 💡 Motivation My primary motivation for creating this project was to provide an alternative to existing solutions by emphasizing two critical values: 1. Self-hosting: By allowing users to host the solution on their infrastructure, this project…

完整内容见 GitHub 原始 README 或本页 。

常见问题

BankTextCategorizer 用什么语言开发?

主要使用 Python 编写,目前有 146 个 Star。

如何获取 BankTextCategorizer 的源码?

可以直接克隆仓库:git clone https://github.com/j-convey/BankTextCategorizer.git,默认分支为 main;安装与运行步骤见仓库 README。

BankTextCategorizer 最近还在维护吗?

仓库最近一次更新为 2025年3月10日,当前有 3 个未关闭 Issue;Star 数为 146,可作为社区活跃度的参考。

关于

Automated Categorization: Utilizing the power of neural networks, this project offers an automated solution to categorize bank descriptions, reducing manual effort and enhancing efficiency while maintaining privacy.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
202
价值分
95
活跃状态
活跃

语言占比

CSS
Python

贡献者

README

Bank Transaction Categorization

A simple and powerful tool that uses a neural network to categorize bank transaction descriptions into respective categories and subcategories.

💡 Motivation

My primary motivation for creating this project was to provide an alternative to existing solutions by emphasizing two critical values:

  1. Self-hosting: By allowing users to host the solution on their infrastructure, this project offers complete control over data, operations, and customization. Self-hosting eliminates the dependency on third-party services which might shut down, change their terms, or even introduce pricing that might not be favorable to all.
  2. Privacy-friendly: In an era where every click, every view, and even every scroll is tracked, privacy has become a scarce commodity. This project is designed with privacy at its core. No unnecessary data collection, no sneaky trackers, and no third-party analytics. Your data stays yours, and that’s how it should be.

📋 Overview

This program is designed to help with the categorization of bank transaction descriptions. It leverages the power of the BERT model to recognize patterns in transaction descriptions and subsequently classify them into predefined categories and subcategories.

✨ Features

  • Data preprocessing to clean and prepare the transaction descriptions for the neural network.
  • Utilizes the BERT model, a state-of-the-art NLP model, for accurate categorization.
  • Simultaneous categorization into main category and subcategory.
  • Easy to use interface with simple Python functions.

🚀 How to Use

Setup & Installation

Make sure you have all the necessary libraries installed. Most importantly, ensure that torch, transformers, and pandas are available.

pip install torch transformers pandas

Categories/Subcategories

This program comes with a standard set of categories and subcategories to categorize your bank transactions. Below is the default categorization schema:

categories = {
    'Auto': ['Gas','Maintenance', 'Upgrades', 'Other_Auto'],
    'Baby': ['Diapers', 'Formula', 'Clothes', 'Toys', 'Other_Baby'],
    'Clothes': ['Clothes', 'Shoes', 'Jewelry', 'Bags_Accessories'],
    'Entertainment': ['Sports_Outdoors', 'Movies_TV', 'DateNights', 'Arts_Crafts', 'Books', 'Games', 'Guns', 'E_Other'],
    'Electronics': ['Accessories', 'Computer', 'TV', 'Camera', 'Phone','Tablet_Watch', 'Gaming', 'Electronics_misc'],
    'Food': ['Groceries', 'FastFood_Restaurants'],
    'Home': ['Maintenance', 'Furniture_Appliances', 'Hygiene', 'Gym',
        'Home_Essentials', 'Kitchen', 'Decor', 'Security', 'Yard_Garden', 'Tools'],
    'Medical': ['Health_Wellness'],
    'Kids': ['K_Toys'],
    'Personal_Care': ['Hair', 'Makeup_Nails', 'Beauty', 'Massage','Vitamins_Supplements', 'PC_Other'],
    'Pets': ['Pet_Food', 'Pet_Toys', 'Pet_Med', 'Pet_Grooming', 'Pet_Other'],
    'Subscriptions_Memberships': ['Entertainment', 'Gym', 'Sub_Other'],
    'Travel': ['Hotels', 'Flights', 'Car_Rental', 'Activities']
}

Flexibility in Categorization

However, we understand that every user might have specific needs, and the default categories might not fit everyone. You have the flexibility to modify, add, or remove categories and subcategories as per your requirements.

How to Customize:

Update the Dictionary: Modify the categories dictionary in the code with your desired categories and subcategories. The key should be the main category, and the values should be a list containing the subcategories.

Update Training Data: It’s crucial that once you modify the categories and subcategories, you also need to change the training data. Ensure that the data has labels corresponding to your new categories and subcategories.

Re-Train the Model: With the updated categories and training data, re-run the main() function to train the model on the new data.

By following these steps, you can easily customize the categorization to suit your personal or business needs.

🖥️ UI

image image image

🏗️ Code Structure

  • Data Preprocessing: DataPreprocessor class is responsible for reading the CSV file, cleaning the data, tokenizing the sentences, and preparing the data for training.
  • BERT Model: BertModel class initializes the BERT model with the appropriate number of categories and subcategories.
  • Training: train_category_model function handles the training loop, including batching, forward and backward passes, and early stopping.

📈 Performance

Here are my results after using main.csv dataset (62,793 lines of data) for 2 epochs. This took around 10 hours to complete based on my hardware. This is without using data augmentation to double the size due to time restaints. cat_modelV1

🔮 Future Improvements

  • Adding Visualizers for viewing categorized data to Summary and Details tab.
  • Refining the data preprocessing pipeline.
  • Fine-tuning the BERT model for better performance.

🤝 Contribute

  1. Consider contributing to the project.
  2. Add a Github Star to the project.
  3. Post about the project on X.

评论

暂无评论