xlin 0.1.30__tar.gz → 0.1.31__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.
- {xlin-0.1.30 → xlin-0.1.31}/PKG-INFO +1 -1
- {xlin-0.1.30 → xlin-0.1.31}/pyproject.toml +1 -1
- {xlin-0.1.30 → xlin-0.1.31}/xlin/statistic.py +14 -7
- {xlin-0.1.30 → xlin-0.1.31}/LICENSE +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/README.md +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/__init__.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/ischinese.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/jsonl.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/metric.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/multiprocess_mapping.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/read_as_dataframe.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/timing.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/util.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/xls2xlsx.py +0 -0
- {xlin-0.1.30 → xlin-0.1.31}/xlin/yaml.py +0 -0
@@ -203,7 +203,7 @@ def generate_classification_report(predictions: List[str], labels: List[str]) ->
|
|
203
203
|
pred_label = error_label
|
204
204
|
confusion[(true_label, pred_label)] += 1
|
205
205
|
|
206
|
-
confusion_matrix = pd.DataFrame(index=
|
206
|
+
confusion_matrix = pd.DataFrame(index=classes, columns=extend_classes, data=0)
|
207
207
|
for (true, pred), count in confusion.items():
|
208
208
|
confusion_matrix.loc[true, pred] = count
|
209
209
|
|
@@ -212,13 +212,15 @@ def generate_classification_report(predictions: List[str], labels: List[str]) ->
|
|
212
212
|
micro_fp = 0
|
213
213
|
micro_fn = 0
|
214
214
|
class_stats = []
|
215
|
-
for cls in
|
215
|
+
for cls in classes:
|
216
216
|
tp = confusion[(cls, cls)]
|
217
217
|
fp = sum(confusion[(other, cls)] for other in extend_classes if other != cls)
|
218
218
|
fn = sum(confusion[(cls, other)] for other in extend_classes if other != cls)
|
219
|
-
|
220
|
-
|
221
|
-
|
219
|
+
|
220
|
+
if cls != error_label:
|
221
|
+
micro_tp += tp
|
222
|
+
micro_fp += fp
|
223
|
+
micro_fn += fn
|
222
224
|
|
223
225
|
precision = tp / (tp + fp) if (tp + fp) > 0 else 0
|
224
226
|
recall = tp / (tp + fn) if (tp + fn) > 0 else 0
|
@@ -237,8 +239,10 @@ def generate_classification_report(predictions: List[str], labels: List[str]) ->
|
|
237
239
|
# 添加汇总统计
|
238
240
|
class_df = pd.DataFrame(class_stats)
|
239
241
|
report["class_report"] = class_df
|
242
|
+
print(class_df)
|
243
|
+
print(confusion_matrix)
|
240
244
|
confusion_matrix["recall"] = class_df["recall"].values.tolist()
|
241
|
-
p = class_df["precision"].values.tolist() + [
|
245
|
+
p = class_df["precision"].values.tolist() + ["", ""] # [out_of_class, recall]
|
242
246
|
tail = pd.DataFrame([p], index=["precision"], columns=confusion_matrix.columns)
|
243
247
|
confusion_matrix = pd.concat([confusion_matrix, tail], axis=0)
|
244
248
|
confusion_matrix.index.name = "True \\ Pred"
|
@@ -274,7 +278,10 @@ def convert_to_jsonable_report(report_row):
|
|
274
278
|
elif isinstance(value, list):
|
275
279
|
new_report_json[key] = [convert_to_jsonable_report(item) if isinstance(item, dict) else item for item in value]
|
276
280
|
elif isinstance(value, pd.DataFrame):
|
277
|
-
|
281
|
+
if value.index.name is not None:
|
282
|
+
value = value.reset_index()
|
283
|
+
value = value.fillna(-1)
|
284
|
+
new_report_json[key] = value.to_dict(orient="records")
|
278
285
|
else:
|
279
286
|
new_report_json[key] = value
|
280
287
|
return new_report_json
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|