Icon

Ex2

Fraud Detection: Random Forest Model Training

The workflow reads in the creditcard.csv file and trains and evaluates a Random Forest model to classify transactions as either fraudulent or not. Notice the Rule Engine node classifies all transactions with fraud probability above 0.3 as fraudulent. We apply a threshold of 0.3 to the probability of being a fraudulent transaction (default is 0.5). Adopting a lower threshold makes the algorithm more responsive in classifying frauds. You can evaluate the results by opening 'Evaluation' component view. After training, the model is saved for deployment. In our case we use Random Forest Learner, but we can use any other Supervised model.


This workflow demonstrates how we can train the model on the provided data:
1. Read training data
2. Train the Random Forest Model
3. Evaluate model results
4. Save trained model for deployment

URL: Kaggle Dataset https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud

Read training data

Train the Random Forest Model

Save trained model for deployment

Fraud Detection: Random Forest Model Training


Το workflow διαβάζει το αρχείο creditcard.csv και εκπαιδεύει και αξιολογεί ένα μοντέλο Random Forest για να ταξινομεί τις συναλλαγές ως fraudulent ή όχι. Σημειώστε ότι ο Rule Engine node κατηγοριοποιεί όλες τις συναλλαγές με fraud probability πάνω από 0.3 ως fraudulent. Εφαρμόζουμε ένα threshold 0.3 στην probability του να είναι μια συναλλαγή fraudulent (η default είναι 0.5). Μια χαμηλότερη τιμή threshold κάνει τον αλγόριθμο πιο ευαίσθητο στην ανίχνευση frauds. Μπορείτε να αξιολογήσετε τα αποτελέσματα ανοίγοντας την ‘Evaluation’ component view.

Μετά την εκπαίδευση, το μοντέλο αποθηκεύεται για deployment. Στην παρούσα περίπτωση χρησιμοποιούμε Random Forest Learner, αλλά μπορούμε να χρησιμοποιήσουμε οποιοδήποτε άλλο Supervised model.

Αυτό το workflow δείχνει πώς μπορούμε να εκπαιδεύσουμε το μοντέλο στα δεδομένα που παρέχονται:

  1. Read training data

  2. Train the Random Forest Model

  3. Evaluate model results

  4. Save trained model for deployment

Evaluate model results

Open Viewto see results
Evaluation
P(Class =1)>0.3=>1P(Class=1)<= 1
Rule Engine
Class = Fraud
Random Forest Learner
Διαβάστε τα credit card data (sample)
CSV Reader
Random Forest Predictor
Convert Class to string
Number to String
70 % Training30 % Testing
Partitioning
Save model
Model Writer

Nodes

Extensions

Links