valor-lite 0.33.11__tar.gz → 0.33.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of valor-lite might be problematic. Click here for more details.

Files changed (79) hide show
  1. {valor_lite-0.33.11/valor_lite.egg-info → valor_lite-0.33.12}/PKG-INFO +1 -1
  2. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_accuracy.py +7 -90
  3. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/classification/computation.py +2 -2
  4. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/classification/manager.py +8 -6
  5. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/classification/metric.py +29 -17
  6. {valor_lite-0.33.11 → valor_lite-0.33.12/valor_lite.egg-info}/PKG-INFO +1 -1
  7. {valor_lite-0.33.11 → valor_lite-0.33.12}/LICENSE +0 -0
  8. {valor_lite-0.33.11 → valor_lite-0.33.12}/README.md +0 -0
  9. {valor_lite-0.33.11 → valor_lite-0.33.12}/benchmarks/.gitignore +0 -0
  10. {valor_lite-0.33.11 → valor_lite-0.33.12}/benchmarks/benchmark_classification.py +0 -0
  11. {valor_lite-0.33.11 → valor_lite-0.33.12}/benchmarks/benchmark_objdet.py +0 -0
  12. {valor_lite-0.33.11 → valor_lite-0.33.12}/examples/.gitignore +0 -0
  13. {valor_lite-0.33.11 → valor_lite-0.33.12}/examples/object-detection.ipynb +0 -0
  14. {valor_lite-0.33.11 → valor_lite-0.33.12}/examples/tabular_classification.ipynb +0 -0
  15. {valor_lite-0.33.11 → valor_lite-0.33.12}/pyproject.toml +0 -0
  16. {valor_lite-0.33.11 → valor_lite-0.33.12}/setup.cfg +0 -0
  17. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/__init__.py +0 -0
  18. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/__init__.py +0 -0
  19. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/conftest.py +0 -0
  20. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_confusion_matrix.py +0 -0
  21. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_counts.py +0 -0
  22. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_dataloader.py +0 -0
  23. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_evaluator.py +0 -0
  24. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_f1.py +0 -0
  25. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_filtering.py +0 -0
  26. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_precision.py +0 -0
  27. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_recall.py +0 -0
  28. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_rocauc.py +0 -0
  29. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_schemas.py +0 -0
  30. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/classification/test_stability.py +0 -0
  31. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/__init__.py +0 -0
  32. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/conftest.py +0 -0
  33. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_average_precision.py +0 -0
  34. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_average_recall.py +0 -0
  35. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_confusion_matrix.py +0 -0
  36. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_counts.py +0 -0
  37. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_dataloader.py +0 -0
  38. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_evaluator.py +0 -0
  39. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_filtering.py +0 -0
  40. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_iou.py +0 -0
  41. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_pr_curve.py +0 -0
  42. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_precision.py +0 -0
  43. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_recall.py +0 -0
  44. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_schemas.py +0 -0
  45. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/object_detection/test_stability.py +0 -0
  46. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/__init__.py +0 -0
  47. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/conftest.py +0 -0
  48. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_accuracy.py +0 -0
  49. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_annotation.py +0 -0
  50. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_confusion_matrix.py +0 -0
  51. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_dataloader.py +0 -0
  52. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_evaluator.py +0 -0
  53. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_f1.py +0 -0
  54. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_filtering.py +0 -0
  55. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_iou.py +0 -0
  56. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_precision.py +0 -0
  57. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_recall.py +0 -0
  58. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/semantic_segmentation/test_stability.py +0 -0
  59. {valor_lite-0.33.11 → valor_lite-0.33.12}/tests/text_generation/__init__.py +0 -0
  60. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/LICENSE +0 -0
  61. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/__init__.py +0 -0
  62. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/classification/__init__.py +0 -0
  63. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/classification/annotation.py +0 -0
  64. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/object_detection/__init__.py +0 -0
  65. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/object_detection/annotation.py +0 -0
  66. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/object_detection/computation.py +0 -0
  67. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/object_detection/manager.py +0 -0
  68. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/object_detection/metric.py +0 -0
  69. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/schemas.py +0 -0
  70. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/semantic_segmentation/__init__.py +0 -0
  71. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/semantic_segmentation/annotation.py +0 -0
  72. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/semantic_segmentation/computation.py +0 -0
  73. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/semantic_segmentation/manager.py +0 -0
  74. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/semantic_segmentation/metric.py +0 -0
  75. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite/text_generation/__init__.py +0 -0
  76. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite.egg-info/SOURCES.txt +0 -0
  77. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite.egg-info/dependency_links.txt +0 -0
  78. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite.egg-info/requires.txt +0 -0
  79. {valor_lite-0.33.11 → valor_lite-0.33.12}/valor_lite.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: valor-lite
3
- Version: 0.33.11
3
+ Version: 0.33.12
4
4
  Summary: Compute valor metrics locally.
5
5
  License: MIT License
6
6
 
@@ -53,18 +53,12 @@ def test_accuracy_computation():
53
53
  )
54
54
 
55
55
  # score threshold, label, count metric
56
- assert accuracy.shape == (2, 4)
56
+ assert accuracy.shape == (2,)
57
57
 
58
58
  # score >= 0.25
59
- assert accuracy[0][0] == 2 / 3
60
- assert accuracy[0][1] == 1.0
61
- assert accuracy[0][2] == 2 / 3
62
- assert accuracy[0][3] == 1.0
59
+ assert accuracy[0] == 2 / 3
63
60
  # score >= 0.75
64
- assert accuracy[1][0] == 2 / 3
65
- assert accuracy[1][1] == 1.0
66
- assert accuracy[1][2] == 2 / 3
67
- assert accuracy[1][3] == 2 / 3
61
+ assert accuracy[1] == 1 / 3
68
62
 
69
63
 
70
64
  def test_accuracy_basic(basic_classifications: list[Classification]):
@@ -87,20 +81,10 @@ def test_accuracy_basic(basic_classifications: list[Classification]):
87
81
  expected_metrics = [
88
82
  {
89
83
  "type": "Accuracy",
90
- "value": [2 / 3, 2 / 3],
84
+ "value": [2 / 3, 1 / 3],
91
85
  "parameters": {
92
86
  "score_thresholds": [0.25, 0.75],
93
87
  "hardmax": True,
94
- "label": "0",
95
- },
96
- },
97
- {
98
- "type": "Accuracy",
99
- "value": [1.0, 2 / 3],
100
- "parameters": {
101
- "score_thresholds": [0.25, 0.75],
102
- "hardmax": True,
103
- "label": "3",
104
88
  },
105
89
  },
106
90
  ]
@@ -124,29 +108,10 @@ def test_accuracy_with_animal_example(
124
108
  expected_metrics = [
125
109
  {
126
110
  "type": "Accuracy",
127
- "value": [2.0 / 3.0],
128
- "parameters": {
129
- "score_thresholds": [0.5],
130
- "hardmax": True,
131
- "label": "bird",
132
- },
133
- },
134
- {
135
- "type": "Accuracy",
136
- "value": [0.5],
111
+ "value": [2.0 / 6.0],
137
112
  "parameters": {
138
113
  "score_thresholds": [0.5],
139
114
  "hardmax": True,
140
- "label": "dog",
141
- },
142
- },
143
- {
144
- "type": "Accuracy",
145
- "value": [2 / 3],
146
- "parameters": {
147
- "score_thresholds": [0.5],
148
- "hardmax": True,
149
- "label": "cat",
150
115
  },
151
116
  },
152
117
  ]
@@ -170,38 +135,10 @@ def test_accuracy_color_example(
170
135
  expected_metrics = [
171
136
  {
172
137
  "type": "Accuracy",
173
- "value": [2 / 3],
174
- "parameters": {
175
- "score_thresholds": [0.5],
176
- "hardmax": True,
177
- "label": "white",
178
- },
179
- },
180
- {
181
- "type": "Accuracy",
182
- "value": [2 / 3],
138
+ "value": [2 / 6],
183
139
  "parameters": {
184
140
  "score_thresholds": [0.5],
185
141
  "hardmax": True,
186
- "label": "red",
187
- },
188
- },
189
- {
190
- "type": "Accuracy",
191
- "value": [2 / 3],
192
- "parameters": {
193
- "score_thresholds": [0.5],
194
- "hardmax": True,
195
- "label": "blue",
196
- },
197
- },
198
- {
199
- "type": "Accuracy",
200
- "value": [5 / 6],
201
- "parameters": {
202
- "score_thresholds": [0.5],
203
- "hardmax": True,
204
- "label": "black",
205
142
  },
206
143
  },
207
144
  ]
@@ -237,7 +174,6 @@ def test_accuracy_with_image_example(
237
174
  "parameters": {
238
175
  "score_thresholds": [0.0],
239
176
  "hardmax": True,
240
- "label": "v4",
241
177
  },
242
178
  },
243
179
  ]
@@ -269,29 +205,10 @@ def test_accuracy_with_tabular_example(
269
205
  expected_metrics = [
270
206
  {
271
207
  "type": "Accuracy",
272
- "value": [0.7],
273
- "parameters": {
274
- "score_thresholds": [0.0],
275
- "hardmax": True,
276
- "label": "0",
277
- },
278
- },
279
- {
280
- "type": "Accuracy",
281
- "value": [0.5],
282
- "parameters": {
283
- "score_thresholds": [0.0],
284
- "hardmax": True,
285
- "label": "1",
286
- },
287
- },
288
- {
289
- "type": "Accuracy",
290
- "value": [0.8],
208
+ "value": [5 / 10],
291
209
  "parameters": {
292
210
  "score_thresholds": [0.0],
293
211
  "hardmax": True,
294
- "label": "2",
295
212
  },
296
213
  },
297
214
  ]
@@ -182,9 +182,9 @@ def compute_metrics(
182
182
  out=precision,
183
183
  )
184
184
 
185
- accuracy = np.zeros_like(recall)
185
+ accuracy = np.zeros(n_scores, dtype=np.float64)
186
186
  np.divide(
187
- (counts[:, :, 0] + counts[:, :, 3]),
187
+ counts[:, :, 0].sum(axis=1),
188
188
  float(n_datums),
189
189
  out=accuracy,
190
190
  )
@@ -367,6 +367,14 @@ class Evaluator:
367
367
  )
368
368
  ]
369
369
 
370
+ metrics[MetricType.Accuracy] = [
371
+ Accuracy(
372
+ value=accuracy.astype(float).tolist(),
373
+ score_thresholds=score_thresholds,
374
+ hardmax=hardmax,
375
+ )
376
+ ]
377
+
370
378
  for label_idx, label in self.index_to_label.items():
371
379
 
372
380
  kwargs = {
@@ -401,12 +409,6 @@ class Evaluator:
401
409
  **kwargs,
402
410
  )
403
411
  )
404
- metrics[MetricType.Accuracy].append(
405
- Accuracy(
406
- value=accuracy[:, label_idx].astype(float).tolist(),
407
- **kwargs,
408
- )
409
- )
410
412
  metrics[MetricType.F1].append(
411
413
  F1(
412
414
  value=f1_score[:, label_idx].astype(float).tolist(),
@@ -158,24 +158,23 @@ class Recall(_ThresholdValue):
158
158
  pass
159
159
 
160
160
 
161
- class Accuracy(_ThresholdValue):
161
+ class F1(_ThresholdValue):
162
162
  """
163
- Accuracy metric for a specific class label.
163
+ F1 score for a specific class label.
164
164
 
165
- This class calculates the accuracy at various score thresholds for a binary
166
- classification task. Accuracy is defined as the ratio of the sum of true positives and
167
- true negatives over all predictions.
165
+ This class calculates the F1 score at various score thresholds for a binary
166
+ classification task.
168
167
 
169
168
  Attributes
170
169
  ----------
171
170
  value : list[float]
172
- Accuracy values computed at each score threshold.
171
+ F1 scores computed at each score threshold.
173
172
  score_thresholds : list[float]
174
- Score thresholds at which the accuracy values are computed.
173
+ Score thresholds at which the F1 scores are computed.
175
174
  hardmax : bool
176
175
  Indicates whether hardmax thresholding was used.
177
176
  label : str
178
- The class label for which the accuracy is computed.
177
+ The class label for which the F1 score is computed.
179
178
 
180
179
  Methods
181
180
  -------
@@ -188,23 +187,21 @@ class Accuracy(_ThresholdValue):
188
187
  pass
189
188
 
190
189
 
191
- class F1(_ThresholdValue):
190
+ @dataclass
191
+ class Accuracy:
192
192
  """
193
- F1 score for a specific class label.
193
+ Multiclass accuracy metric.
194
194
 
195
- This class calculates the F1 score at various score thresholds for a binary
196
- classification task.
195
+ This class calculates the accuracy at various score thresholds.
197
196
 
198
197
  Attributes
199
198
  ----------
200
199
  value : list[float]
201
- F1 scores computed at each score threshold.
200
+ Accuracy values computed at each score threshold.
202
201
  score_thresholds : list[float]
203
- Score thresholds at which the F1 scores are computed.
202
+ Score thresholds at which the accuracy values are computed.
204
203
  hardmax : bool
205
204
  Indicates whether hardmax thresholding was used.
206
- label : str
207
- The class label for which the F1 score is computed.
208
205
 
209
206
  Methods
210
207
  -------
@@ -214,7 +211,22 @@ class F1(_ThresholdValue):
214
211
  Converts the instance to a dictionary representation.
215
212
  """
216
213
 
217
- pass
214
+ value: list[float]
215
+ score_thresholds: list[float]
216
+ hardmax: bool
217
+
218
+ def to_metric(self) -> Metric:
219
+ return Metric(
220
+ type=type(self).__name__,
221
+ value=self.value,
222
+ parameters={
223
+ "score_thresholds": self.score_thresholds,
224
+ "hardmax": self.hardmax,
225
+ },
226
+ )
227
+
228
+ def to_dict(self) -> dict:
229
+ return self.to_metric().to_dict()
218
230
 
219
231
 
220
232
  @dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: valor-lite
3
- Version: 0.33.11
3
+ Version: 0.33.12
4
4
  Summary: Compute valor metrics locally.
5
5
  License: MIT License
6
6
 
File without changes
File without changes
File without changes