66import joblib
77import pandas as pd
88import numpy as np
9-
10- # import predict_model
119import streamlit as st
1210
13- # import model
1411model = joblib .load ('models/model_BIMReTA.pkl' )
15- # https://github.com/tanmoyie/Bayesian-Inference-Modeling/blob/clean-code/models/model_BIMReTA.pkl
1612
1713
1814def rank_response_technologies (dispersion , E_ss , E_sl , E_sw , sufficient_mixing_energy ,
1915 E_ssC , seawater , E_ssI , soot_pollution , displacement ):
2016 """Ranking oil spill response technologies in Arctic
21- ++
22- Motivated from https://github.com/krishnaik06/Dockers/blob/master/app.py
2317 """
2418 X1 = pd .DataFrame (np .array ([[dispersion , E_ss , E_sl , E_sw , sufficient_mixing_energy ,
2519 E_ssC , seawater , E_ssI , soot_pollution , displacement ]]))
2620 # 99, 1, 1, 1, 'no', 0, 'Small', 1, 0, 'yes'
27- X1 .columns = ['evaporation_and_natural_disperson' , 'E_ss' , 'E_sl' , 'E_sw' ,'sufficient_mixing_energy' ,
21+ X1 .columns = ['evaporation_and_natural_disperson' , 'E_ss' , 'E_sl' , 'E_sw' , 'sufficient_mixing_energy' ,
2822 'E_ssC' , 'seawater' , 'E_ssI' , 'soot_pollution' , 'displacement' ]
2923
30- prediction = model .predict (X1 ).reshape (1 ,- 1 ).flatten ().tolist ()
24+ prediction = model .predict (X1 ).reshape (1 , - 1 ).flatten ().tolist ()
3125 return prediction
3226
3327
3428def main ():
35- # global result_df
36-
3729 html_temp = """<div style="background-color:tomato;padding:10px;height=20px">
3830 <h3 style="color:white;text-align:center;">Ranking spill response technology: ML App </h3>
3931 </div>"""
40- st .markdown (html_temp , unsafe_allow_html = True )
32+ st .markdown (html_temp , unsafe_allow_html = True )
4133
4234 input_title = """<div style="background-color:gray;padding:0px">
4335 <h4 style="color:white;text-align:center;">Input variables </h4>
@@ -68,9 +60,8 @@ def main():
6860 if st .button ("Rank Technology" ):
6961 result = rank_response_technologies (dispersion , E_ss , E_sl , E_sw , sufficient_mixing_energy ,
7062 E_ssC , seawater , E_ssI , soot_pollution , displacement )
71-
7263 result_df1 = pd .DataFrame (columns = ["MCR" , "CDU" , "ISB" ])
73- #result_df = pd.concat([result_df1, pd.DataFrame(result)], ignore_index=True, axis=0)
64+ # result_df = pd.concat([result_df1, pd.DataFrame(result)], ignore_index=True, axis=0)
7465 result_df1 .loc [len (result_df1 .index )] = result
7566 result_df1 .set_index ([['Ranking' ] * len (result_df1 )],
7667 inplace = True ) # df.set_index([['A']*len(df)], inplace=True)
@@ -81,6 +72,8 @@ def main():
8172 "Marine Pollution Bulletin, 185, 114203 <a href="https://doi.org/10.1016/j.marpolbul.2022.114203"> (link) </a> </p>
8273 </div>"""
8374 st .markdown (paper_title , unsafe_allow_html = True )
75+ # Motivated from https://github.com/krishnaik06/Dockers/blob/master/app.py
76+
8477
8578if __name__ == '__main__' :
8679 main ()
0 commit comments