xlin 0.1.30__tar.gz → 0.1.32__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xlin
3
- Version: 0.1.30
3
+ Version: 0.1.32
4
4
  Summary: toolbox for LinXueyuan
5
5
  License: MIT
6
6
  Author: LinXueyuanStdio
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "xlin"
3
- version = "0.1.30"
3
+ version = "0.1.32"
4
4
  description = "toolbox for LinXueyuan"
5
5
  authors = ["LinXueyuanStdio <23211526+LinXueyuanStdio@users.noreply.github.com>"]
6
6
  license = "MIT"
@@ -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=extend_classes, columns=extend_classes, data=0)
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 extend_classes:
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
- micro_tp += tp
220
- micro_fp += fp
221
- micro_fn += fn
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
@@ -238,7 +240,7 @@ def generate_classification_report(predictions: List[str], labels: List[str]) ->
238
240
  class_df = pd.DataFrame(class_stats)
239
241
  report["class_report"] = class_df
240
242
  confusion_matrix["recall"] = class_df["recall"].values.tolist()
241
- p = class_df["precision"].values.tolist() + [None]
243
+ p = class_df["precision"].values.tolist() + ["", ""] # [out_of_class, recall]
242
244
  tail = pd.DataFrame([p], index=["precision"], columns=confusion_matrix.columns)
243
245
  confusion_matrix = pd.concat([confusion_matrix, tail], axis=0)
244
246
  confusion_matrix.index.name = "True \\ Pred"
@@ -274,7 +276,10 @@ def convert_to_jsonable_report(report_row):
274
276
  elif isinstance(value, list):
275
277
  new_report_json[key] = [convert_to_jsonable_report(item) if isinstance(item, dict) else item for item in value]
276
278
  elif isinstance(value, pd.DataFrame):
277
- new_report_json[key] = value.fillna(-1).to_dict(orient="records")
279
+ if value.index.name is not None:
280
+ value = value.reset_index()
281
+ value = value.fillna(-1)
282
+ new_report_json[key] = value.to_dict(orient="records")
278
283
  else:
279
284
  new_report_json[key] = value
280
285
  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