SURE-tools 2.1.7__py3-none-any.whl → 2.1.8__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.
Potentially problematic release.
This version of SURE-tools might be problematic. Click here for more details.
- SURE/perturb/__init__.py +1 -1
- SURE/perturb/perturb.py +19 -2
- {sure_tools-2.1.7.dist-info → sure_tools-2.1.8.dist-info}/METADATA +1 -1
- {sure_tools-2.1.7.dist-info → sure_tools-2.1.8.dist-info}/RECORD +8 -8
- {sure_tools-2.1.7.dist-info → sure_tools-2.1.8.dist-info}/WHEEL +0 -0
- {sure_tools-2.1.7.dist-info → sure_tools-2.1.8.dist-info}/entry_points.txt +0 -0
- {sure_tools-2.1.7.dist-info → sure_tools-2.1.8.dist-info}/licenses/LICENSE +0 -0
- {sure_tools-2.1.7.dist-info → sure_tools-2.1.8.dist-info}/top_level.txt +0 -0
SURE/perturb/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
from .perturb import
|
|
1
|
+
from .perturb import LabelMatrix
|
SURE/perturb/perturb.py
CHANGED
|
@@ -2,7 +2,24 @@ import re
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
from itertools import chain
|
|
4
4
|
from joblib import Parallel, delayed
|
|
5
|
+
from typing import Literal
|
|
5
6
|
|
|
7
|
+
class LabelMatrix:
|
|
8
|
+
def __init__(self):
|
|
9
|
+
self.labels_ = None
|
|
10
|
+
|
|
11
|
+
def fit_transform(self, labels, sep_pattern=r'[;_\-\s]', speedup: Literal['none','vectorize','parallel']='none'):
|
|
12
|
+
if speedup=='none':
|
|
13
|
+
mat, self.labels_ = label_to_matrix(labels=labels, sep_pattern=sep_pattern)
|
|
14
|
+
elif speedup=='vectorize':
|
|
15
|
+
mat, self.labels_ = vectorized_label_to_matrix(labels=labels, sep_pattern=sep_pattern)
|
|
16
|
+
elif speedup=='parallel':
|
|
17
|
+
mat, self.labels_ = parallel_label_to_matrix(labels=labels, sep_pattern=sep_pattern)
|
|
18
|
+
return mat
|
|
19
|
+
|
|
20
|
+
def inverse_transform(self, matrix):
|
|
21
|
+
matrix_to_labels(matrix=matrix, unique_labels=self.labels_)
|
|
22
|
+
|
|
6
23
|
def label_to_matrix(labels, sep_pattern=r'[;_\-\s]'):
|
|
7
24
|
"""
|
|
8
25
|
将混合分隔符的多标签数据转换为 0-1 矩阵
|
|
@@ -48,8 +65,8 @@ def vectorized_label_to_matrix(labels, sep_pattern=r'[;_\-\s]'):
|
|
|
48
65
|
|
|
49
66
|
|
|
50
67
|
|
|
51
|
-
def parallel_label_to_matrix(labels, n_jobs=4):
|
|
52
|
-
labels_unified = [re.sub(
|
|
68
|
+
def parallel_label_to_matrix(labels, sep_pattern=r'[;_\-\s]', n_jobs=4):
|
|
69
|
+
labels_unified = [re.sub(sep_pattern, ';', label) for label in labels]
|
|
53
70
|
unique_labels = sorted(set(chain(*[label.split(';') for label in labels_unified])))
|
|
54
71
|
|
|
55
72
|
def process_row(row_labels, unique_labels):
|
|
@@ -13,15 +13,15 @@ SURE/flow/__init__.py,sha256=eIcHeeISEOXEB0zRW-uiRlDz5IEUbA7rZZ1htUxhLVU,167
|
|
|
13
13
|
SURE/flow/flow_stats.py,sha256=wpIxmOpYPU7YcgxqXKS8EDmnZ3oGh-YdBjiBiEmHcoU,2360
|
|
14
14
|
SURE/flow/plot_quiver.py,sha256=spcPC0BDpvC-FBk9XIu6rcJI64bS-U-IVmmKLYHHXgs,1865
|
|
15
15
|
SURE/flow/quiver.py,sha256=_euFqSaRrDoZ_oOabOx20LOoUTJ__XPhLW-vzLNQfAo,1859
|
|
16
|
-
SURE/perturb/__init__.py,sha256=
|
|
17
|
-
SURE/perturb/perturb.py,sha256=
|
|
16
|
+
SURE/perturb/__init__.py,sha256=ouxShhbxZM4r5Gf7GmKiutrsmtyq7QL8rHjhgF0BU08,32
|
|
17
|
+
SURE/perturb/perturb.py,sha256=LhrQSZEka7GFc9x4YfMhzHEYE-oHWwDg5tlhIRXVtGg,3237
|
|
18
18
|
SURE/utils/__init__.py,sha256=Htqv4KqVKcRiaaTBsR-6yZ4LSlbhbzutjNKXGD9-uds,660
|
|
19
19
|
SURE/utils/custom_mlp.py,sha256=07TYX1HgxfEjb_3i5MpiZfNhOhx3dKntuwGkrpteWiM,7036
|
|
20
20
|
SURE/utils/queue.py,sha256=E_5PA5EWcBoGAZj8BkKQnkCK0p4C-4-xcTPqdIXaPXU,1892
|
|
21
21
|
SURE/utils/utils.py,sha256=IUHjDDtYaAYllCWsZyIzqQwaLul6fJRvHRH4vIYcR-c,8462
|
|
22
|
-
sure_tools-2.1.
|
|
23
|
-
sure_tools-2.1.
|
|
24
|
-
sure_tools-2.1.
|
|
25
|
-
sure_tools-2.1.
|
|
26
|
-
sure_tools-2.1.
|
|
27
|
-
sure_tools-2.1.
|
|
22
|
+
sure_tools-2.1.8.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
|
|
23
|
+
sure_tools-2.1.8.dist-info/METADATA,sha256=DJqLBtteAneDszgl4HiVf-Fucqzn9thAXoXzPq6b6_Y,2650
|
|
24
|
+
sure_tools-2.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
sure_tools-2.1.8.dist-info/entry_points.txt,sha256=-nJI8rVe_qqrR0HmfAODzj-JNfEqCcSsyVh6okSqyHk,83
|
|
26
|
+
sure_tools-2.1.8.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
|
|
27
|
+
sure_tools-2.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|