> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mathfi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Banknote forgery detection: binary classification

> Banknote forgery detection: binary classification of authentic vs counterfeit notes using MathFi.ai.

### The problem: detection of forged banknotes

MathFi.ai Platform can classify images, and perform prediction based on images, when the image characteristics has been converted to rows of numerical or text features and put into a tabular data format in a CSV file. As an example, in this project we demonstrate how MathFi.ai can help banks detect banknote forgery with accuracy of 100% (F1=1 score).

### The data

For this case, we're going to develop a **binary classification model** to detect which banknotes are fake.

Within <a href="/files/banknote-forgery/banknote-forgery-labelled.csv" target="_blank">the labelled training csv file</a>, each row represents the characteristics of an image for a single banknote. The data features are:

| Parameter           | Type / Units      | Description                                          |
| ------------------- | ----------------- | ---------------------------------------------------- |
| `MachineIdentifier` | identifier        | ID of the individual banknote.                       |
| `variance_of_image` | continuous        | Variance of the Wavelet Transformed banknote image.  |
| `skewness`          | continuous        | Skewness of the Wavelet Transformed banknote image.  |
| `kurtosis`          | continuous        | Kurtosis of the Wavelet Transformed banknote image.  |
| `entropy`           | continuous        | Entropy of the banknote image.                       |
| `Result`            | categorical (0/1) | Target variable — `0` if genuine, `1` if fraudulent. |

<br />

<img src="https://mintcdn.com/mathficast/vsPVxXb4l3VcjgSi/images/usecases/banknote-forgery/banknote-forgery-labelled-csv.png?fit=max&auto=format&n=vsPVxXb4l3VcjgSi&q=85&s=9814c9911e271bdc6dda3f44dc6df50e" alt="Banknote forgery CSV" width="767" height="720" data-path="images/usecases/banknote-forgery/banknote-forgery-labelled-csv.png" />

<br />

<Note>**Disclaimer**: The data files used in this use case are altered, transformed and edited version of the data present in [https://archive.ics.uci.edu/dataset/267/banknote+authentication](https://archive.ics.uci.edu/dataset/267/banknote+authentication)</Note>

### Dataset creation

Use the following parameters for dataset creation:

* **number of buckets**: `20`

<img src="https://mintcdn.com/mathficast/vsPVxXb4l3VcjgSi/images/usecases/banknote-forgery/banknote-forgery-dataset-creation.png?fit=max&auto=format&n=vsPVxXb4l3VcjgSi&q=85&s=f564fb043db58257d94f295b0adf60d1" alt="Dataset creation" width="1378" height="592" data-path="images/usecases/banknote-forgery/banknote-forgery-dataset-creation.png" />

<br />

### Training

This is the best training attempt:

* **Scaling factor**: `19`
* **Performance Threshold**: `0.98`

<img src="https://mintcdn.com/mathficast/vsPVxXb4l3VcjgSi/images/usecases/banknote-forgery/banknote-forgery-best-training.png?fit=max&auto=format&n=vsPVxXb4l3VcjgSi&q=85&s=3c1cac4cf1d8921bbffd918b6742c9f7" alt="Training params" width="1377" height="595" data-path="images/usecases/banknote-forgery/banknote-forgery-best-training.png" />

And the created *champion model*:

<img src="https://mintcdn.com/mathficast/vsPVxXb4l3VcjgSi/images/usecases/banknote-forgery/banknote-forgery-training-result.png?fit=max&auto=format&n=vsPVxXb4l3VcjgSi&q=85&s=c5132cb6eb296fed91046de07b928f7c" alt="Training best" width="1376" height="643" data-path="images/usecases/banknote-forgery/banknote-forgery-training-result.png" />

<br />

The final performance of `0.98` was achieved after few iterations of [hyperparameter tuning](/guides/hyperparameter-tuning):

| Number of Buckets | Scaling Factor | Performance Threshold |
| ----------------: | -------------: | --------------------: |
|                20 |             19 |                  0.80 |
|                20 |             19 |                  0.95 |
|                20 |             19 |                  0.95 |
|                20 |             19 |                  0.97 |
|                20 |             19 |                  0.98 |

<br />

### Final result

When performing binary classifications or predictions, MathFi.ai platform's underlying proprietary algorithms calculate the probability of certainty for a prediction outcome.

* One label (e.g.`1`) will be selected when the probability is equal or above `0.5`
* and the other one (e.g. `0`) will be selected when the probability is below `0.5`

The closer the value is to `0` or `1`, the more certain is the prediction. The probability is presented in a dedicated column in the prediction result file.

Using <a href="/files/banknote-forgery/banknote-forgery-unseen.csv" target="_blank">this unseen unlabelled data</a>, the <a href="/files/banknote-forgery/banknote-forgery-prediction-result.csv" target="_blank">resulting labelled CSV</a> looks like this:

<img src="https://mintcdn.com/mathficast/vsPVxXb4l3VcjgSi/images/usecases/banknote-forgery/banknote-forgery-prediction-result.png?fit=max&auto=format&n=vsPVxXb4l3VcjgSi&q=85&s=d07e70f21907149b91a12dc093afb394" alt="Prediction 2" width="1909" height="903" data-path="images/usecases/banknote-forgery/banknote-forgery-prediction-result.png" />

***

**Build this yourself** — Follow the [Quickstart](/quickstart) to run your first prediction, or go straight to [API Recipes](/developers/api-recipes) to integrate programmatically.
