Update utils/vulnerability_classifier.py
Browse files
utils/vulnerability_classifier.py
CHANGED
@@ -84,24 +84,26 @@ def vulnerability_classification(haystack_doc:pd.DataFrame,
|
|
84 |
classifier_model = st.session_state['vulnerability_classifier']
|
85 |
|
86 |
predictions = classifier_model(list(haystack_doc.text))
|
87 |
-
|
88 |
-
list_ = []
|
89 |
-
for i in range(len(predictions)):
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
truth_df
|
103 |
-
|
104 |
-
truth_df
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
107 |
return haystack_doc
|
|
|
84 |
classifier_model = st.session_state['vulnerability_classifier']
|
85 |
|
86 |
predictions = classifier_model(list(haystack_doc.text))
|
|
|
|
|
|
|
87 |
|
88 |
+
haystack_doc['Vulnerability Label'] = predictions
|
89 |
+
|
90 |
+
# list_ = []
|
91 |
+
# for i in range(len(predictions)):
|
92 |
+
|
93 |
+
# temp = predictions[i]
|
94 |
+
# placeholder = {}
|
95 |
+
# for j in range(len(temp)):
|
96 |
+
# placeholder[temp[j]['label']] = temp[j]['score']
|
97 |
+
# list_.append(placeholder)
|
98 |
+
# labels_ = [{**list_[l]} for l in range(len(predictions))]
|
99 |
+
# truth_df = DataFrame.from_dict(labels_)
|
100 |
+
# truth_df = truth_df.round(2)
|
101 |
+
# truth_df = truth_df.astype(float) >= threshold
|
102 |
+
# truth_df = truth_df.astype(str)
|
103 |
+
# categories = list(truth_df.columns)
|
104 |
+
# truth_df['Vulnerability Label'] = truth_df.apply(lambda x: {i if x[i]=='True' else
|
105 |
+
# None for i in categories}, axis=1)
|
106 |
+
# truth_df['Vulnerability Label'] = truth_df.apply(lambda x: list(x['Vulnerability Label']
|
107 |
+
# -{None}),axis=1)
|
108 |
+
# haystack_doc['Vulnerability Label'] = list(truth_df['Vulnerability Label'])
|
109 |
return haystack_doc
|