Posts

[Day 208] Setting up docker-services for the KB project, streaming transactions, and the Scottish dataset

Image
 Hello :) Today is Day 208! A quick summary of today: making progress with the Kukmin Bank (KB) project Scottish dataset 2hr audio mark is close First, about the KB project for the KB AI competition All code from today is on the project's repo on branch ivan . Today I managed to set up the (what I think are the) needed services going forward. I hit the Docker storage space limit a few times, so I had to compromise on complexixty. For example instead of using postgres as a db for mlflow, even using a simple sqlite3 db for this project is fine. Later, plugging in a better storage for mlflow, and its artifacts is trivial. One new thing, that was not there before is grafana. I saw online that there is a neo4j grafana plugin - so I tried to install it. At first, by default, I could not, so I looked in grafana cloud (free for 14 days) and on there, the plugin could easily be loaded, and I could easily connect to my neo4j db. However, I wanted to do it locally, so I found a way to install...

[Day 207] Finished with neo4j (for now) and thinking about fraud detection models

Image
 Hello :) Today is Day 207! A quick summary of today: setting up neo4j reading some papers on bank telemarketing classification Firstly, about the Kukmin Bank (KB) AI competition project We set up  the database on my partner's laptop insert CreditCard nodes insert Merchant nodes insert Transaction edge We also had a look at the final EDA notebook. At the moment the repo looks like: As for next steps, we will start developing models, and try to get something that can identify Fraud transactions well. And more importantly, explainability - what features help the model determine that a transaction is fraud. So we will start with some basic models like logistic reg, decision trees, random forest, then add hyperparam tuning, over/undersampling, etc. And try to get a model that detects Fraud well.  As I want to try out a GNN for this project's model. I saw there is a GNNExplainer by torch-geometric, so I need to try using it in practice and see if the explainability it provides...

[Day 206] Finishing the Stock Market Analysis zoomcamp (for now)

Image
 Hello :) Today is Day 206! A quick summary of today: last homework from Stock Market Analysis Zoomcamp Uploading neo4j scripts to the KB project repo Over the past 4 weeks, my lab mate (Jae-Hyeok, the same guy with whom I am doing the KB project) and I have been covering another couse by DataTalksClub - the Stock Market Analysis Zoomcamp . The course introduces basic concepts and strategies for creating models that can potentially invest in stocks. Today was the 4th week since we started it and was the last homework, related to working with a financial model workbook to modify and analyse stocks, focusing on Random Forest tuning, reducing feature sets (to see difference in results), predicting strong future growth (investing in cases where the stock growth is above a fixed treshold), and developing an ideal trading strategy. Above is an example resulting graph from one of the questions. We compare models based on CAGR (Compound annual growth rate), and there are various models - r...

[Day 205] Going back to a basic mlflow service and another meeting for the KB project

Image
 Hello :) Today is Day 205! A quick summary of today: no minIO, just plain old postgres and local storage for mlflow helping my friend better understand github's workflow Yesterday I mentioned I set up minIO as an artifact store for mlflow ~  Well today I removed it haha. The problem was that i wanted some extra AWS credentials in order to work, and to get that I need a working AWS account. I can easilty set that up again (because I deleted my aws account recently), but in order for my project collaborator to set it up, he needs to do it as well. We have enough work as it is, and this extra tech is not essential so I just removed it and set up mlflow just using a local postgres docker service and a folder as the artifact store. Maybe later, we can swap out this whole mlflow to run on GCP but it is not crucial if we leave it as is for now.  While setting up mlflow and testing the connection, I was reminded of the value of "network" in dockere-compose. I had the other servi...

[Day 204] Transaction data EDA + MLflow & minIO docker setup

Image
 Hello :) Today is Day 204! A quick summary of today: some EDA on the KB AI competition data setting up mlflow and minIO Firstly, about doing some basic cleaning and EDA on my part of the data for the Kukmin Bank project These are the variables assigned to myself:  trans_date_trans_time,cc_num,merchant,category,amt,first,last,gender,street,city,state No missing/null values.  Box plot of log(amount) in Not Fraud vs Fraud Distribution of Not Fraud vs Fraud Other graphs Interesting ~ only Fraud transactions in the state of Delaware (of course this is not real data, but interesting nonetheless) We should also do some basic transformation and cleanup before the raw data goes to the db. In my columns, an example case is: all merchant's name start with fraud_, so removing it would be fine, just for a bit more clarity.  On another note ~ mlflow and minIO I found this website (in Korean but can be translated) that provides an easy "plug-n-play" Dockerfile and docker-compose ...

[Day 203] Starting LLM zoomcamp module 4 - Monitoring

Image
 Hello :) Today is Day 203! A quick summary of today: meeting with my lab mate for the KB AI competition project starting LLM zoomcamp module 4 Today we met to talk about neo4j and doing EDA for the Kukmin Bank AI competition. We talked about the benefits of docker and docker-compose, and how to use neo4j. The next step we will do is EDA. This might sound a bit odd, given that yesterday I created a GNN. Then I just use raw data without many features. The reason being I wanted to make sure I can get even a simple GNN to work.  My lab mate suggested to split the columns of the dataset in half, and to see what we can find in terms of needing to change in the dataset. In total there are 22 columns, so we split it down the middle.  These are the columns assigned to myself: trans_date_trans_time,cc_num,merchant,category,amt,first,last,gender,street,city,state,zip,lat,long,city_pop,job,dob,trans_num,unix_time,merch_lat,merch_long,is_fraud   On another note, today I cov...

[Day 202] Setting up a Graph Convolution Network model to detect fraud credit card transactions

Image
 Hello :) Today is Day 202! A quick summary of today: finally got a GNN to work learned how to use Mage for data streaming pipelines I started today where I ended yesterday - trying to create some kind of a graph neural network to predict whether a transaction is fraud or not.  Tldr (as it is ~3.20am, another late night) I ended up using torch geometric's Homogeneous data class and the resulting data looks something like: Data(x=[4290, 18], edge_index=[2, 23278], y=[4290], train_mask=[4290], test_mask=[4290]) The preprocessing involves undersampling the majority class and we end up with a balanced dataset.  The dataset has the following amount of edges and nodes Neo4j is nice.  The model I found that works (at least for now, version 0.1) is: After splitting data into train and test, the best model so far achieved the following results: Accuracy: 0.8833, Precision: 0.8151, Recall: 0.9909, F1: 0.8945 Today I experimented with creating the training pipeline, but nothing...

[Day 201] Struggling with neo4j and a fraud GNN

Image
 Hello :) Today is Day 201! A quick summary of today: started using neo4j as a graph database It is ~3.30am when I am starting to write this as I was occupied with neo4j and trying to get a GNN model to work so I will keep it brief and go to bed. Why did we switch from arangoDB to neo4j?  Neo4j has a free cloud version with up to 400,000 edges so we can use this one for our real-time inference pipeline. Whereas in arangoDB there is no *permanent* free version. There *is* a free one but it expires after 14 days, and if anything I'd like to keep the data in the cloud db just in case we need it.  Inserting data into neo4j This is the dataset we will go with for now. It has a lot of info about the credit card user, transaction, and also we can extract location info about the merchant. I set up neo4j locally and inserted some data (inserting was easy and fast). In the red square, you can see the amount of nodes, and edges. The right side is an sql-esque type of query space bu...

[Day 200] Kukmin Bank AI competition project idea

Image
 Hello :) Today is Day 200! A quick summary of today: creating a project plan, timeline and learning about graph DBs My lab mate and I considered two project ideas. First I will talk and show our plan for the project we chose, and then for the other one which I did a simple demo for. Project idea we chose: Real-time fraud analysis using graph data and graph database My lab mate said he trusts me to choose the technologies for our project and to set up a plan to follow: Training Pipeline Data Collection and Preprocessing: Raw dataset obtained from Kaggle containing transaction data. Raw data is preprocessed before going into the database. Storage in ArangoDB: Transactions are stored in ArangoDB, a popular graph database. Customers and merchants are represented as nodes, and transactions as edges. Graph Neural Network with PyG: PyTorch Geometric (PyG) is used to build and train a Graph Neural Network (GNN) for fraud detection on the graph data. The model is trained on a batch of the ...