Spaces:
Sleeping
Sleeping
ZeroCommand
commited on
Commit
·
b5a969d
1
Parent(s):
df23b1a
GSK-2396 allow edit feature mapping and scan config
Browse files- scan_config.yaml +8 -0
- text_classification.py +1 -1
- utils.py +24 -0
scan_config.yaml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
detectors:
|
2 |
+
- ethical_bias
|
3 |
+
- text_perturbation
|
4 |
+
- robustness
|
5 |
+
- performance
|
6 |
+
- underconfidence
|
7 |
+
- overconfidence
|
8 |
+
- spurious_correlation
|
text_classification.py
CHANGED
@@ -50,7 +50,7 @@ def text_classification_map_model_and_dataset_labels(id2label, dataset_features)
|
|
50 |
continue
|
51 |
if len(feature.names) != len(id2label_mapping.keys()):
|
52 |
continue
|
53 |
-
|
54 |
dataset_labels = feature.names
|
55 |
# Try to match labels
|
56 |
for label in feature.names:
|
|
|
50 |
continue
|
51 |
if len(feature.names) != len(id2label_mapping.keys()):
|
52 |
continue
|
53 |
+
|
54 |
dataset_labels = feature.names
|
55 |
# Try to match labels
|
56 |
for label in feature.names:
|
utils.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import yaml
|
2 |
+
import sys
|
3 |
+
# read scanners from yaml file
|
4 |
+
# return a list of scanners
|
5 |
+
def read_scanners(path):
|
6 |
+
scanners = []
|
7 |
+
with open(path, "r") as f:
|
8 |
+
config = yaml.load(f, Loader=yaml.FullLoader)
|
9 |
+
scanners = config.get("detectors", None)
|
10 |
+
return scanners
|
11 |
+
|
12 |
+
# convert a list of scanners to yaml file
|
13 |
+
def write_scanners(scanners):
|
14 |
+
with open("./scan_config.yaml", "w") as f:
|
15 |
+
# save scanners to detectors in yaml
|
16 |
+
yaml.dump({"detectors": scanners}, f)
|
17 |
+
|
18 |
+
# convert column mapping dataframe to json
|
19 |
+
def convert_column_mapping_to_json(df, label=""):
|
20 |
+
column_mapping = {}
|
21 |
+
column_mapping[label] = []
|
22 |
+
for _, row in df.iterrows():
|
23 |
+
column_mapping[label].append(row.tolist())
|
24 |
+
return column_mapping
|