Update utils/conditional_classifier.py
Browse files
utils/conditional_classifier.py
CHANGED
@@ -66,9 +66,12 @@ def conditional_classification(haystack_doc:pd.DataFrame,
|
|
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['
|
71 |
-
(x['Policies_Plans Label'] == 'Policies and Plans')) else
|
72 |
False, axis=1)
|
73 |
# we apply Netzero to only paragraphs which are classified as 'Target' related
|
74 |
temp = haystack_doc[haystack_doc['cond_check'] == True]
|
@@ -85,7 +88,7 @@ def conditional_classification(haystack_doc:pd.DataFrame,
|
|
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 |
|
|
|
66 |
haystack_doc['Conditional Label'] = 'NA'
|
67 |
haystack_doc['Conditional Score'] = 0.0
|
68 |
haystack_doc['cond_check'] = False
|
69 |
+
haystack_doc['PA_check'] = haystack_doc['Policy-Action Label'].apply(lambda x: True if len(x) != 0 else False)
|
70 |
+
|
71 |
+
#df1 = haystack_doc[haystack_doc['PA_check'] == True]
|
72 |
+
#df = haystack_doc[haystack_doc['PA_check'] == False]
|
73 |
haystack_doc['cond_check'] = haystack_doc.apply(lambda x: True if (
|
74 |
+
(x['Target Label'] == 'TARGET') | (x['PA_check'] == True) else
|
|
|
75 |
False, axis=1)
|
76 |
# we apply Netzero to only paragraphs which are classified as 'Target' related
|
77 |
temp = haystack_doc[haystack_doc['cond_check'] == True]
|
|
|
88 |
# temp[' Label'] = temp['Netzero Label'].apply(lambda x: _lab_dict[x])
|
89 |
# merging Target with Non Target dataframe
|
90 |
df = pd.concat([df,temp])
|
91 |
+
df = df.drop(columns = ['cond_check','PA_check'])
|
92 |
df = df.reset_index(drop =True)
|
93 |
df.index += 1
|
94 |
|