Repository: evidentlyai/evidently
Issue: How can I change the relative value in of TestNumberOfNulls() ?
Root cause: Documentation Deficiency

Function:

- TestNumberOfNulls()

If I pass a reference dataset in the 

```
data_integrity = TestSuite([
     TestNumberOfNulls()
])
data_integrity_tes.run(reference_data=ref, current_data=curr)

```
The test fails if the share of nulls and missing values is over 10% higher than in reference. The class contains the following lines:

```
        if reference_null_values is not None:
            curr_number_of_rows = self.metric.get_result().current.number_of_rows
            ref_number_of_rows = reference_null_values.number_of_rows
            mult = curr_number_of_rows / ref_number_of_rows
            return TestValueCondition(lte=approx(reference_null_values.number_of_missed_values * mult, relative=0.1))
```
reference: https://github.com/evidentlyai/evidently/blob/c1b1b78f48ecc0c70fa628e8bd98c2daf7611a02/src/evidently/tests/data_integrity_tests.py#L41

I'm asking how can I easily change the value of **relative=0.1** to any other value I wanted ?

Okay, I think I reached the solution (not the best one), but that works:

The following code uses the **metric** instance which is a `DatasetMissingValuesMetric` class to arrive at the `DatasetMissingValuesMetricResult` class and use the attributes/metrics of the Null values of the **reference** and **current** dataset and thus modify the `TestNumberOfNulls()` condition based on the values of the reference dataset

My code:
```
from evidently.tests.data_integrity_tests import TestNumberOfNulls
from evidently.metrics.base_metric import InputData
from evidently.pipeline.column_mapping import ColumnMapping

column_mapping = ColumnMapping()

test_nulls = TestNumberOfNulls()
input_data = InputData(
    reference_data = ref,
    current_data = curr,
    column_mapping = column_mapping
)
data_integrity_null = test_nulls.metric.calculate(input_data)
# First item
data_integrity_null.reference_null_values.number_of_rows

data_integrity_null.current_null_values.number_of_rows

data_integrity_null.reference_null_values.number_of_nulls
```

So, this condition

`lte=approx(reference_null_values.number_of_missed_values * mult, relative=0.1)`

uses the 

`reference_null_values.number_of_missed_values = data_integrity_null.reference_null_values.number_of_nulls`

and 

`mult = data_integrity_null.current_null_values.number_of_rows \ data_integrity_null.reference_null_values.number_of_rows `

So now I can call the following code

```

data_integrity = TestSuite([
     TestNumberOfNulls(
        lte=approx(
                  data_integrity_null.reference_null_values.number_of_nulls *(data_integrity_null.current_null_values.number_of_rows \ data_integrity_null.reference_null_values.number_of_rows `), 
                  relative=0.2
         )
)
])
data_integrity_tes.run(reference_data=ref, current_data=curr)

```

changing the relative=0.2 and still using the metrics of the reference dataset



Hi @samuelamico ,

First of all I apologise for the late answer. You caught us in the middle of major refactoring.

To be completely honest it is not finished yet and right now we do not have the possibility to edit the "relative to the reference" parameter itself. We consider to add it in the future so that it is possible to edit the test default in a simpler way either in the test or in a test preset. Thanks for confirming that it needed!

You can still pass a parameter, you already have a good approach. I can suggest pretty similar way to do it, with a little less code:

```
data_integrity = TestSuite(tests=[
    TestNumberOfNulls(), # default test parameters
    TestNumberOfNulls(lte=approx(ref.isna().sum().sum(), relative=0.2)), # not more than 20% differ from reference
])
                  
data_integrity.run(reference_data=ref, current_data=curr)
data_integrity
```
 
I hope this helps at lest a little  🙂

Thanks so much @emeli-dral . By the way, I'm creating a tutorial for all Tests available in Evidently AI (written in a jupyter notebook), if you want I can share with you. Thanks

Hi @samuelamico! We'll happily share the tutorial through our newsletter and social channels, please share it with us once it is ready! You can also join our Discord if not yet and share it with the community yourself: https://discord.com/invite/xZjKRaNp8b