Skip to main content
image Detect anomalies in your data. Anomaly detection, such as fraud detection is crucial for preventing financial losses. ML models can be trained on e.g. historical credit card transaction data, and then used to identify and prevent fraudulent transactions. Peliqan’s platform also supports the regular updating and fine-tuning of models to ensure their effectiveness in detecting fraud. Here is an example on how to build an ML model in Peliqan.io with a few lines of Python code.

Import required modules

We will be using IsolationForest Algorithm to perform the anomaly detection. More on IsolationForest here.

Load a dataset

Load data from a table into a dataframe (df).

Using Streamlit to build an app

We use the Streamlit module (st), built into Peliqan.io, to build a UI and show data.
image

Understanding data

the dataset we are using contained 28 compressed features which are the result of a PCA transformation. Feature ‘Time’ contains the seconds elapsed between each transaction and the first transaction in the dataset. The feature ‘Amount’ is the transaction Amount. Feature ‘Class’ is the response variable and it takes the value 1 in case of fraud and 0 otherwise. Let’s have a look if the data is balanced by plotting the Number of frauds in transactions vs non-frauds.
image

Training the model & predicting

Note: It’s important that we drop any NaN values of Impute them before training IsolationForest, more on it here.

Evaluation & Saving the model

More on understanding classification report function here. image Peliqan’s platform enables businesses to create anomaly detection systems, improving operational efficiency and preventing financial losses. By detecting anomalies in real time, businesses can make informed decisions and take proactive measures to prevent issues before they occur. Expand this to see the full code

Next Steps

  1. You can make real-time predictions on new incoming data and send alerts to slack if the model makes a prediction above a certain threshold.
  2. You can make predictions on real-time incoming data using the saved model. Learn more about making real-time predictions on new incoming data.
  3. Using Peliqan you can create an app for your users to consume the model you have created in a simple and intuitive UI. Learn more about creating apps for users to consume your model.