add adaptation mitigation
Browse files- appStore/target.py +1 -1
- utils/adapmit_classifier.py +15 -2
appStore/target.py
CHANGED
@@ -257,7 +257,7 @@ def filter_dataframe(df: pd.DataFrame) -> pd.DataFrame:
|
|
257 |
df = df[df[column].str.contains(user_text_input)]
|
258 |
df['keep'] = True
|
259 |
df = df[['keep','text','Target Score','Netzero Label','GHG Label',
|
260 |
-
'Conditional Label','Sector Label']]
|
261 |
df = st.data_editor(
|
262 |
df,
|
263 |
column_config={
|
|
|
257 |
df = df[df[column].str.contains(user_text_input)]
|
258 |
df['keep'] = True
|
259 |
df = df[['keep','text','Target Score','Netzero Label','GHG Label',
|
260 |
+
'Conditional Label','Sector Label','Adapt-Mitig Label','page']]
|
261 |
df = st.data_editor(
|
262 |
df,
|
263 |
column_config={
|
utils/adapmit_classifier.py
CHANGED
@@ -63,11 +63,20 @@ def adapmit_classification(haystack_doc:pd.DataFrame,
|
|
63 |
"""
|
64 |
logging.info("Working on Adaptation-Mitigation Identification")
|
65 |
haystack_doc['Adapt-Mitig Label'] = 'NA'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
if not classifier_model:
|
68 |
classifier_model = st.session_state['adapmit_classifier']
|
69 |
|
70 |
-
predictions = classifier_model(list(
|
71 |
# converting the predictions to desired format
|
72 |
list_ = []
|
73 |
for i in range(len(predictions)):
|
@@ -92,6 +101,10 @@ def adapmit_classification(haystack_doc:pd.DataFrame,
|
|
92 |
truth_df['Adapt-Mitig Label'] = truth_df.apply(lambda x:
|
93 |
list(x['Adapt-Mitig Label'] -{None}),axis=1)
|
94 |
# adding Adaptation-Mitigation label
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
|
97 |
return haystack_doc
|
|
|
63 |
"""
|
64 |
logging.info("Working on Adaptation-Mitigation Identification")
|
65 |
haystack_doc['Adapt-Mitig Label'] = 'NA'
|
66 |
+
haystack_doc['cond_check'] = haystack_doc.apply(lambda x: True if (
|
67 |
+
(x['Target Label'] == 'TARGET') | (x['Action Label'] == 'Action') |
|
68 |
+
(x['Policies_Plans Label'] == 'Policies and Plans')) else
|
69 |
+
False, axis=1)
|
70 |
+
# we apply Netzero to only paragraphs which are classified as 'Target' related
|
71 |
+
df1 = haystack_doc[haystack_doc['cond_check'] == True]
|
72 |
+
df1 = temp.reset_index(drop=True)
|
73 |
+
df = haystack_doc[haystack_doc['cond_check'] == False]
|
74 |
+
df = df.reset_index(drop=True)
|
75 |
|
76 |
if not classifier_model:
|
77 |
classifier_model = st.session_state['adapmit_classifier']
|
78 |
|
79 |
+
predictions = classifier_model(list(df1.text))
|
80 |
# converting the predictions to desired format
|
81 |
list_ = []
|
82 |
for i in range(len(predictions)):
|
|
|
101 |
truth_df['Adapt-Mitig Label'] = truth_df.apply(lambda x:
|
102 |
list(x['Adapt-Mitig Label'] -{None}),axis=1)
|
103 |
# adding Adaptation-Mitigation label
|
104 |
+
df1['Adapt-Mitig Label'] = list(truth_df['Adapt-Mitig Label'])
|
105 |
+
df = pd.concat([df,df1])
|
106 |
+
df = df.drop(columns = ['cond_check'])
|
107 |
+
df = df.reset_index(drop =True)
|
108 |
+
df.index += 1
|
109 |
|
110 |
return haystack_doc
|