bowdbeg commited on
Commit
fcc706c
·
1 Parent(s): b7ef094

add documents

Browse files
Files changed (3) hide show
  1. README.md +115 -31
  2. __main__.py +2 -2
  3. matching_series.py +139 -28
README.md CHANGED
@@ -26,9 +26,97 @@ At minium, the metric requires the original time-series and the generated time-s
26
  >>> references = np.random.rand(num_reference, seq_len, num_features)
27
  >>> predictions = np.random.rand(num_generation, seq_len, num_features)
28
  >>> metric = evaluate.load("bowdbeg/matching_series")
29
- >>> results = metric.compute(references=references, predictions=predictions, batch_size=1000)
30
  >>> print(results)
31
- {'precision_distance': 0.15843592698313289, 'f1_distance': 0.155065974239652, 'recall_distance': 0.1518363944110798, 'index_distance': 0.17040952035850207, 'precision_distance_features': [0.13823438020409948, 0.13795530908046955, 0.13737011148651265, 0.14067189082974238, 0.1364122789352347, 0.1436081670647643, 0.14458237409706912, 0.13806270434163667, 0.1409687410230486, 0.14361925950728213], 'f1_distance_features': [0.1296088638995658, 0.1321776706161825, 0.13029775314091577, 0.13175439826605778, 0.12737279060587542, 0.1356699896603108, 0.13397234988746393, 0.12775081706715302, 0.1315612879575721, 0.13479662354178928], 'recall_distance_features': [0.12199655178880468, 0.12686452003437784, 0.12391796468320122, 0.12390010513296679, 0.11945686853897312, 0.12856343456552471, 0.12481307474748718, 0.11887226171295895, 0.12333088520535256, 0.1269952147807759], 'index_distance_features': [0.1675969516703118, 0.1670366499114896, 0.1671737398882021, 0.17176917018356727, 0.1648541323369367, 0.1719173137987784, 0.1718364937170575, 0.16298119493341198, 0.17348958360035996, 0.18543997354490532], 'macro_precision_distance': 0.14014852165698596, 'macro_recall_distance': 0.1238710881190423, 'macro_f1_distance': 0.13149625446428864, 'macro_index_distance': 0.17040952035850207, 'matching_precision': 0.1, 'matching_recall': 1.0, 'matching_f1': 0.18181818181818182, 'matching_precision_features': [0.9, 0.9, 0.8, 0.9, 0.9, 0.9, 1.0, 0.8, 1.0, 1.0], 'matching_recall_features': [0.1, 0.09, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], 'matching_f1_features': [0.18, 0.16363636363636364, 0.17777777777777778, 0.18, 0.18, 0.18, 0.18181818181818182, 0.17777777777777778, 0.18181818181818182, 0.18181818181818182], 'macro_matching_precision': 0.91, 'macro_matching_recall': 0.099, 'macro_matching_f1': 0.17846464646464646, 'cuc': 0.12364285714285712, 'coverages': [0.10000000000000002, 0.20000000000000004, 0.3333333333333333, 0.4666666666666666, 0.7666666666666666, 0.9333333333333332, 1.0], 'macro_cuc': 0.12047857142857143, 'macro_coverages': [0.10000000000000002, 0.19000000000000003, 0.32666666666666666, 0.51, 0.72, 0.8966666666666667, 0.99], 'cuc_features': [0.1175, 0.11607142857142858, 0.12214285714285712, 0.12507142857142856, 0.1202142857142857, 0.11735714285714285, 0.12042857142857144, 0.12028571428571429, 0.12864285714285717, 0.11707142857142858], 'coverages_features': [[0.10000000000000002, 0.20000000000000004, 0.3, 0.43333333333333335, 0.6666666666666666, 0.8666666666666667, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3666666666666667, 0.5666666666666667, 0.6666666666666666, 0.9, 0.9], [0.10000000000000002, 0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.9333333333333332, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3333333333333333, 0.5666666666666667, 0.7999999999999999, 0.9333333333333332, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3333333333333333, 0.43333333333333335, 0.6999999999999998, 0.9, 1.0], [0.10000000000000002, 0.20000000000000004, 0.26666666666666666, 0.43333333333333335, 0.6666666666666666, 0.8666666666666667, 1.0], [0.10000000000000002, 0.16666666666666666, 0.4000000000000001, 0.6, 0.7333333333333334, 0.8666666666666667, 1.0], [0.10000000000000002, 0.16666666666666666, 0.3, 0.5666666666666667, 0.7666666666666666, 0.8666666666666667, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.5333333333333333, 0.8000000000000002, 1.0, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3333333333333333, 0.4666666666666666, 0.7333333333333334, 0.8333333333333334, 1.0]]}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ```
33
 
34
  ### Inputs
@@ -38,6 +126,15 @@ At minium, the metric requires the original time-series and the generated time-s
38
  - **cuc_n_calculation**: (int, optional): The number of samples to compute the coverage because sampling exists. Default is 3.
39
  - **cuc_n_samples**: (list of int, optional): The number of samples to compute the coverage. Default is $[2^i \text{for} i \leq \log_2 n] + [n]$.
40
  - **metric**: (str, optional): The metric to measure distance between examples. Default is "mse". Available options are "mse", "mae", "rmse".
 
 
 
 
 
 
 
 
 
41
 
42
  ### Output Values
43
 
@@ -45,43 +142,30 @@ Let prediction instances be $P = \{p_1, p_2, \ldots, p_n\}$ and reference instan
45
 
46
  - **precision_distance**: (float): Average of the distance between the generated instance and the reference instance with the lowest distance. Intuitively, this is similar to precision in classification. In the equation, $\frac{1}{n} \sum_{i=1}^{n} \min_{j} \mathrm{distance}(p_i, r_j)$.
47
  - **recall_distance**: (float): Average of the distance between the reference instance and the with the lowest distance. Intuitively, this is similar to recall in classification. In the equation, $\frac{1}{m} \sum_{j=1}^{m} \min_{i} \mathrm{distance}(p_i, r_j)$.
48
- - **f1_distance**: (float): Harmonic mean of the precision_distance and recall_distance. This is similar to F1-score in classification.
49
  - **index_distance**: (float): Average of the distance between the generated instance and the reference instance with the same index. In the equation, $\frac{1}{n} \sum_{i=1}^{n} \mathrm{distance}(p_i, r_i)$.
50
- - **precision_distance_features**: (list of float): precision_distance computed individually for each feature.
51
- - **recall_distance_features**: (list of float): recall_distance computed individually for each feature.
52
- - **f1_distance_features**: (list of float): f1_distance computed individually for each feature.
53
- - **index_distance_features**: (list of float): index_distance computed individually for each feature.
54
- - **macro_precision_distance**: (float): Average of the precision_distance_features.
55
- - **macro_recall_distance**: (float): Average of the recall_distance_features.
56
- - **macro_f1_distance**: (float): Average of the f1_distance_features.
57
- - **macro_index_distance**: (float): Average of the index_distance_features.
58
- - **matching_precision**: (float): Precision of the matching instances. In the equation, $\frac{ | \{i | \min_{i} \mathrm{distance}(p_i, r_j)\} | }{m}$.
59
- - **matching_recall**: (float): Recall of the matching instances. In the equation, $\frac{ | \{j | \min_{j} \mathrm{distance}(p_i, r_j)\} | }{n}$.
60
- - **matching_f1**: (float): F1-score of the matching instances.
61
- - **matching_precision_features**: (list of float): matching_precision computed individually for each feature.
62
- - **matching_recall_features**: (list of float): matching_recall computed individually for each feature.
63
- - **matching_f1_features**: (list of float): matching_f1 computed individually for each feature.
64
- - **macro_matching_precision**: (float): Average of the matching_precision_features.
65
- - **macro_matching_recall**: (float): Average of the matching_recall_features.
66
- - **macro_matching_f1**: (float): Average of the matching_f1_features.
67
- - **coverages**: (list of float): Coverage of the matching instances computed on the sampled generated data in cuc_n_samples. In the equation, $[\frac{ | \{ j | \min_{j} \mathrm{distance}(p_i, r_j) \text{where}~p_i \in \mathrm{sample}(P, \mathrm{n\_sample}) \} | }{m} \text{for}~\mathrm{n\_sample} \in \mathrm{cuc\_n\_samples} ]$.
68
- - **cuc**: (float): Coverage of the matching instances. In the equation, $\frac{ | \{i | \min_{i} \mathrm{distance}(p_i, r_j) < \mathrm{threshold}\} | }{n}$.
69
- - **coverages_features**: (list of list of float): coverages computed individually for each feature.
70
- - **cuc_features**: (list of float): cuc computed individually for each feature.
71
- - **macro_coverages**: (list of float): Average of the coverages_features.
72
- - **macro_cuc**: (float): Average of the cuc_features.
73
-
74
- #### Values from Popular Papers
75
  <!-- *Give examples, preferrably with links to leaderboards or publications, to papers that have reported this metric, along with the values they have reported.* -->
76
 
77
- ### Examples
78
  <!-- *Give code examples of the metric being used. Try to include examples that clear up any potential ambiguity left from the metric description above. If possible, provide a range of examples that show both typical and atypical results, as well as examples where a variety of input parameters are passed.* -->
79
 
80
  ## Limitations and Bias
81
  This metric is based on the assumption that the generated time-series should match the original time-series. This may not be the case in some scenarios. The metric may not be suitable for evaluating time-series generation models that are not required to match the original time-series.
82
 
83
- ## Citation
84
  <!-- *Cite the source where this metric was introduced.* -->
85
 
86
- ## Further References
87
  <!-- *Add any useful further references.* -->
 
26
  >>> references = np.random.rand(num_reference, seq_len, num_features)
27
  >>> predictions = np.random.rand(num_generation, seq_len, num_features)
28
  >>> metric = evaluate.load("bowdbeg/matching_series")
29
+ >>> results = metric.compute(references=references, predictions=predictions, batch_size=1000, return_all=True)
30
  >>> print(results)
31
+ {'precision_distance': 0.1573285013437271, 'recall_distance': 0.15106813609600067, 'mean_distance': 0.1541983187198639, 'index_distance': 0.16858606040477753, 'matching_precision': 0.06, 'matching_recall': 1.0, 'matching_f1': 0.11320756503381972, 'cuc': 0.12428571428571429, 'macro_precision_distance': 0.13803552389144896, 'macro_recall_distance': 0.12179495096206665, 'macro_mean_distance': 0.1299152374267578, 'macro_index_distance': 0.16858604848384856, 'macro_matching_precision': 0.094, 'macro_matching_recall': 0.97, 'macro_matching_f1': 0.17132608782381706, 'macro_cuc': 0.11419285714285714, 'distance': array([[[0.20763363, 0.16514072, 0.18695284, ..., 0.15037987,
32
+ 0.19424284, 0.15943716],
33
+ [0.17150438, 0.18020014, 0.17024504, ..., 0.18492931,
34
+ 0.18814348, 0.204207 ],
35
+ [0.1769202 , 0.15609328, 0.17568389, ..., 0.17731658,
36
+ 0.2027854 , 0.13216409],
37
+ ...,
38
+ [0.1838122 , 0.19475608, 0.14176111, ..., 0.1635111 ,
39
+ 0.1652672 , 0.17145865],
40
+ [0.16084194, 0.14208058, 0.17567575, ..., 0.15595785,
41
+ 0.16614595, 0.17834347],
42
+ [0.16388315, 0.14126392, 0.18021484, ..., 0.16791071,
43
+ 0.18403953, 0.16666758]],
44
+
45
+ [[0.16838932, 0.18878576, 0.17654441, ..., 0.1747057 ,
46
+ 0.16590554, 0.16901629],
47
+ [0.16553226, 0.1882645 , 0.17863466, ..., 0.19269662,
48
+ 0.20451452, 0.19941731],
49
+ [0.16502398, 0.16619626, 0.18069996, ..., 0.16124909,
50
+ 0.18933088, 0.1495165 ],
51
+ ...,
52
+ [0.15946846, 0.19988221, 0.17965002, ..., 0.12951666,
53
+ 0.2067793 , 0.13811146],
54
+ [0.16227122, 0.17736743, 0.18641905, ..., 0.15038314,
55
+ 0.20186146, 0.17849396],
56
+ [0.16410898, 0.18323919, 0.16945514, ..., 0.15783694,
57
+ 0.21556957, 0.17172968]],
58
+
59
+ [[0.18094379, 0.1364854 , 0.18436092, ..., 0.187335 ,
60
+ 0.16240291, 0.13713893],
61
+ [0.18005298, 0.15323727, 0.15788248, ..., 0.19451861,
62
+ 0.12822135, 0.14064161],
63
+ [0.1564556 , 0.17312287, 0.1856657 , ..., 0.17237219,
64
+ 0.1596888 , 0.16547912],
65
+ ...,
66
+ [0.15611127, 0.16121496, 0.15533476, ..., 0.16520709,
67
+ 0.1427248 , 0.19455005],
68
+ [0.17268528, 0.17360437, 0.15962966, ..., 0.18134868,
69
+ 0.15509704, 0.20222983],
70
+ [0.18704675, 0.15934442, 0.14928888, ..., 0.18904984,
71
+ 0.16192877, 0.18576236]],
72
+
73
+ ...,
74
+
75
+ [[0.13717972, 0.15645625, 0.16123378, ..., 0.19453087,
76
+ 0.14441733, 0.1487963 ],
77
+ [0.1454296 , 0.13368016, 0.18665504, ..., 0.16096605,
78
+ 0.15130125, 0.18332979],
79
+ [0.14654924, 0.19097947, 0.19629759, ..., 0.15887487,
80
+ 0.19266474, 0.17430782],
81
+ ...,
82
+ [0.161704 , 0.16357127, 0.18512094, ..., 0.16441964,
83
+ 0.13961458, 0.17298506],
84
+ [0.1366249 , 0.15852758, 0.1982772 , ..., 0.18822236,
85
+ 0.16153064, 0.19617072],
86
+ [0.14570995, 0.15005183, 0.19667573, ..., 0.1856473 ,
87
+ 0.18603194, 0.19179863]],
88
+
89
+ [[0.17813908, 0.176182 , 0.16847256, ..., 0.16903524,
90
+ 0.17150073, 0.15068175],
91
+ [0.17632519, 0.1404587 , 0.16388708, ..., 0.16873878,
92
+ 0.15744762, 0.198475 ],
93
+ [0.14986345, 0.1517829 , 0.17624639, ..., 0.18365957,
94
+ 0.17399347, 0.15581599],
95
+ ...,
96
+ [0.16128553, 0.1974935 , 0.13766351, ..., 0.14026196,
97
+ 0.15450196, 0.16110381],
98
+ [0.16281141, 0.14699166, 0.16935429, ..., 0.1394466 ,
99
+ 0.1717883 , 0.16191883],
100
+ [0.14886455, 0.1603608 , 0.15172943, ..., 0.12851712,
101
+ 0.19859877, 0.15576601]],
102
+
103
+ [[0.20230632, 0.19680001, 0.17143433, ..., 0.18601838,
104
+ 0.15998998, 0.16043548],
105
+ [0.19753966, 0.19073424, 0.15046756, ..., 0.18833323,
106
+ 0.16755773, 0.20127842],
107
+ [0.16012056, 0.16638812, 0.16493171, ..., 0.15849902,
108
+ 0.20269662, 0.1857642 ],
109
+ ...,
110
+ [0.16341361, 0.19168772, 0.16597596, ..., 0.15715535,
111
+ 0.18122095, 0.17266828],
112
+ [0.1570099 , 0.18294124, 0.16713732, ..., 0.17442709,
113
+ 0.17020254, 0.18804537],
114
+ [0.16752282, 0.1295177 , 0.18792175, ..., 0.13976808,
115
+ 0.21054329, 0.18118018]]], dtype=float32), 'match': array([4, 7, 3, 9, 4, 0, 7, 5, 4, 7, 9, 7, 7, 5, 7, 0, 0, 7, 4, 3, 3, 2,
116
+ 8, 9, 4, 4, 5, 1, 4, 9, 0, 2, 7, 3, 6, 5, 6, 3, 2, 2, 2, 6, 9, 4,
117
+ 4, 9, 1, 6, 0, 6, 9, 2, 0, 6, 7, 2, 0, 4, 5, 2, 3, 9, 2, 3, 9, 1,
118
+ 6, 4, 8, 9, 7, 4, 6, 5, 5, 6, 9, 5, 6, 2, 9, 4, 9, 3, 2, 9, 9, 7,
119
+ 9, 5, 9, 1, 7, 6, 4, 4, 5, 4, 7, 5]), 'match_inv': array([15, 91, 79, 4, 4, 4, 49, 4, 49, 45]), 'coverages': [0.10000000000000002, 0.16666666666666666, 0.3666666666666667, 0.6333333333333333, 0.8333333333333334, 0.9, 1.0], 'precision_distance_features': [0.1383965164422989, 0.13804036378860474, 0.1388234943151474, 0.1392393559217453, 0.1357768476009369, 0.1364508718252182, 0.14039862155914307, 0.13417008519172668, 0.1368638128042221, 0.14219526946544647], 'recall_distance_features': [0.11730053275823593, 0.12232911586761475, 0.12200610339641571, 0.12571024894714355, 0.12081331014633179, 0.11693283170461655, 0.12660981714725494, 0.12248671054840088, 0.11726576089859009, 0.12649507820606232], 'mean_distance_features': [0.1278485246002674, 0.13018473982810974, 0.13041479885578156, 0.13247480243444443, 0.12829507887363434, 0.12669185176491737, 0.133504219353199, 0.12832839787006378, 0.1270647868514061, 0.1343451738357544], 'index_distance_features': [0.17064405977725983, 0.17019756138324738, 0.17373089492321014, 0.17575454711914062, 0.15942324697971344, 0.1615942418575287, 0.16519878804683685, 0.1714271903038025, 0.17072594165802002, 0.16716401278972626], 'matching_precision_features': [0.1, 0.09, 0.1, 0.1, 0.09, 0.09, 0.1, 0.08, 0.09, 0.1], 'matching_recall_features': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.9, 0.9, 0.9, 1.0], 'matching_f1_features': [0.18181819851239656, 0.16513763164885095, 0.18181819851239656, 0.18181819851239656, 0.16513763164885095, 0.16513763164885095, 0.18000001639999985, 0.14693879251145342, 0.16363638033057834, 0.18181819851239656], 'cuc_features': [0.11935714285714286, 0.11578571428571431, 0.11814285714285715, 0.12407142857142857, 0.11207142857142856, 0.11821428571428572, 0.10807142857142855, 0.09635714285714285, 0.10700000000000001, 0.12285714285714286], 'coverages_features': [[0.10000000000000002, 0.20000000000000004, 0.26666666666666666, 0.4666666666666666, 0.7666666666666666, 0.8666666666666667, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3666666666666667, 0.5666666666666668, 0.6, 0.8333333333333334, 1.0], [0.10000000000000002, 0.16666666666666666, 0.26666666666666666, 0.4666666666666666, 0.6999999999999998, 0.8666666666666667, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.6, 0.7333333333333333, 0.9333333333333332, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.5, 0.6666666666666666, 0.7666666666666666, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3333333333333333, 0.5333333333333333, 0.7666666666666666, 0.8333333333333334, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.5333333333333333, 0.6999999999999998, 0.7666666666666666, 0.9], [0.10000000000000002, 0.20000000000000004, 0.2333333333333333, 0.4666666666666666, 0.5333333333333333, 0.6333333333333333, 0.9], [0.10000000000000002, 0.16666666666666666, 0.26666666666666666, 0.4666666666666666, 0.5666666666666667, 0.8000000000000002, 0.9], [0.10000000000000002, 0.16666666666666666, 0.30000000000000004, 0.5666666666666667, 0.7999999999999999, 0.9, 1.0]]}
120
  ```
121
 
122
  ### Inputs
 
126
  - **cuc_n_calculation**: (int, optional): The number of samples to compute the coverage because sampling exists. Default is 3.
127
  - **cuc_n_samples**: (list of int, optional): The number of samples to compute the coverage. Default is $[2^i \text{for} i \leq \log_2 n] + [n]$.
128
  - **metric**: (str, optional): The metric to measure distance between examples. Default is "mse". Available options are "mse", "mae", "rmse".
129
+ - **num_processes**: (int, optional): The number of processes to use for computing the distance. Default is 1.
130
+ - **instance_normalization**: (bool, optional): Whether to normalize the instances along the time axis. Default is False.
131
+ - **return_distance**: (bool, optional): Whether to return the distance matrix. Default is False.
132
+ - **return_matching**: (bool, optional): Whether to return the matching matrix. Default is False.
133
+ - **return_each_features**: (bool, optional): Whether to return the results for each feature. Default is False.
134
+ - **return_coverages**: (bool, optional): Whether to return the coverages. Default is False.
135
+ - **return_all**: (bool, optional): Whether to return all the results. Default is False.
136
+ - **dtype**: (str, optional): The data type used for computation. Default is "float32".
137
+ - **eps**: (float, optional): The epsilon value to avoid division by zero. Default is 1e-8.
138
 
139
  ### Output Values
140
 
 
142
 
143
  - **precision_distance**: (float): Average of the distance between the generated instance and the reference instance with the lowest distance. Intuitively, this is similar to precision in classification. In the equation, $\frac{1}{n} \sum_{i=1}^{n} \min_{j} \mathrm{distance}(p_i, r_j)$.
144
  - **recall_distance**: (float): Average of the distance between the reference instance and the with the lowest distance. Intuitively, this is similar to recall in classification. In the equation, $\frac{1}{m} \sum_{j=1}^{m} \min_{i} \mathrm{distance}(p_i, r_j)$.
145
+ - **mean_disntance**: (float): Average of the precision_distance and recall_distance.
146
  - **index_distance**: (float): Average of the distance between the generated instance and the reference instance with the same index. In the equation, $\frac{1}{n} \sum_{i=1}^{n} \mathrm{distance}(p_i, r_i)$.
147
+ - **matching_precision**: (float): Precision of the matching instances, which means how predictions are covered by references, i.e., how accurate the predictions are. In the equation, $\frac{ | \{i | \argmin_{i} \mathrm{distance}(p_i, r_j)\} | }{n}$.
148
+ - **matching_recall**: (float): Recall of the matching instances, which means how predictions cover references. In the equation, $\frac{ | \{j | \argmin_{j} \mathrm{distance}(p_i, r_j)\} | }{m}$.
149
+ - **matching_f1**: (float): F1-score of the matching instances, harmonic mean of the matching_precision and matching_recall.
150
+ - **coverages**: (list of float): Coverage of the matching instances computed on the sampled generated data in cuc_n_samples. In the equation, $[\frac{1}{m} | \{ j \mid \argmin_{j} \mathrm{distance}(p_i, r_j)~\text{where $p_i \in \mathrm{sample}(P, \mathrm{n\_sample})$} \} | ~\text{for}~\mathrm{n\_sample} \in \mathrm{cuc\_n\_samples} ]$.
151
+ - **cuc**: (float): Under the curve of the coverage. In the equation, $\int_{0}^{n} \mathrm{coverage}(x) dx$. As an approximation, the trapezoidal rule is used.
152
+ - **.\*_features**: (list of float): The values computed individually for each feature.
153
+ - **macro_.\***: (float): Averaged values computed for each feature, average of the \*\_features.
154
+ - **distance**: (numpy.ndarray): The distance matrix between the generated instances and the reference instances.
155
+ - **match**: (numpy.ndarray): The matching matrix between the generated instances and the reference instances.
156
+ - **match_inv**: (numpy.ndarray): The matching matrix between the reference instances and the generated instances.
157
+
158
+ <!-- #### Values from Popular Papers -->
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  <!-- *Give examples, preferrably with links to leaderboards or publications, to papers that have reported this metric, along with the values they have reported.* -->
160
 
161
+ <!-- ### Examples -->
162
  <!-- *Give code examples of the metric being used. Try to include examples that clear up any potential ambiguity left from the metric description above. If possible, provide a range of examples that show both typical and atypical results, as well as examples where a variety of input parameters are passed.* -->
163
 
164
  ## Limitations and Bias
165
  This metric is based on the assumption that the generated time-series should match the original time-series. This may not be the case in some scenarios. The metric may not be suitable for evaluating time-series generation models that are not required to match the original time-series.
166
 
167
+ <!-- ## Citation -->
168
  <!-- *Cite the source where this metric was introduced.* -->
169
 
170
+ <!-- ## Further References -->
171
  <!-- *Add any useful further references.* -->
__main__.py CHANGED
@@ -15,7 +15,7 @@ parser.add_argument("predictions", type=str, help="Path to the numpy array conta
15
  parser.add_argument("references", type=str, help="Path to the numpy array containing the references")
16
  parser.add_argument("--output", type=str, help="Path to the output file")
17
  parser.add_argument("--batch_size", type=int, help="Batch size to use for the computation")
18
- parser.add_argument("--num_process", type=int, help="Batch size to use for the computation", default=1)
19
  parser.add_argument("--dtype", type=str, help="Data type to use for the computation", default="float32")
20
  parser.add_argument("--debug", action="store_true", help="Debug mode")
21
  args = parser.parse_args()
@@ -43,7 +43,7 @@ results = metric.compute(
43
  predictions=predictions,
44
  references=references,
45
  batch_size=args.batch_size,
46
- num_process=args.num_process,
47
  return_each_features=True,
48
  return_coverages=True,
49
  dtype=args.dtype,
 
15
  parser.add_argument("references", type=str, help="Path to the numpy array containing the references")
16
  parser.add_argument("--output", type=str, help="Path to the output file")
17
  parser.add_argument("--batch_size", type=int, help="Batch size to use for the computation")
18
+ parser.add_argument("--num_processes", type=int, help="Batch size to use for the computation", default=1)
19
  parser.add_argument("--dtype", type=str, help="Data type to use for the computation", default="float32")
20
  parser.add_argument("--debug", action="store_true", help="Debug mode")
21
  args = parser.parse_args()
 
43
  predictions=predictions,
44
  references=references,
45
  batch_size=args.batch_size,
46
+ num_processes=args.num_process,
47
  return_each_features=True,
48
  return_coverages=True,
49
  dtype=args.dtype,
matching_series.py CHANGED
@@ -11,7 +11,7 @@
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
- """TODO: Add a description here."""
15
 
16
  import concurrent.futures
17
  import math
@@ -23,37 +23,150 @@ import evaluate
23
  import numpy as np
24
 
25
  # TODO: Add BibTeX citation
26
- _CITATION = """\
27
- @InProceedings{huggingface:module,
28
- title = {A great new module},
29
- authors={huggingface, Inc.},
30
- year={2020}
31
- }
32
- """
33
 
34
  # TODO: Add description of the module here
35
  _DESCRIPTION = """\
36
- This new module is designed to solve this great ML task and is crafted with a lot of care.
37
  """
38
 
39
 
40
- # TODO: Add description of the arguments of the module here
41
  _KWARGS_DESCRIPTION = """
42
  Calculates how good are predictions given some references, using certain scores
43
  Args:
44
- predictions: list of generated time series.
45
- shape: (num_generation, num_timesteps, num_features)
46
- references: list of reference
47
- shape: (num_reference, num_timesteps, num_features)
 
 
 
 
 
 
 
 
 
 
 
48
  Returns:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  Examples:
50
  Examples should be written in doctest format, and should illustrate how
51
  to use the function.
52
 
53
- >>> my_new_module = evaluate.load("bowdbeg/matching_series")
54
- >>> results = my_new_module.compute(references=[[[0.0, 1.0]]], predictions=[[[0.0, 1.0]]])
 
 
 
 
 
 
55
  >>> print(results)
56
- {'matchin': 1.0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  """
58
 
59
 
@@ -135,15 +248,15 @@ class matching_series(evaluate.Metric):
135
  cuc_n_calculation: int = 3,
136
  cuc_n_samples: Union[List[int], str] = "auto",
137
  metric: str = "mse",
138
- num_process: int = 1,
 
139
  return_distance: bool = False,
140
  return_matching: bool = False,
141
  return_each_features: bool = False,
142
  return_coverages: bool = False,
143
  return_all: bool = False,
144
  dtype=np.float32,
145
- instance_normalization: bool = False,
146
- eps: float = 1e-10,
147
  ):
148
  """
149
  Compute the scores of the module given the predictions and references
@@ -185,7 +298,7 @@ class matching_series(evaluate.Metric):
185
  references=references,
186
  metric=metric,
187
  batch_size=batch_size,
188
- num_process=num_process,
189
  dtype=dtype,
190
  )
191
 
@@ -281,13 +394,13 @@ class matching_series(evaluate.Metric):
281
  references: np.ndarray,
282
  metric: str,
283
  batch_size: Optional[int] = None,
284
- num_process: int = 1,
285
  dtype=np.float32,
286
  ):
287
  # distance between predictions and references for all example combinations for each features
288
  # shape: (num_generation, num_reference, num_features)
289
  if batch_size is not None:
290
- if num_process > 1:
291
  distance = np.zeros((len(predictions), len(references), predictions.shape[-1]), dtype=dtype)
292
  idxs = [
293
  (i, j)
@@ -298,7 +411,7 @@ class matching_series(evaluate.Metric):
298
  (predictions[i : i + batch_size, None], references[None, j : j + batch_size], metric, -2)
299
  for i, j in idxs
300
  ]
301
- with concurrent.futures.ProcessPoolExecutor(max_workers=num_process) as executor:
302
  results = executor.map(
303
  self._compute_distance,
304
  *zip(*args),
@@ -325,7 +438,7 @@ class matching_series(evaluate.Metric):
325
  def _compute_metrics(
326
  self,
327
  distance: np.ndarray,
328
- eps: float = 1e-10,
329
  cuc_n_calculation: int = 3,
330
  cuc_n_samples: Union[List[int], str] = "auto",
331
  ) -> dict[str, float | list[float]]:
@@ -348,19 +461,17 @@ class matching_series(evaluate.Metric):
348
  best_match_inv = np.argmin(distance, axis=0)
349
  recall_distance = distance[best_match_inv, np.arange(len(best_match_inv))].mean().item()
350
 
351
- f1_distance = 2 / (1 / (precision_distance + eps) + 1 / (recall_distance + eps))
352
  mean_distance = (precision_distance + recall_distance) / 2
353
 
354
  # matching precision, recall and f1
355
- matching_recall = np.unique(best_match).size / len(best_match_inv)
356
  matching_precision = np.unique(best_match_inv).size / len(best_match)
 
357
  matching_f1 = 2 / (1 / (matching_precision + eps) + 1 / (matching_recall + eps))
358
 
359
  # cuc
360
  coverages, cuc = self.compute_cuc(best_match, len(best_match_inv), cuc_n_calculation, cuc_n_samples)
361
  return {
362
  "precision_distance": precision_distance,
363
- "f1_distance": f1_distance,
364
  "recall_distance": recall_distance,
365
  "mean_distance": mean_distance,
366
  "index_distance": index_distance,
 
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
+ """Matching Series is a metric for evaluating time-series generation models. It is based on the idea of matching the generated time-series with the original time-series. The metric calculates the Mean Squared Error (distance) between the generated time-series and the original time-series between matched instances."""
15
 
16
  import concurrent.futures
17
  import math
 
23
  import numpy as np
24
 
25
  # TODO: Add BibTeX citation
26
+ _CITATION = """TBA"""
 
 
 
 
 
 
27
 
28
  # TODO: Add description of the module here
29
  _DESCRIPTION = """\
30
+ Matching Series is a metric for evaluating time-series generation models. It is based on the idea of matching the generated time-series with the original time-series. The metric calculates the Mean Squared Error (distance) between the generated time-series and the original time-series between matched instances. The metric outputs a score greater or equal to 0, where 0 indicates a perfect generation.
31
  """
32
 
33
 
 
34
  _KWARGS_DESCRIPTION = """
35
  Calculates how good are predictions given some references, using certain scores
36
  Args:
37
+ predictions: list of list of list of float or numpy.ndarray: The generated time-series. The shape of the array should be `(num_generation, seq_len, num_features)`.
38
+ references: list of list of list of float or numpy.ndarray: The original time-series. The shape of the array should be `(num_reference, seq_len, num_features)`.
39
+ batch_size: int, optional: The batch size for computing the metric. This affects quadratically. Default is None.
40
+ cuc_n_calculation: int, optional: The number of samples to compute the coverage because sampling exists. Default is 3.
41
+ cuc_n_samples: list of int, optional: The number of samples to compute the coverage. Default is $[2^i \text{for} i \leq \log_2 n] + [n]$.
42
+ metric: str, optional: The metric to measure distance between examples. Default is "mse". Available options are "mse", "mae", "rmse".
43
+ num_processes: int, optional: The number of processes to use for computing the distance. Default is 1.
44
+ instance_normalization: bool, optional: Whether to normalize the instances along the time axis. Default is False.
45
+ return_distance: bool, optional: Whether to return the distance matrix. Default is False.
46
+ return_matching: bool, optional: Whether to return the matching matrix. Default is False.
47
+ return_each_features: bool, optional: Whether to return the results for each feature. Default is False.
48
+ return_coverages: bool, optional: Whether to return the coverages. Default is False.
49
+ return_all: bool, optional: Whether to return all the results. Default is False.
50
+ dtype: str, optional: The data type used for computation. Default is "float32".
51
+ eps: float, optional: The epsilon value to avoid division by zero. Default is 1e-8.
52
  Returns:
53
+ dict: A dictionary containing the following keys:
54
+ precision_distance (float): The precision of the distance.
55
+ recall_distance (float): The recall of the distance.
56
+ mean_distance (float): The mean of the distance.
57
+ index_distance (float): The index of the distance.
58
+ matching_precision (float): The precision of the matching instances.
59
+ matching_recall (float): The recall of the matching instances.
60
+ matching_f1 (float): The F1-score of the matching instances.
61
+ coverages (list of float): The coverages.
62
+ cuc (float): The coverage under the curve.
63
+ macro_.* (float): The macro value of the .*.
64
+ .*_features (list of float): The values computed individually for each feature.
65
+ distance (numpy.ndarray): The distance matrix.
66
+ match (numpy.ndarray): The matching matrix.
67
+ match_inv (numpy.ndarray): The inverse matching matrix.
68
  Examples:
69
  Examples should be written in doctest format, and should illustrate how
70
  to use the function.
71
 
72
+ >>> num_generation = 100
73
+ >>> num_reference = 10
74
+ >>> seq_len = 100
75
+ >>> num_features = 10
76
+ >>> references = np.random.rand(num_reference, seq_len, num_features)
77
+ >>> predictions = np.random.rand(num_generation, seq_len, num_features)
78
+ >>> metric = evaluate.load("bowdbeg/matching_series")
79
+ >>> results = metric.compute(references=references, predictions=predictions, batch_size=1000, return_all=True)
80
  >>> print(results)
81
+ {'precision_distance': 0.1573285013437271, 'recall_distance': 0.15106813609600067, 'mean_distance': 0.1541983187198639, 'index_distance': 0.16858606040477753, 'matching_precision': 0.06, 'matching_recall': 1.0, 'matching_f1': 0.11320756503381972, 'cuc': 0.12428571428571429, 'macro_precision_distance': 0.13803552389144896, 'macro_recall_distance': 0.12179495096206665, 'macro_mean_distance': 0.1299152374267578, 'macro_index_distance': 0.16858604848384856, 'macro_matching_precision': 0.094, 'macro_matching_recall': 0.97, 'macro_matching_f1': 0.17132608782381706, 'macro_cuc': 0.11419285714285714, 'distance': array([[[0.20763363, 0.16514072, 0.18695284, ..., 0.15037987,
82
+ 0.19424284, 0.15943716],
83
+ [0.17150438, 0.18020014, 0.17024504, ..., 0.18492931,
84
+ 0.18814348, 0.204207 ],
85
+ [0.1769202 , 0.15609328, 0.17568389, ..., 0.17731658,
86
+ 0.2027854 , 0.13216409],
87
+ ...,
88
+ [0.1838122 , 0.19475608, 0.14176111, ..., 0.1635111 ,
89
+ 0.1652672 , 0.17145865],
90
+ [0.16084194, 0.14208058, 0.17567575, ..., 0.15595785,
91
+ 0.16614595, 0.17834347],
92
+ [0.16388315, 0.14126392, 0.18021484, ..., 0.16791071,
93
+ 0.18403953, 0.16666758]],
94
+
95
+ [[0.16838932, 0.18878576, 0.17654441, ..., 0.1747057 ,
96
+ 0.16590554, 0.16901629],
97
+ [0.16553226, 0.1882645 , 0.17863466, ..., 0.19269662,
98
+ 0.20451452, 0.19941731],
99
+ [0.16502398, 0.16619626, 0.18069996, ..., 0.16124909,
100
+ 0.18933088, 0.1495165 ],
101
+ ...,
102
+ [0.15946846, 0.19988221, 0.17965002, ..., 0.12951666,
103
+ 0.2067793 , 0.13811146],
104
+ [0.16227122, 0.17736743, 0.18641905, ..., 0.15038314,
105
+ 0.20186146, 0.17849396],
106
+ [0.16410898, 0.18323919, 0.16945514, ..., 0.15783694,
107
+ 0.21556957, 0.17172968]],
108
+
109
+ [[0.18094379, 0.1364854 , 0.18436092, ..., 0.187335 ,
110
+ 0.16240291, 0.13713893],
111
+ [0.18005298, 0.15323727, 0.15788248, ..., 0.19451861,
112
+ 0.12822135, 0.14064161],
113
+ [0.1564556 , 0.17312287, 0.1856657 , ..., 0.17237219,
114
+ 0.1596888 , 0.16547912],
115
+ ...,
116
+ [0.15611127, 0.16121496, 0.15533476, ..., 0.16520709,
117
+ 0.1427248 , 0.19455005],
118
+ [0.17268528, 0.17360437, 0.15962966, ..., 0.18134868,
119
+ 0.15509704, 0.20222983],
120
+ [0.18704675, 0.15934442, 0.14928888, ..., 0.18904984,
121
+ 0.16192877, 0.18576236]],
122
+
123
+ ...,
124
+
125
+ [[0.13717972, 0.15645625, 0.16123378, ..., 0.19453087,
126
+ 0.14441733, 0.1487963 ],
127
+ [0.1454296 , 0.13368016, 0.18665504, ..., 0.16096605,
128
+ 0.15130125, 0.18332979],
129
+ [0.14654924, 0.19097947, 0.19629759, ..., 0.15887487,
130
+ 0.19266474, 0.17430782],
131
+ ...,
132
+ [0.161704 , 0.16357127, 0.18512094, ..., 0.16441964,
133
+ 0.13961458, 0.17298506],
134
+ [0.1366249 , 0.15852758, 0.1982772 , ..., 0.18822236,
135
+ 0.16153064, 0.19617072],
136
+ [0.14570995, 0.15005183, 0.19667573, ..., 0.1856473 ,
137
+ 0.18603194, 0.19179863]],
138
+
139
+ [[0.17813908, 0.176182 , 0.16847256, ..., 0.16903524,
140
+ 0.17150073, 0.15068175],
141
+ [0.17632519, 0.1404587 , 0.16388708, ..., 0.16873878,
142
+ 0.15744762, 0.198475 ],
143
+ [0.14986345, 0.1517829 , 0.17624639, ..., 0.18365957,
144
+ 0.17399347, 0.15581599],
145
+ ...,
146
+ [0.16128553, 0.1974935 , 0.13766351, ..., 0.14026196,
147
+ 0.15450196, 0.16110381],
148
+ [0.16281141, 0.14699166, 0.16935429, ..., 0.1394466 ,
149
+ 0.1717883 , 0.16191883],
150
+ [0.14886455, 0.1603608 , 0.15172943, ..., 0.12851712,
151
+ 0.19859877, 0.15576601]],
152
+
153
+ [[0.20230632, 0.19680001, 0.17143433, ..., 0.18601838,
154
+ 0.15998998, 0.16043548],
155
+ [0.19753966, 0.19073424, 0.15046756, ..., 0.18833323,
156
+ 0.16755773, 0.20127842],
157
+ [0.16012056, 0.16638812, 0.16493171, ..., 0.15849902,
158
+ 0.20269662, 0.1857642 ],
159
+ ...,
160
+ [0.16341361, 0.19168772, 0.16597596, ..., 0.15715535,
161
+ 0.18122095, 0.17266828],
162
+ [0.1570099 , 0.18294124, 0.16713732, ..., 0.17442709,
163
+ 0.17020254, 0.18804537],
164
+ [0.16752282, 0.1295177 , 0.18792175, ..., 0.13976808,
165
+ 0.21054329, 0.18118018]]], dtype=float32), 'match': array([4, 7, 3, 9, 4, 0, 7, 5, 4, 7, 9, 7, 7, 5, 7, 0, 0, 7, 4, 3, 3, 2,
166
+ 8, 9, 4, 4, 5, 1, 4, 9, 0, 2, 7, 3, 6, 5, 6, 3, 2, 2, 2, 6, 9, 4,
167
+ 4, 9, 1, 6, 0, 6, 9, 2, 0, 6, 7, 2, 0, 4, 5, 2, 3, 9, 2, 3, 9, 1,
168
+ 6, 4, 8, 9, 7, 4, 6, 5, 5, 6, 9, 5, 6, 2, 9, 4, 9, 3, 2, 9, 9, 7,
169
+ 9, 5, 9, 1, 7, 6, 4, 4, 5, 4, 7, 5]), 'match_inv': array([15, 91, 79, 4, 4, 4, 49, 4, 49, 45]), 'coverages': [0.10000000000000002, 0.16666666666666666, 0.3666666666666667, 0.6333333333333333, 0.8333333333333334, 0.9, 1.0], 'precision_distance_features': [0.1383965164422989, 0.13804036378860474, 0.1388234943151474, 0.1392393559217453, 0.1357768476009369, 0.1364508718252182, 0.14039862155914307, 0.13417008519172668, 0.1368638128042221, 0.14219526946544647], 'recall_distance_features': [0.11730053275823593, 0.12232911586761475, 0.12200610339641571, 0.12571024894714355, 0.12081331014633179, 0.11693283170461655, 0.12660981714725494, 0.12248671054840088, 0.11726576089859009, 0.12649507820606232], 'mean_distance_features': [0.1278485246002674, 0.13018473982810974, 0.13041479885578156, 0.13247480243444443, 0.12829507887363434, 0.12669185176491737, 0.133504219353199, 0.12832839787006378, 0.1270647868514061, 0.1343451738357544], 'index_distance_features': [0.17064405977725983, 0.17019756138324738, 0.17373089492321014, 0.17575454711914062, 0.15942324697971344, 0.1615942418575287, 0.16519878804683685, 0.1714271903038025, 0.17072594165802002, 0.16716401278972626], 'matching_precision_features': [0.1, 0.09, 0.1, 0.1, 0.09, 0.09, 0.1, 0.08, 0.09, 0.1], 'matching_recall_features': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.9, 0.9, 0.9, 1.0], 'matching_f1_features': [0.18181819851239656, 0.16513763164885095, 0.18181819851239656, 0.18181819851239656, 0.16513763164885095, 0.16513763164885095, 0.18000001639999985, 0.14693879251145342, 0.16363638033057834, 0.18181819851239656], 'cuc_features': [0.11935714285714286, 0.11578571428571431, 0.11814285714285715, 0.12407142857142857, 0.11207142857142856, 0.11821428571428572, 0.10807142857142855, 0.09635714285714285, 0.10700000000000001, 0.12285714285714286], 'coverages_features': [[0.10000000000000002, 0.20000000000000004, 0.26666666666666666, 0.4666666666666666, 0.7666666666666666, 0.8666666666666667, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3666666666666667, 0.5666666666666668, 0.6, 0.8333333333333334, 1.0], [0.10000000000000002, 0.16666666666666666, 0.26666666666666666, 0.4666666666666666, 0.6999999999999998, 0.8666666666666667, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.6, 0.7333333333333333, 0.9333333333333332, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.5, 0.6666666666666666, 0.7666666666666666, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3333333333333333, 0.5333333333333333, 0.7666666666666666, 0.8333333333333334, 1.0], [0.10000000000000002, 0.20000000000000004, 0.3, 0.5333333333333333, 0.6999999999999998, 0.7666666666666666, 0.9], [0.10000000000000002, 0.20000000000000004, 0.2333333333333333, 0.4666666666666666, 0.5333333333333333, 0.6333333333333333, 0.9], [0.10000000000000002, 0.16666666666666666, 0.26666666666666666, 0.4666666666666666, 0.5666666666666667, 0.8000000000000002, 0.9], [0.10000000000000002, 0.16666666666666666, 0.30000000000000004, 0.5666666666666667, 0.7999999999999999, 0.9, 1.0]]}
170
  """
171
 
172
 
 
248
  cuc_n_calculation: int = 3,
249
  cuc_n_samples: Union[List[int], str] = "auto",
250
  metric: str = "mse",
251
+ num_processes: int = 1,
252
+ instance_normalization: bool = False,
253
  return_distance: bool = False,
254
  return_matching: bool = False,
255
  return_each_features: bool = False,
256
  return_coverages: bool = False,
257
  return_all: bool = False,
258
  dtype=np.float32,
259
+ eps: float = 1e-8,
 
260
  ):
261
  """
262
  Compute the scores of the module given the predictions and references
 
298
  references=references,
299
  metric=metric,
300
  batch_size=batch_size,
301
+ num_processes=num_processes,
302
  dtype=dtype,
303
  )
304
 
 
394
  references: np.ndarray,
395
  metric: str,
396
  batch_size: Optional[int] = None,
397
+ num_processes: int = 1,
398
  dtype=np.float32,
399
  ):
400
  # distance between predictions and references for all example combinations for each features
401
  # shape: (num_generation, num_reference, num_features)
402
  if batch_size is not None:
403
+ if num_processes > 1:
404
  distance = np.zeros((len(predictions), len(references), predictions.shape[-1]), dtype=dtype)
405
  idxs = [
406
  (i, j)
 
411
  (predictions[i : i + batch_size, None], references[None, j : j + batch_size], metric, -2)
412
  for i, j in idxs
413
  ]
414
+ with concurrent.futures.ProcessPoolExecutor(max_workers=num_processes) as executor:
415
  results = executor.map(
416
  self._compute_distance,
417
  *zip(*args),
 
438
  def _compute_metrics(
439
  self,
440
  distance: np.ndarray,
441
+ eps: float = 1e-8,
442
  cuc_n_calculation: int = 3,
443
  cuc_n_samples: Union[List[int], str] = "auto",
444
  ) -> dict[str, float | list[float]]:
 
461
  best_match_inv = np.argmin(distance, axis=0)
462
  recall_distance = distance[best_match_inv, np.arange(len(best_match_inv))].mean().item()
463
 
 
464
  mean_distance = (precision_distance + recall_distance) / 2
465
 
466
  # matching precision, recall and f1
 
467
  matching_precision = np.unique(best_match_inv).size / len(best_match)
468
+ matching_recall = np.unique(best_match).size / len(best_match_inv)
469
  matching_f1 = 2 / (1 / (matching_precision + eps) + 1 / (matching_recall + eps))
470
 
471
  # cuc
472
  coverages, cuc = self.compute_cuc(best_match, len(best_match_inv), cuc_n_calculation, cuc_n_samples)
473
  return {
474
  "precision_distance": precision_distance,
 
475
  "recall_distance": recall_distance,
476
  "mean_distance": mean_distance,
477
  "index_distance": index_distance,