Delete appStore/netzero.py
Browse files- appStore/netzero.py +0 -89
appStore/netzero.py
DELETED
@@ -1,89 +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 |
-
|
25 |
-
def app():
|
26 |
-
### Main app code ###
|
27 |
-
with st.container():
|
28 |
-
if 'key1' in st.session_state:
|
29 |
-
df = st.session_state.key1
|
30 |
-
|
31 |
-
# Load the classifier model
|
32 |
-
classifier = load_netzeroClassifier(classifier_name=params['model_name'])
|
33 |
-
st.session_state['{}_classifier'.format(classifier_identifier)] = classifier
|
34 |
-
|
35 |
-
if sum(df['Target Label'] == 'TARGET') > 100:
|
36 |
-
warning_msg = ": This might take sometime, please sit back and relax."
|
37 |
-
else:
|
38 |
-
warning_msg = ""
|
39 |
-
|
40 |
-
df = netzero_classification(haystack_doc=df,
|
41 |
-
threshold= params['threshold'])
|
42 |
-
st.session_state.key1 = df
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
# @st.cache_data
|
47 |
-
# def to_excel(df):
|
48 |
-
# len_df = len(df)
|
49 |
-
# output = BytesIO()
|
50 |
-
# writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
51 |
-
# df.to_excel(writer, index=False, sheet_name='Sheet1')
|
52 |
-
# workbook = writer.book
|
53 |
-
# worksheet = writer.sheets['Sheet1']
|
54 |
-
# worksheet.data_validation('E2:E{}'.format(len_df),
|
55 |
-
# {'validate': 'list',
|
56 |
-
# 'source': ['No', 'Yes', 'Discard']})
|
57 |
-
# writer.save()
|
58 |
-
# processed_data = output.getvalue()
|
59 |
-
# return processed_data
|
60 |
-
|
61 |
-
# def netzero_display():
|
62 |
-
# if 'key1' in st.session_state:
|
63 |
-
# df = st.session_state.key2
|
64 |
-
# hits = df[df['Netzero Label'] == 'NETZERO']
|
65 |
-
# range_val = min(5,len(hits))
|
66 |
-
# if range_val !=0:
|
67 |
-
# count_df = df['Netzero Label'].value_counts()
|
68 |
-
# count_df = count_df.rename('count')
|
69 |
-
# count_df = count_df.rename_axis('Netzero Label').reset_index()
|
70 |
-
# count_df['Label_def'] = count_df['Netzero Label'].apply(lambda x: _lab_dict[x])
|
71 |
-
|
72 |
-
# fig = px.bar(count_df, y="Label_def", x="count", orientation='h', height =200)
|
73 |
-
# c1, c2 = st.columns([1,1])
|
74 |
-
# with c1:
|
75 |
-
# st.plotly_chart(fig,use_container_width= True)
|
76 |
-
|
77 |
-
# hits = hits.sort_values(by=['Netzero Score'], ascending=False)
|
78 |
-
# st.write("")
|
79 |
-
# st.markdown("###### Top few NetZero Target Classified paragraph/text results ######")
|
80 |
-
# range_val = min(5,len(hits))
|
81 |
-
# for i in range(range_val):
|
82 |
-
# # the page number reflects the page that contains the main paragraph
|
83 |
-
# # according to split limit, the overlapping part can be on a separate page
|
84 |
-
# st.write('**Result {}** `page {}` (Relevancy Score: {:.2f})'.format(i+1,hits.iloc[i]['page'],hits.iloc[i]['Netzero Score']))
|
85 |
-
# st.write("\t Text: \t{}".format(hits.iloc[i]['text']))
|
86 |
-
# else:
|
87 |
-
# st.info("🤔 No Netzero target found")
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|