add conditionality
Browse files
utils/conditional_classifier.py
CHANGED
@@ -8,12 +8,6 @@ from utils.preprocessing import processingpipeline
|
|
8 |
import streamlit as st
|
9 |
from transformers import pipeline
|
10 |
|
11 |
-
# Labels dictionary ###
|
12 |
-
_lab_dict = {
|
13 |
-
'NEGATIVE':'NO NETZERO TARGET',
|
14 |
-
'NET-ZERO':'NETZERO TARGET',
|
15 |
-
'TARGET_FREE':'OTHERS'
|
16 |
-
}
|
17 |
|
18 |
@st.cache_resource
|
19 |
def load_conditionalClassifier(config_file:str = None, classifier_name:str = None):
|
@@ -70,7 +64,7 @@ def conditional_classification(haystack_doc:pd.DataFrame,
|
|
70 |
"""
|
71 |
logging.info("Working on Conditionality Identification")
|
72 |
haystack_doc['Conditional Label'] = 'NA'
|
73 |
-
haystack_doc['Conditional Score'] =
|
74 |
haystack_doc['cond_check'] = False
|
75 |
haystack_doc['cond_check'] = haystack_doc.apply(lambda x: True if (
|
76 |
(x['Target Label'] == 'TARGET') | (x['Action Label'] == 'Action') |
|
@@ -91,6 +85,7 @@ def conditional_classification(haystack_doc:pd.DataFrame,
|
|
91 |
# temp[' Label'] = temp['Netzero Label'].apply(lambda x: _lab_dict[x])
|
92 |
# merging Target with Non Target dataframe
|
93 |
df = pd.concat([df,temp])
|
|
|
94 |
df = df.reset_index(drop =True)
|
95 |
df.index += 1
|
96 |
|
|
|
8 |
import streamlit as st
|
9 |
from transformers import pipeline
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
@st.cache_resource
|
13 |
def load_conditionalClassifier(config_file:str = None, classifier_name:str = None):
|
|
|
64 |
"""
|
65 |
logging.info("Working on Conditionality Identification")
|
66 |
haystack_doc['Conditional Label'] = 'NA'
|
67 |
+
haystack_doc['Conditional Score'] = 0.0
|
68 |
haystack_doc['cond_check'] = False
|
69 |
haystack_doc['cond_check'] = haystack_doc.apply(lambda x: True if (
|
70 |
(x['Target Label'] == 'TARGET') | (x['Action Label'] == 'Action') |
|
|
|
85 |
# temp[' Label'] = temp['Netzero Label'].apply(lambda x: _lab_dict[x])
|
86 |
# merging Target with Non Target dataframe
|
87 |
df = pd.concat([df,temp])
|
88 |
+
df = df.drop(columns = ['cond_check'])
|
89 |
df = df.reset_index(drop =True)
|
90 |
df.index += 1
|
91 |
|