# Missing Value Test

### Execute Test:

The code snippet provided outlines the process of setting up and executing a Missing Value Test in RagaAI, focusing on detecting data points where text detection and recognition have been missed.

**Step 1: Define the Outlier Detection Rules**

Begin by establishing the criteria for detecting missing values in your dataset.

```
rules = OcrRules()
rules.add(expected_detection={"invoice_date": 1,"total_gross_worth": 1})


ocr_test = ocr_missing_test_analysis(test_session=test_session,
                             dataset_name = "Invoices_Test",
                             test_name = "OCR Missing Value Test",
                             model = "dbnet",
                             type = "ocr",
                             output_type="missing_value",
                             rules = rules)

test_session.add(ocr_test)

test_session.run()

```

* `OCRRules()`: Initialises the rules for missing value detection for OCR Usecases.&#x20;
  * `rules.add()`: Adds a rule for detecting missed values:
    * `expected_detection`: Sets the expected classes to be present in each datapoint.&#x20;

* `ocr_missing_test_analysis()`: Configures the missing value test with the following parameters:
  * `test_session`: The session object tied to your RagaAI project.
  * `dataset_name`: The name of the dataset you are analysing, "Invoices\_Test" here.
  * `test_name`: A name for the test, "OCR Missing Value Test" in this case.
  * `model`: Specifies the OCR model used for inferences, "dbnet" here.
  * `type`: Specify the usecase, "ocr" here.
  * `output_type`: For OCR use cases use output\_type = "missing value".
  * `rules`: The previously defined rules for missing value detection.

* `test_session.add()`: Registers the outlier detection test within the session.

* `test_session.run()`: Starts the execution of all tests in the session, including the outlier detection test.

By completing these steps, you have initiated a Missing Value Test for OCR application on the RagaAI Testing Platform.&#x20;

After the test, carefully review the identified missing values and do a root cause analysis to take remedial actions.

### Analysing Test Results

#### Test Overview

* **Pie Chart**: Provides an overview of the test results using a pie chart compares the percentage of Bbox of classes accurately detected in a dataset according to the expected values set by the user

**Failed Cases Per Class**

* **Bar Graph**: This helps users visualise the count of missing values per class.&#x20;

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2FmSlgEk3ksXWkuox5szqM%2FScreenshot%202024-01-17%20at%2013.55.32.png?alt=media&#x26;token=ceb5575a-4dbd-4ff4-b32c-c0b6340dce3b" alt=""><figcaption></figcaption></figure>

#### Assessing and Visualising Data

* **Datagrid View**: Examine images in the grid view. View datapoints where detections are being missed and drill down to gain more insights.

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2Fsobb4Fx0CylFTFQUbecO%2FScreenshot%202024-01-17%20at%2014.09.03.png?alt=media&#x26;token=ab952f43-9f2b-4e33-a919-f19a737b0131" alt=""><figcaption></figcaption></figure>

#### Interpreting Results

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2F4bKvwJMANh1sh0qAV2MW%2FScreenshot%202024-01-17%20at%2014.10.37.png?alt=media&#x26;token=7d24485c-4fe3-4552-be37-dfc55b9a3756" alt=""><figcaption></figcaption></figure>

* **Expected values:** Number of expected bounding boxes of a class in a datapoint. This information is set by the user while executing the test
* **Actual:** Number of bounding boxes detected of a class in a datapoint.

By adhering to these steps, you can effectively utilise RagaAI to detect and analyse datapoints where detections are being missed in your OCR datasets.
