Create tapp.py
Browse files- appStore/tapp.py +49 -0
appStore/tapp.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 st_aggrid import AgGrid
|
12 |
+
from utils.tapp_classifier import load_tappClassifier, tapp_classification
|
13 |
+
import logging
|
14 |
+
logger = logging.getLogger(__name__)
|
15 |
+
from utils.config import get_classifier_params
|
16 |
+
from io import BytesIO
|
17 |
+
import xlsxwriter
|
18 |
+
import plotly.express as px
|
19 |
+
from pandas.api.types import (
|
20 |
+
is_categorical_dtype,
|
21 |
+
is_datetime64_any_dtype,
|
22 |
+
is_numeric_dtype,
|
23 |
+
is_object_dtype,
|
24 |
+
is_list_like)
|
25 |
+
|
26 |
+
# Declare all the necessary variables
|
27 |
+
tapp_classifier_identifier = 'tapp'
|
28 |
+
param1 = get_classifier_params(tapp_classifier_identifier)
|
29 |
+
|
30 |
+
def app():
|
31 |
+
### Main app code ###
|
32 |
+
with st.container():
|
33 |
+
if 'key0' in st.session_state:
|
34 |
+
df = st.session_state.key0
|
35 |
+
|
36 |
+
#load Classifiers
|
37 |
+
classifier = load_tappClassifier(classifier_name=param1['model_name'])
|
38 |
+
st.session_state['{}_classifier'.format(tapp_classifier_identifier)] = classifier
|
39 |
+
|
40 |
+
if len(df) > 100:
|
41 |
+
warning_msg = ": This might take sometime, please sit back and relax."
|
42 |
+
else:
|
43 |
+
warning_msg = ""
|
44 |
+
|
45 |
+
df = tapp_classification(haystack_doc=df,
|
46 |
+
threshold= param1['threshold'])
|
47 |
+
st.dataframe(df)
|
48 |
+
|
49 |
+
st.session_state.key1 = df
|