API Reference
multivariate_ecdf(data_a, data_b, n_nodes = 1000, verbose = True, random_seed = None)
Function to compute ecdf on proportion of row counts generated by dynamic pandas queries on a dataset.
It returns a tuple of query_list and computed ECDFs of both Input Datasets.
The query list is generated using the first dataset as reference. It is a list of query strings combined for each column.
E.g. Say we have a dataframe with two columns x0
& x1
. Then the query string will be generated as x0 <= z0 and x1 <= z1
, where z0
, z1
calculated based on random quantiles that are uniformly distributed on [0, 1], for each feature.
Many such query_strings are generated and their respective count proportions are calculated for getting the ECDF from both the input datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_a |
DataFrame
|
Pandas DataFrame |
required |
data_b |
DataFrame
|
Pandas DataFrame |
required |
n_nodes |
int
|
Specifies the number of nodes i.e. the query strings to be generated. This is a hyperparameter and can be tuned. Defaults to 1000. |
1000
|
verbose |
bool
|
Flag to display progress of the operations. Defaults to True |
True
|
random_seed |
int
|
random seed to be set before
operations. If set random seed is set using |
None
|
Raises:
Type | Description |
---|---|
TypeError
|
Throws error if Input Datasets are not Pandas DataFrames |
ValueError
|
Throws error if any Input Dataset is empty |
ValueError
|
Thows value error if one or more column names between both the |
Returns:
Name | Type | Description |
---|---|---|
List |
Tuple
|
Returns Tuple of query_string & computed ECDFs of both Input Datasets |
Source code in genai_evaluation\genai_evaluation.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
ks_statistic(ecdf_a, ecdf_b)
Function to calculate the KS Statistic between the two input ECDFs. Calculates the maximum separation (distance) between the ECDFs and yields a result ranging from 0 (indicating the best fit) and 1 (indicating the worst fit).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ecdf_a |
List
|
ECDF Generated through the Multivariate ECDF function |
required |
ecdf_a |
List
|
ECDF Generated through the Multivariate ECDF function |
required |
Raises:
Type | Description |
---|---|
ValueEror
|
Throws error if the input ECDFs' are empty or their lengths are not equal |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Returns KS Statistic |
Source code in genai_evaluation\genai_evaluation.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|