ppsingh commited on
Commit
b78b722
1 Parent(s): e6c722f

Delete appStore/netzero.py

Browse files
Files changed (1) hide show
  1. appStore/netzero.py +0 -95
appStore/netzero.py DELETED
@@ -1,95 +0,0 @@
1
- # set path
2
- import glob, os, sys;
3
- sys.path.append('../utils')
4
-
5
- #import needed libraries
6
- import seaborn as sns
7
- import matplotlib.pyplot as plt
8
- import numpy as np
9
- import pandas as pd
10
- import streamlit as st
11
- from utils.netzero_classifier import load_netzeroClassifier, netzero_classification
12
- import logging
13
- logger = logging.getLogger(__name__)
14
- from utils.config import get_classifier_params
15
- from io import BytesIO
16
- import xlsxwriter
17
- import plotly.express as px
18
-
19
-
20
- # Declare all the necessary variables
21
- classifier_identifier = 'netzero'
22
- params = get_classifier_params(classifier_identifier)
23
-
24
- # Labels dictionary ###
25
- _lab_dict = {
26
- 'NEGATIVE':'NO NETZERO TARGET',
27
- 'NA':'NOT APPLICABLE',
28
- 'NETZERO':'NETZERO TARGET',
29
- }
30
-
31
-
32
- @st.cache_data
33
- def to_excel(df):
34
- len_df = len(df)
35
- output = BytesIO()
36
- writer = pd.ExcelWriter(output, engine='xlsxwriter')
37
- df.to_excel(writer, index=False, sheet_name='Sheet1')
38
- workbook = writer.book
39
- worksheet = writer.sheets['Sheet1']
40
- worksheet.data_validation('E2:E{}'.format(len_df),
41
- {'validate': 'list',
42
- 'source': ['No', 'Yes', 'Discard']})
43
- writer.save()
44
- processed_data = output.getvalue()
45
- return processed_data
46
-
47
- def app():
48
- ### Main app code ###
49
- with st.container():
50
- if 'key1' in st.session_state:
51
- df = st.session_state.key1
52
-
53
- # Load the classifier model
54
- classifier = load_netzeroClassifier(classifier_name=params['model_name'])
55
- st.session_state['{}_classifier'.format(classifier_identifier)] = classifier
56
-
57
- if sum(df['Target Label'] == 'TARGET') > 100:
58
- warning_msg = ": This might take sometime, please sit back and relax."
59
- else:
60
- warning_msg = ""
61
-
62
- df = netzero_classification(haystack_doc=df,
63
- threshold= params['threshold'])
64
- st.session_state.key1 = df
65
-
66
-
67
- def netzero_display():
68
- if 'key1' in st.session_state:
69
- df = st.session_state.key2
70
- hits = df[df['Netzero Label'] == 'NETZERO']
71
- range_val = min(5,len(hits))
72
- if range_val !=0:
73
- count_df = df['Netzero Label'].value_counts()
74
- count_df = count_df.rename('count')
75
- count_df = count_df.rename_axis('Netzero Label').reset_index()
76
- count_df['Label_def'] = count_df['Netzero Label'].apply(lambda x: _lab_dict[x])
77
-
78
- fig = px.bar(count_df, y="Label_def", x="count", orientation='h', height =200)
79
- c1, c2 = st.columns([1,1])
80
- with c1:
81
- st.plotly_chart(fig,use_container_width= True)
82
-
83
- hits = hits.sort_values(by=['Netzero Score'], ascending=False)
84
- st.write("")
85
- st.markdown("###### Top few NetZero Target Classified paragraph/text results ######")
86
- range_val = min(5,len(hits))
87
- for i in range(range_val):
88
- # the page number reflects the page that contains the main paragraph
89
- # according to split limit, the overlapping part can be on a separate page
90
- st.write('**Result {}** `page {}` (Relevancy Score: {:.2f})'.format(i+1,hits.iloc[i]['page'],hits.iloc[i]['Netzero Score']))
91
- st.write("\t Text: \t{}".format(hits.iloc[i]['text']))
92
- else:
93
- st.info("🤔 No Netzero target found")
94
-
95
-