An AI Model for Human Financial Behavior
We all have our own unique perspective when it comes to managing our finances. Understanding how someone earns, saves, invests, and spends their money can be very useful. While statistics can help us gain some good insights, AI is much better suited to tackle the problem of understanding how a person manages their money. Earlier this year, I kicked-off a research project to define, train, test, and deploy a financial behavior AI model. The aim of the project was to analyze bank transactions and learn the intricate patterns of how people manage their finances. The outcome of this research project could potentially revolutionize financial predictions and personal financial management.
Defining a Financial Behavior AI Model
It is important to clearly identify the goal of any AI project. In this case, the objective was to develop a "financial behavior" AI model that can learn how different individuals manage their money. The model would use anonymized bank transactions from different individuals to identify patterns related to earning, spending, saving, and investing money. Through the application of machine learning algorithms, the model would generate predictions and insights that can be very useful.
My research project aimed to develop an AI model that not only predicts but also learns the financial behavior of individuals. This understanding could result in enhanced personalization, predictive insights, better financial services, and risk management. My ultimate objective is to create a foundational model that other organizations can utilize to predict the financial actions of people demonstrating specific traits. This will enable more personalized and effective financial solutions.
Preprocessing Financial Data
The first step involved was gathering a significant amount of transaction data from bank statements. Some of this data was obtained through the Crediture borrower processing system, while other data was sourced from Kaggle. This data underwent several preprocessing stages to ensure that it was appropriately anonymized, clean, normalized, and structured for analysis. This involved using tools such as Pandas and NumPy. The transaction descriptions and categories were also tokenized into types of expenses (such as utilities, groceries, entertainment). Additionally, sensitive personal information was obfuscated to ensure personal privacy.
Settling on the Model Foundation and Training
I was faced with a decision about the fundamental direction of the AI model. Should I focus more on the time intervals between financial transactions and learn patterns to predict future transactions? Or should my financial model learn the context and relationships among financial transactions and possibly associate transactions with specific life events?
Recommended by LinkedIn
In order to effectively analyze financial transactions, it is often best to use a combination of different model approaches. For example, a Long Short-Term Memory (LSTM) network is well-suited for handling sequential data because it can learn patterns and dependencies in data sequences, which is useful for analyzing financial transactions. On the other hand, a transformer model like DistilBERT is better suited for extracting meaning and context from text data, such as transaction descriptions. I decided to take a hybrid approach that combined the strengths of both models to analyze different aspects of the same financial transactions.
Creating a hybrid AI model that integrates LSTM and DistilBERT technologies required some creativity. The solution had to handle the complex nature of financial transactions. For example, if you look at how you spend money week over week, it's likely that no two weeks ever look alike. However, there may still be some patterns hidden in the data, such as a 'Starbucks Monday morning' or a 'Friday pizza night'. To start this process, I separately prepared the data for each model. For the LSTM, I formatted sequential transaction data such as timestamps, amounts, and frequencies using Python's Pandas library. Pandas is excellent for manipulating time-series data. By doing this, LSTM could focus on learning the temporal patterns in spending or saving behavior. Meanwhile, I processed the transaction descriptions using DistilBERT and applied Hugging Face transformers library to extract meaningful text embeddings. This allowed DistilBERT to learn the semantic relationships within the transaction descriptions and classify them into categories like 'utilities', 'dining out', or 'healthcare'.
In the next stage of the project, I was challenged to merge the outputs of the LSTM and DistilBERT models. To ensure that both outputs were compatible with each other, I had to perform feature engineering. I went with Scikit-learn's preprocessing modules to normalize vectors and reduce dimensions, creating a single feature set. This resulting feature set was then fed into a secondary PyTorch-based neural network model. The secondary model was trained with attention mechanisms to dynamically weigh the importance of inputs. By doing so, the model could learn to predict financial behaviors by considering both temporal patterns and contextual embeddings.
Testing with part of my initial training data set was looking good, but the exciting part was testing with new unseen data and getting results that were validated by the contributing participants. After some more testing, the model was deployed using Flask and containerized with Docker to serve predictions in real-time with an API. It's performing pretty well though there are still some improvements and optimizations that can be applied.
Planning the Next Steps
The next steps for this research project is to enhance the analytical capabilities of the model. Specifically, I would like to focus on improving the model's predictive accuracy by incorporating additional datasets. Adding real-time economic indicators and consumer sentiment indexes should provide insights into how individuals feel about the overall economic situation and how they may react financially. I think this additional data will help enhance the DistilBERT model's contextual understanding. Additionally, I may explore more advanced neural network architectures that can better handle sequential and textual data. And lastly, I'll need to really stress-test the financial behavior model under various economic conditions to validate its robustness and reliability.
Overall, this project aimed to understand human financial behavior by analyzing numerous financial transactions. The purpose was to train the system to predict how people will manage their money. The best results were obtained by utilizing a dual modeling approach of LSTM and DistilBERT. However, blending the outputs of these two models was a bit of a challenge. The numerical data from LSTM and contextual insights from DistilBERT had to work together without overwhelming the analysis. Blending the two AI technologies boosted the model's predictive accuracy significantly. Further work on this project could lead to more precise and personalized financial advice solutions.
Great article! My 2 cents: the model (or multi-model) should be trained with a much more discrete training set. For instance, 'savings for education' should not be classified separately from 'education'. Or, alternatively, should be divided into more classes. Example of bad labels: - green apple - red apple - banana The model will be confused and overall accuracy will be very low. Again, your idea is very cool :)
thanks for sharing this exploration. so cool and thoughtful. wondering how this could be applied to all the publicly available crypto trading data … hmmm