santuchal commited on
Commit
d6cdde0
·
verified ·
1 Parent(s): 93467f1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -0
app.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import joblib
3
+ from sklearn.ensemble import RandomForestRegressor
4
+ import gzip
5
+ from rdkit.Chem import MolFromSmiles, rdMolDescriptors
6
+ from rdkit.Chem.Descriptors import CalcMolDescriptors
7
+ import lightgbm as lgb
8
+ from sklearn.ensemble import ExtraTreesRegressor
9
+ import streamlit as st
10
+
11
+ class Molecule:
12
+ def __init__(self, smiles: str):
13
+ if not smiles :
14
+ print("Empty smiles are given")
15
+ sys.exit()
16
+ self.smiles = smiles
17
+ self.mol = MolFromSmiles(smiles)
18
+ def descriptor_generator(self):
19
+ return CalcMolDescriptors(self.mol)
20
+
21
+ SMI = st.text_input('Input SMILE', 'O=Cc1ccc(Cl)cc1')
22
+ st.write('The input SMILE is', str(SMI))
23
+ mol = MolFromSmiles(SMI)
24
+
25
+ formula = rdMolDescriptors.CalcMolFormula(MolFromSmiles(SMI))
26
+ descriptors = CalcMolDescriptors(mol)
27
+ descriptors_dataframe = pd.DataFrame([list(descriptors.values())], columns= list(descriptors.keys()))
28
+ st.markdown(''':rainbow[ABSORPTION]''')
29
+
30
+ st.markdown(''':rainbow[Lipophilicity]''')
31
+
32
+ st.markdown(''':orange[LGBMRegressor]''')
33
+
34
+
35
+ with gzip.GzipFile('model/Absorption_Lipophilicity_Prediction_lgbm_model.joblib.gz', 'rb') as fa:
36
+ Absorption_Lipophilicity_Prediction_lgbm_model = joblib.load(fa)
37
+
38
+ st.write("Absorption Lipophilicity Result for LGBM Regressor : ", round(Absorption_Lipophilicity_Prediction_lgbm_model.predict(descriptors_dataframe)[0],4))
39
+
40
+
41
+ with gzip.GzipFile('model/Absorption_Lipophilicity_Prediction_etr_model.joblib.gz', 'rb') as fe:
42
+ Absorption_Lipophilicity_Prediction_etr_model = joblib.load(fe)
43
+
44
+ st.markdown(''':orange[ExtraTreesRegressor]''')
45
+ st.write("Absorption_Lipophilicity Result for ExtraTreesRegressor : ", round(Absorption_Lipophilicity_Prediction_etr_model.predict(descriptors_dataframe)[0],4))
46
+
47
+
48
+ with gzip.GzipFile('model/Absorption_Lipophilicity_Prediction_rf_model.joblib.gz', 'rb') as fi:
49
+ Absorption_Lipophilicity_Prediction_rf_model = joblib.load(fi)
50
+
51
+
52
+ st.markdown(''':orange[RandomForestRegressor]''')
53
+ st.write("Absorption_Lipophilicity Result for RandomForestRegressor : ", round(Absorption_Lipophilicity_Prediction_rf_model.predict(descriptors_dataframe)[0],4))
54
+
55
+
56
+ with gzip.GzipFile('model/Absorption_Lipophilicity_Prediction_rf_model_optimised.joblib.gz', 'rb') as fo:
57
+ Absorption_Lipophilicity_Prediction_rf_model_optimised = joblib.load(fo)
58
+
59
+ st.markdown(''':orange[RandomForestRegressor Optimised]''')
60
+ st.write("Absorption_Lipophilicity Result for Optimised RandomForestRegressor : ", round(Absorption_Lipophilicity_Prediction_rf_model_optimised.predict(descriptors_dataframe)[0],4))
61
+
62
+ with gzip.GzipFile('model/Absorption_Lipophilicity_Prediction_etr_model_optimised.joblib.gz', 'rb') as fu:
63
+ Absorption_Lipophilicity_Prediction_etr_model_optimised = joblib.load(fu)
64
+
65
+ st.markdown(''':orange[ExtraTreesRegressor Optimised]''')
66
+ st.write("Absorption_Lipophilicity Result for Optimised ExtraTreesRegressor : ", round(Absorption_Lipophilicity_Prediction_etr_model_optimised.predict(descriptors_dataframe)[0],4))
67
+
68
+ st.markdown(''':orange[LGBMRegressor Optimised]''')
69
+ with gzip.GzipFile('model/Absorption_Lipophilicity_Prediction_lgbm_model_optimised.joblib.gz', 'rb') as fb:
70
+ Absorption_Lipophilicity_Prediction_lgbm_model_optimised = joblib.load(fb)
71
+
72
+ st.write("Absorption Lipophilicity Result for Optimised LGBM Regressor : ", round(Absorption_Lipophilicity_Prediction_lgbm_model_optimised.predict(descriptors_dataframe)[0],4))