Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
from utils import ai_markerter, market_validator | |
import time | |
########################## Data Set Up ############################ | |
# loading the data | |
first_call_off = pd.read_csv('first_call_off.csv') | |
fourth_call_off_abc = pd.read_csv('fourth_call_off_abc_df.csv') | |
fourth_call_off_stock = pd.read_csv('fourth_call_off_stock.csv') | |
list_price = pd.read_csv('list_price_df.csv') | |
reagent_price = pd.read_csv('reagent_prices.csv') | |
# a function to load the data and get info | |
def get_info(product_name): | |
# checking the PRODUCT column in all the dataframes, storing the result in a dictionary | |
# adding a try except block to handle the case where the product is not found in the dataframe | |
dict_list = [] | |
df_list = [first_call_off, fourth_call_off_abc, fourth_call_off_stock, list_price, reagent_price] | |
for df in df_list: | |
dict_info = {} | |
if product_name in df['PRODUCTS'].values: | |
dict_info['Product'] = product_name | |
dict_info['Category'] = df['CATEGORY'][df['PRODUCTS'] == product_name].values[0] | |
dict_info['Unit Price'] = df['UNIT NGN'][df['PRODUCTS'] == product_name].values[0] | |
dict_info['Cinuc Price'] = df['CINUC PRICE'][df['PRODUCTS'] == product_name].values[0] | |
dict_info['Exchange Rate'] = df['EXCHANGE RATE'][df['PRODUCTS'] == product_name].values[0] | |
dict_info['Date'] = df['DATE'][df['PRODUCTS'] == product_name].values[0] | |
dict_list.append(dict_info) | |
return dict_list | |
product_lists = ['AFP i- chromax', | |
'AIC NOW catridge for HB Aic determination 10.PKT', | |
'Agary 2ml single-use syringes 23G X11/4 100 /PACK', | |
'Antibiotics multidisk( AB- DISC) gram neg', | |
'Antibiotics multidisk( AB- DISC) gram pos', | |
'Antibiotics multidisk( AB-DISC) gram neg', | |
'Antibiotics multidisk( AB-DISC) gram pos', | |
'Autoclave tapes (roll)', | |
'BATTERY LITHIUM A A3.6V', | |
'BHCG i- chromax', | |
'BioMed sicle scan for rapid genotye X25 /PKT', | |
'Bispot 1 &2 Determinate pkt', | |
'Bispot 1 &2 Determine pkt ALEERE', | |
'Blood group A typing serum 10ml/ 10 bottles /pkt by Biotec', | |
'Blood group AB typing serum 10ml/ 10 bottles /pkt by Biotec', | |
'Blood group B typing serum 10ml/ 10 bottles /pkt by Biotec', | |
'Blood group D typing serum 10ml/ 10 bottles /pkt by Biotec', | |
'CEA i- chromax', | |
'CK-MB i- chromax', | |
'CLED 500g', | |
'COBAS 3 C111 CLEANER', | |
'COBAS 3 C111 PROBE CLEANER 500ML', | |
'COBAS C 11 GLU2 GLUCOSE 400 TESTS', | |
'COBAS C 111 ALKALINE PHOS 400 TESTS', | |
'COBAS C 111 ALT (GPT) 400 TESTS', | |
'COBAS C 111 AST (GOT) 400 TESTS', | |
'COBAS C 111 Automated system CFAS 12 x 3ml botlles /pkt', | |
'COBAS C 111 BLT3 TOTAL BILIRUBIN', | |
'COBAS C 111 CFAS Lipid', | |
'COBAS C 111 CHOL3 CHOLESTEROL 400 TESTS', | |
'COBAS C 111 DEPROTEINIZER 2 bottles / pkt', | |
'COBAS C 111 PRINTER PAPER 4 rolls /PKT', | |
'COBAS C 111 TRIGLYCERIDES 200 TESTS', | |
'COBAS C 111 UREA 400 TESTS', | |
'COBAS C 111 URIC ACID PLUS 400 TESTS', | |
'COBAS C111 CREATININE 400 TESTS', | |
'COBAS C111 HDL 400TESTS', | |
'COBAS C111 SAMPLE CUPS 1000/PKT', | |
'COBAS C111 SODIUN CHLORIDE', | |
'COBAS INTEGRA C 111 ACTIVATOR 9X12 ml bottles /pt', | |
'CORTISOL i- chromax', | |
'CRP i- chromax', | |
'CUVETTE SEGMENT COBAS C 111 5,000 pcs/pkt', | |
'Chloroscope complete kit with ortholidine', | |
'Cholesterol (Accu Answer)', | |
'Clean and check', | |
'Complete set Vacutainer 4ml EDTA by 1000/pkt BD', | |
'Conical Flask 1000ml', | |
'Conical Flask 250ml', | |
'Conical Flask 500ml', | |
'Cotton wool non absorbent 500g', | |
'D-DIMER i- chromax', | |
'D-DIMER i-chromax', | |
'Dependaplast waterproof round spot plasters 100/pkt', | |
'Electrophoresing buffer, 6.1g x 10 shandon/pky', | |
'Epson ribbon for Reflotron printer', | |
'Erytrocyte sedimentation rate, dispet 100/pkt', | |
'FERRITIN i- chromax', | |
'FSH i- chromax', | |
'Febrile antigen test (OMEGA) 8 x 5ml with controls', | |
'Febrile antigen test (VOSAN) 8 x 5ml with controls', | |
"Field's stain A 100ml", | |
"Field's stain B 100ml", | |
'Filter paper whatman 42 ashless 12.5 cm 100/pkt', | |
'Giemsa Stain 100ml/bottle ferntec biosciences', | |
'Glucose (Accu Answer)', | |
'HALOGEN LAMP for COBAS c111', | |
'HCG i- chromax', | |
'HCG test strips Diaspot, diagnostic USA,/ Antec type/ 50/pkt', | |
'HbA1C i- chromax', | |
'Heavy duty oxivir TB bench wipes AHP approved', | |
'HsCRP i- chromax', | |
'Immersion oil 100ml', | |
'Insta TEST 6 PLUS lamotte 50strips/pkt', | |
'Insta iron Lamotte25 strips/pkt', | |
'LH i- chromax', | |
'Labacon H.pylori', | |
'Laboratory lighter plastic gun type', | |
'Latex examination gloves (by Sempercare) 100 7L', | |
'Latex examination gloves (by Sempercare) 100 8-9L', | |
'MICROALBUMIN i- chromax', | |
'MYOGLOBIN same', | |
'Macconkey agar 500g oxoid', | |
'Manfred grease free crytal clear slides 72/Pack x20', | |
'Manifred cover slips 50 x10/pkt', | |
'Methylated spirit 4l BDH with MSDS', | |
'Mindray UA66 uirinalysis strips 50/pkt', | |
'Multistrips for urinalysis, ACON LABS', | |
'Oxoid Blood agar base 500gm by pronadis product', | |
'Oxoid CLED agar 500grams pronadisa product', | |
'Oxoid Iso- sensitest agar agar 500gm pronadisa product', | |
'Oxoid Iso-sensitest agar agar 500gm pronadisa product', | |
'Oxoid MacConkey agar 500gm by pronadisa procuct', | |
'Oxoid Nutrient agar 500gm pronadisa product', | |
'Oxoid Yeast extract agar 500gm pronadisa product', | |
'PCT i- chromax', | |
'PROBE SET COBAS c111', | |
'PROGESTERONE i- chromax', | |
'PROLACTIN i- chromax', | |
'PSA i- chromax', | |
'Paper tapes (Rolls)', | |
'Parazone 500ml x 20bottles /ctn', | |
'Pipette tips (1-200ul) blue type x 1000/pkt EPPENDDORE', | |
'Pyrix Beaker 1000ml', | |
'Pyrix Beaker 100ml', | |
'Pyrix Beaker 2000 ml', | |
'Pyrix Beaker 250ml', | |
'Pyrix Beaker 500ml', | |
'QBC HEAMATOLOGY/MALARIA TUBES 250T', | |
'QBC HEAMATOLOGY/MALARIA TUBES TUBES 250T', | |
'QBC HEMATOLOGY/MALARIA TUBES TUBES 250T', | |
'RF IgM i- chromax', | |
'Reflotron AST/GOT x30 stripes/pkt', | |
'Reflotron AST/GOT x30 stripes/pkt stripes/pkt', | |
'Reflotron Alk.Phosphate x 30 stripes/pkt', | |
'Reflotron Bilirubin x 30 stripes/pkt', | |
'Reflotron Cholesterol x30 stripes/pkt', | |
'Reflotron Creatinine x30 stripes/pkt', | |
'Reflotron GPT/ALT x 30 stripes/pkt', | |
'Reflotron Gamma GT x 30 stripes/pkt', | |
'Reflotron Glucose 15 x 2 stripes /pkt', | |
'Reflotron HDL Cholesterol x 30 stripes/pkt', | |
'Reflotron Pancreatic Amylase 15 x 2', | |
'Reflotron Pancreatic Amylase 15 x 2 stripes/pkt', | |
'Reflotron Pancreatic Amylase 15x2 stripes/pkt', | |
'Reflotron Potassium x 30', | |
'Reflotron Pottasium x 30', | |
'Reflotron Triglycerides x30 stripes/pkt', | |
'Reflotron Urea 15 x 2 stripes/pkt', | |
'Reflotron Uric Acid x 30 stripes/pkt', | |
'S- monovette 4.5ml lithium heparin Sarstedt x 500/cartoon', | |
'S-monovette 2.6ml EDTA by Sarstedt x500/carton *', | |
'SD BIO LINE H. Pylori Antibody test 30 tests /pkt', | |
'SD BIO LINE H.Pylori Antibody test 30 tests /pkt', | |
'SD BIO LINE HBV test kit', | |
'SD BIO LINE HIV 1/2 antibody test kit 3.0 25/pkt', | |
'SD BIO LINE HIV Ag/Ab combo 30tests/pkt', | |
'SD BIOLINE 30 TEST/PKT. (HAV)', | |
'SD BIOLINE HAC 30 TEST/PKT. (HAV)', | |
'SD BIOLINE HCV 3.0 30 tests/pkt', | |
'SD BIOLINE HIV ELISA 3.0 Confirmatory test kit', | |
'SD BIOLINE MALARIA Ag P. f ELISA Test', | |
'SD BIOLINE Prostatic specific antigen ( PSA) 30/pkt', | |
'SD BIOLINE Rheumatoid athritis test kit 30 tests /pkt', | |
'SD BIOLINE Strep A antigen test 25 tests /pkts', | |
'SD BIOLINE TB Ag test kit 25/kpt', | |
'SD MALARIA SINGLE UNITS', | |
'SD Malaria kit HRP2/Pldh (Pf PAN )', | |
'SD malaria Ag Pf.kit for multiple use, 25/pkt BIOLINE', | |
'SD malaria Ag Pf.kit for single use, 25/pkt BIOLINE', | |
'STATPAK HIV 1/2', | |
'Sarstedt multi-safe comfort 6l, sharp box', | |
'Sarstedt standardinnoculation loop(50)/pkt', | |
'Starstedt Safety sterile petri dish disposable type 92/16mm/ctn', | |
'Sterilin type petri dish containers / 100cm', | |
'Sterilin type universal containers, (for urine) Red cap type(400)/ctn', | |
'T3 i- chromax', | |
'T4 i- chromax', | |
'TESTOSTERONE i- chromax', | |
'TSH i- chromax', | |
'Tn-I i- chromax', | |
'UNIGOLD HIV test kit', | |
'Uristix for urinalysis, plus auto check, SIEMENS/ 100/PKT', | |
'Veneral Disease Resarch LAB antigen test, VDRL TEST.', | |
'Veneral Disease Research Laboratory (VDRL) TEST KIT', | |
'Vit D I-Chromax', | |
'Water quality quick test with probefor PH, ORP, EC, DO and Turbidity', | |
'cellulose acetate foils X50 Bayer', | |
'cellulose acetate strips shandon 60 x150mm x 100/pkt', | |
'mindray 5 heaamatology reagent Cleaner', | |
'mindray 5 heaamatology reagent Diluent 20ml', | |
'mindray 5 heaamatology reagent Rinse1L X 4', | |
'mindray 5 heaamatology reagent leo 1 lyse1L X4', | |
'mindray 5 heaamatology reagent leo 11 lyse(400mlx4)', | |
'mindray 5 heamatology reagent Cleaner', | |
'mindray 5 heamatology reagent Diluent 20ml', | |
'mindray 5 heamatology reagent Rinse1L X 4', | |
'mindray 5 heamatology reagent leo 1 lyse1L X4', | |
'mindray 5 heamtology reagents 53LH LYSE 500/ x4', | |
'mindray 5 heamtology reagents 53LH LYSE 500/4', | |
'oxivir TB sprays AHP approved', | |
'sensigrip latex BX 100 INVACARE'] | |
# product = "Field's stain B 100ml" | |
# data = get_info(product) | |
# print(data) | |
############################ Streamlit App ############################ | |
# app config | |
st.set_page_config(page_title="CINUC AI Marketer", page_icon="π", layout="centered") | |
# Adding some information to the app | |
st.markdown("## Welcome to the CINUC AI Marketer") | |
st.write("This is an AI marketer that helps you to predict the price of a product based on the data provided. It uses the data to make a recommendation on the price to be given to the customers for the next 1 year. The AI marketer also provides a short explanation of the strategy used to get to that price.") | |
# App usage information | |
st.markdown("### How to use the App") | |
st.write("1. Enter today's exchange rate") | |
st.write("2. Choose your profit margin") | |
st.write("3. Select a product from the sidebar") | |
st.write("4. The data for the selected product will be displayed") | |
st.write("5. Click on the Analyze and Recommend button to get the price recommendation") | |
st.write("6. The AI marketer will analyze the data and provide a price recommendation based on the forecasted exchange rate.") | |
# today's exchange rate input | |
today_rate = st.number_input("Enter Today's Exchange Rate", value=1650) | |
# profit margin input in range 0-100 | |
profit_margin = st.number_input("Enter Profit Margin", value=50) | |
# configuring the sidebar | |
st.sidebar.title("Select a Product") | |
product = st.sidebar.selectbox("Select a Product", product_lists) | |
# adding a button to analyze the data | |
# some static data | |
Forecasted_price = 2500 | |
today = time.strftime("%d/%m/%Y") | |
if st.sidebar.button("Analyze and Recommend"): | |
# getting the data | |
data = get_info(product) | |
# displaying the data | |
st.write("### Product Data") | |
st.write(pd.DataFrame(data)) | |
# calling the ai_markerter function | |
try: | |
output = ai_markerter(data, Forecasted_price, today, today_rate, profit_margin) | |
new_output = market_validator(data, Forecasted_price, today, today_rate, output, profit_margin) | |
except Exception as e: | |
new_output = f"An error occured, please try again" | |
# displaying the output | |
st.markdown(new_output) |