Create subtarget.py
Browse files- appStore/subtarget.py +37 -0
appStore/subtarget.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.subtarget_classifier import load_subtargetClassifier, subtarget_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 = 'subtarget'
|
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_subtargetClassifier(classifier_name=params['model_name'])
|
33 |
+
st.session_state['{}_classifier'.format(classifier_identifier)] = classifier
|
34 |
+
|
35 |
+
subtarget_classification(haystack_doc=df,
|
36 |
+
threshold= params['threshold'])
|
37 |
+
#st.session_state.key1 = df
|