xlin 0.1.33__tar.gz → 0.1.34__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.33
3
+ Version: 0.1.34
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.33"
3
+ version = "0.1.34"
4
4
  description = "toolbox for LinXueyuan"
5
5
  authors = ["LinXueyuanStdio <23211526+LinXueyuanStdio@users.noreply.github.com>"]
6
6
  license = "MIT"
@@ -1,4 +1,4 @@
1
- from typing import List
1
+ from typing import List, Optional
2
2
  from collections import defaultdict
3
3
 
4
4
  import pandas as pd
@@ -47,7 +47,7 @@ def statistic_token_length(df: pd.DataFrame, model_path: str, row_to_prompt: lam
47
47
  return lengths
48
48
 
49
49
 
50
- def draw_histogram(data: list[int], bins=30, title="Data Distribution Analysis"):
50
+ def draw_histogram(data: list[int], bins=30, title="Data Distribution Analysis", fig_save_path: Optional[str]=None):
51
51
  import numpy as np
52
52
  import matplotlib.pyplot as plt
53
53
  from scipy.stats import gaussian_kde
@@ -109,10 +109,11 @@ Kurtosis: {float((data - mean).mean()**4 / std**4):.4f}\
109
109
  # 显示图形
110
110
  plt.tight_layout()
111
111
  plt.show()
112
+ if fig_save_path is not None:
113
+ plt.savefig(fig_save_path, dpi=300)
112
114
 
113
115
 
114
-
115
- def draw_preds_labels(preds: list[str], labels: list[str]):
116
+ def draw_preds_labels(preds: list[str], labels: list[str], title="Pred and Label Class Distribution", fig_save_path: Optional[str]=None):
116
117
  from collections import Counter
117
118
  import matplotlib.pyplot as plt
118
119
 
@@ -155,10 +156,12 @@ def draw_preds_labels(preds: list[str], labels: list[str]):
155
156
  plt.subplot(2, 2, 4)
156
157
  plt.pie(label_values, labels=label_labels, autopct="%1.1f%%")
157
158
  plt.title("label class distribution")
158
- plt.suptitle("Pred and Label Class Distribution")
159
+ plt.suptitle(title)
159
160
 
160
161
  plt.tight_layout()
161
162
  plt.show()
163
+ if fig_save_path is not None:
164
+ plt.savefig(fig_save_path, dpi=300)
162
165
 
163
166
 
164
167
  def generate_classification_report(predictions: List[str], labels: List[str]) -> dict:
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