Posts

Showing posts with the label Graphs

[Day 209] Using Mage for pipeline orchestration in the KB project

Image
 Hello :) Today is Day 209! A quick summary of today: creating Mage pipelines for the KB AI competition project The repo after today Today morning/afternoon I went on a bit of a roll ~  I set up all the above pipelines in Mage. Below I will go over each one get_kaggle_data it is just one block that downloads the data for the project from Kaggle using the kaggle python package load_batch_into_neo4j Gets the loaded data from the get_kaggle_data pipeline and inserts it into neo4j. This is the fraudTrain.csv from the Kaggle website (because the fraudTest.csv will be used for the pseudo-streaming pipeline). train_gcn I tried to split this into more blocks, but at the moment the way I structured the code, the most optimal solution was to do it all at once. That is - create a torch-geometric dataset, create node and edge index, train the model, test it, and save summary info. At the moment, because everything is local, I am using mlflow just for easy comparison but later (after the ...

[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 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 92] Starting the official Stanford XCS224W: ML with Graphs

Image
 Hello :) Today is Day 92! A quick summary of today: got access to the lectures + assignments of XCS224W: ML with Graphs on Stanford's platform, and covered Lecture 0: Intro to ML with Graphs, and Lecture 1.1: Traditional ML on Graphs Similar lectures may be found on youtube .  Learned about graphs and their application, nodes, edges, adjacency matrices, different types of graphs (undirected, directed, weighted, unweighted), features that help predict nodes, links between nodes and entire graphs, graphlets, clustering coefficients, way more in the notes below ^^  Lecture 0: Intro to ML with Graphs Lecture 1.1: Traditional methods for ML on Graphs The rest of lecture 1 covers: 1.2  Node Embeddings and 1.3  Link Analysis: PageRank, Random Walks, and Embeddings After which I am supposed to do Assignment 1. Exciting stuff in the next days/weeks! That is all for today! See you tomorrow :)