action policy split
Browse files- utils/policyaction_classifier.py +15 -10
utils/policyaction_classifier.py
CHANGED
@@ -82,20 +82,25 @@ def policyaction_classification(haystack_doc:pd.DataFrame,
|
|
82 |
list_.append(placeholder)
|
83 |
labels_ = [{**list_[l]} for l in range(len(predictions))]
|
84 |
truth_df = DataFrame.from_dict(labels_)
|
85 |
-
st.write(truth_df)
|
86 |
truth_df = truth_df.round(2)
|
|
|
87 |
truth_df = truth_df.astype(float) >= threshold
|
88 |
truth_df = truth_df.astype(str)
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
haystack_doc['Policy-Action Label'] = list(truth_df['Policy-Action Label'])
|
97 |
-
haystack_doc['Policy-Action Label'] = haystack_doc['Policy-Action Label'].apply(
|
98 |
-
|
99 |
# st.dataframe(haystack_doc)
|
100 |
|
101 |
return haystack_doc
|
|
|
82 |
list_.append(placeholder)
|
83 |
labels_ = [{**list_[l]} for l in range(len(predictions))]
|
84 |
truth_df = DataFrame.from_dict(labels_)
|
|
|
85 |
truth_df = truth_df.round(2)
|
86 |
+
temp = truth_df.copy()
|
87 |
truth_df = truth_df.astype(float) >= threshold
|
88 |
truth_df = truth_df.astype(str)
|
89 |
+
truth_df.rename(columns = {'Action':'Action Label','Policies_Plans':'Policies_Plans Label'},
|
90 |
+
inplace =True)
|
91 |
+
temp.rename(columns = {'Action':'Action Score','Policies_Plans':'Policies_Plans Score'},
|
92 |
+
inplace=True)
|
93 |
+
# categories = list(truth_df.columns)
|
94 |
+
# truth_df['Policy-Action Label'] = truth_df.apply(lambda x: {i if x[i]=='True'
|
95 |
+
# else None for i in categories}, axis=1)
|
96 |
+
st.dataframe(truth_df)
|
97 |
+
st.dataframe(temp)
|
98 |
+
# truth_df['Policy-Action Label'] = truth_df.apply(lambda x:
|
99 |
+
# list(x['Policy-Action Label'] -{None}),axis=1)
|
100 |
|
101 |
+
# haystack_doc['Policy-Action Label'] = list(truth_df['Policy-Action Label'])
|
102 |
+
# haystack_doc['Policy-Action Label'] = haystack_doc['Policy-Action Label'].apply(
|
103 |
+
# lambda x:x if x else ['NA'])
|
104 |
# st.dataframe(haystack_doc)
|
105 |
|
106 |
return haystack_doc
|