Create conditional.py
Browse files- appStore/conditional.py +42 -0
appStore/conditional.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.conditional_classifier import load_conditionalClassifier, conditional_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 = 'conditional'
|
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_conditionalClassifier(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 = conditional_classification(haystack_doc=df,
|
41 |
+
threshold= params['threshold'])
|
42 |
+
st.session_state.key1 = df
|