xlin 0.1.28__py2.py3-none-any.whl → 0.1.29__py2.py3-none-any.whl

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/statistic.py CHANGED
@@ -111,11 +111,53 @@ Kurtosis: {float((data - mean).mean()**4 / std**4):.4f}\
111
111
  plt.show()
112
112
 
113
113
 
114
- def draw_pie(numbers: List[int], title="Pie Chart of Numbers"):
114
+
115
+ def draw_preds_labels(preds: list[str], labels: list[str]):
116
+ from collections import Counter
115
117
  import matplotlib.pyplot as plt
116
118
 
117
- plt.pie(numbers, labels=[str(i) for i in range(len(numbers))], autopct='%1.1f%%')
118
- plt.title(title)
119
+ out_of_class = "out_of_class"
120
+ valid_values = list(set(labels)) + [out_of_class]
121
+ valid_preds = []
122
+ for pred in preds:
123
+ if pred not in valid_values:
124
+ valid_preds.append(out_of_class)
125
+ else:
126
+ valid_preds.append(pred)
127
+
128
+ counter = Counter(valid_preds)
129
+ pred_labels = list(counter.keys())
130
+ pred_values = list(counter.values())
131
+
132
+ # 绘制柱状图 pred
133
+ plt.figure(figsize=(12, 12))
134
+ plt.subplot(2, 2, 1)
135
+ plt.bar(pred_labels, pred_values)
136
+ plt.xlabel("class")
137
+ plt.ylabel("count")
138
+ plt.title("pred class distribution")
139
+
140
+ # 绘制饼图 pred
141
+ plt.subplot(2, 2, 2)
142
+ plt.pie(pred_values, labels=pred_labels, autopct="%1.1f%%")
143
+ plt.title("pred class distribution")
144
+
145
+ # 绘制柱状图 label
146
+ counter = Counter(labels)
147
+ label_labels = list(counter.keys())
148
+ label_values = list(counter.values())
149
+ plt.subplot(2, 2, 3)
150
+ plt.bar(label_labels, label_values)
151
+ plt.xlabel("class")
152
+ plt.ylabel("count")
153
+ plt.title("label class distribution")
154
+ # 绘制饼图 label
155
+ plt.subplot(2, 2, 4)
156
+ plt.pie(label_values, labels=label_labels, autopct="%1.1f%%")
157
+ plt.title("label class distribution")
158
+ plt.suptitle("Pred and Label Class Distribution")
159
+
160
+ plt.tight_layout()
119
161
  plt.show()
120
162
 
121
163
 
@@ -256,6 +298,7 @@ def print_classification_report(predictions: List[str], labels: List[str]):
256
298
  print("=== 分类报告 ===")
257
299
  print(report["class_report"])
258
300
  print()
301
+ return report
259
302
 
260
303
 
261
304
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xlin
3
- Version: 0.1.28
3
+ Version: 0.1.29
4
4
  Summary: toolbox for LinXueyuan
5
5
  License: MIT
6
6
  Author: LinXueyuanStdio
@@ -4,12 +4,12 @@ xlin/jsonl.py,sha256=IDRydHh2x-8iAGCxt9ScK2wfNLNA40PxNxR5hhr4v6k,7903
4
4
  xlin/metric.py,sha256=N7wJ35y-C-IaBr1I1CJ_37lTG7gA69zmn9Xg6xSwKoI,1690
5
5
  xlin/multiprocess_mapping.py,sha256=q4EVU8JPLcRAbNf9NUEzmn8rDLDfIQ3jaW0yxVKPECk,16669
6
6
  xlin/read_as_dataframe.py,sha256=MqY57L7Wp9UoWTRlZLSBKQNaZa-dKw51-ufrKvHKf8s,9041
7
- xlin/statistic.py,sha256=2DCUgzf7xkMFH4Pk9v82bFDNeSxCTjwPh9Y4IPJBHCE,9300
7
+ xlin/statistic.py,sha256=VS8tL0rwhs3tBR0hC4IU-7FVIlHuxImMrqJzut8JKNI,10525
8
8
  xlin/timing.py,sha256=XMT8dMcMolOMohDvAZOIM_BAiPMREhGQKnO1kc5s6PU,998
9
9
  xlin/util.py,sha256=TTWJaqF5D_r-gAZ_fj0kyHomvCagjwHXQZ2OPSgwd54,10976
10
10
  xlin/xls2xlsx.py,sha256=uSmXcDvIhi5Sq0LGidMXy0wErNBXdjaoa6EftYVjTXs,947
11
11
  xlin/yaml.py,sha256=kICi7G3Td5q2MaSXXt85qNTWoHMgjzt7pvn7r3C4dME,183
12
- xlin-0.1.28.dist-info/LICENSE,sha256=60ys6rRtc1dZOP8UjSUr9fAqhZudT3WpKe5WbMCralM,1066
13
- xlin-0.1.28.dist-info/METADATA,sha256=Ft8sYxlqCYTiuej-KTNXrKbFGhahW0LOSdng3XWH7Z0,1098
14
- xlin-0.1.28.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
15
- xlin-0.1.28.dist-info/RECORD,,
12
+ xlin-0.1.29.dist-info/LICENSE,sha256=60ys6rRtc1dZOP8UjSUr9fAqhZudT3WpKe5WbMCralM,1066
13
+ xlin-0.1.29.dist-info/METADATA,sha256=oGtT05fTogUwHLtNFuLkmV8oxd_wzLIJfC69f6Q4JYg,1098
14
+ xlin-0.1.29.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
15
+ xlin-0.1.29.dist-info/RECORD,,
File without changes
File without changes