Spaces:
Sleeping
Sleeping
legend1234
commited on
Commit
•
1471306
1
Parent(s):
d219162
Fix typos
Browse files
app.py
CHANGED
@@ -5,17 +5,13 @@ from io import StringIO
|
|
5 |
import joblib
|
6 |
import numpy as np
|
7 |
import pandas as pd
|
8 |
-
|
9 |
# page set up
|
10 |
import streamlit as st
|
11 |
from b3clf.descriptor_padel import compute_descriptors
|
12 |
from b3clf.geometry_opt import geometry_optimize
|
13 |
-
from b3clf.utils import (
|
14 |
-
|
15 |
-
|
16 |
-
scale_descriptors,
|
17 |
-
select_descriptors,
|
18 |
-
)
|
19 |
from streamlit_extras.let_it_rain import rain
|
20 |
from streamlit_ketcher import st_ketcher
|
21 |
|
@@ -35,9 +31,9 @@ st.set_page_config(
|
|
35 |
keep_features = "no"
|
36 |
keep_sdf = "no"
|
37 |
classifiers_dict = {
|
38 |
-
"decision
|
39 |
"kNN": "knn",
|
40 |
-
"
|
41 |
"XGBoost": "xgb",
|
42 |
}
|
43 |
resample_methods_dict = {
|
@@ -54,6 +50,7 @@ pandas_display_options = {
|
|
54 |
}
|
55 |
|
56 |
|
|
|
57 |
def generate_predictions(
|
58 |
input_fname: str,
|
59 |
sep: str = "\s+|\t+",
|
@@ -132,8 +129,24 @@ with info_column:
|
|
132 |
# fmt: off
|
133 |
st.markdown(
|
134 |
"""
|
135 |
-
`B3clf` is a Python package for predicting the blood-brain barrier (BBB) permeability of small molecules using imbalanced learning. Source code
|
136 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
# fmt: on
|
138 |
sdf_col, smi_col = st.columns(2)
|
139 |
with sdf_col:
|
@@ -165,7 +178,7 @@ with upload_column:
|
|
165 |
with algorithm_col:
|
166 |
classifier = st.selectbox(
|
167 |
label="Classification Algorithm:",
|
168 |
-
options=("XGBoost", "kNN", "decision
|
169 |
)
|
170 |
with resampler_col:
|
171 |
resampler = st.selectbox(
|
@@ -276,7 +289,10 @@ if submit_job_button:
|
|
276 |
selected_result_rows = np.min(
|
277 |
[results.shape[0], pandas_display_options["line_limit"]]
|
278 |
)
|
279 |
-
|
|
|
|
|
|
|
280 |
# Add a button to download the predictions as a CSV file
|
281 |
predictions_csv = results.to_csv(index=True)
|
282 |
results_file_name = file.name.split(".")[0] + "_b3clf_predictions.csv"
|
|
|
5 |
import joblib
|
6 |
import numpy as np
|
7 |
import pandas as pd
|
|
|
8 |
# page set up
|
9 |
import streamlit as st
|
10 |
from b3clf.descriptor_padel import compute_descriptors
|
11 |
from b3clf.geometry_opt import geometry_optimize
|
12 |
+
from b3clf.utils import (get_descriptors, predict_permeability,
|
13 |
+
scale_descriptors, select_descriptors)
|
14 |
+
# from PIL import Image
|
|
|
|
|
|
|
15 |
from streamlit_extras.let_it_rain import rain
|
16 |
from streamlit_ketcher import st_ketcher
|
17 |
|
|
|
31 |
keep_features = "no"
|
32 |
keep_sdf = "no"
|
33 |
classifiers_dict = {
|
34 |
+
"decision tree": "dtree",
|
35 |
"kNN": "knn",
|
36 |
+
"logistic regression": "logreg",
|
37 |
"XGBoost": "xgb",
|
38 |
}
|
39 |
resample_methods_dict = {
|
|
|
50 |
}
|
51 |
|
52 |
|
53 |
+
@st.cache_resource
|
54 |
def generate_predictions(
|
55 |
input_fname: str,
|
56 |
sep: str = "\s+|\t+",
|
|
|
129 |
# fmt: off
|
130 |
st.markdown(
|
131 |
"""
|
132 |
+
`B3clf` is a Python package for predicting the blood-brain barrier (BBB) permeability of small molecules using imbalanced learning. It supports decision tree, XGBoost, kNN, logistical regression and 5 resampling strategies (SMOTE, Borderline SMOTE, k-means SMOTE and ADASYN). The workflow of `B3clf` is summarized as below. The Source code and more details are available at https://github.com/theochem/B3clf."""
|
133 |
)
|
134 |
+
# text_body = '''
|
135 |
+
# `B3clf` is a Python package for predicting the blood-brain barrier (BBB) permeability of small molecules using imbalanced learning. It supports decision tree, XGBoost, kNN, logistical regression and 5 resampling strategies (SMOTE, Borderline SMOTE, k-means SMOTE and ADASYN). The workflow of `B3clf` is summarized as below. The Source code and more details are available at https://github.com/theochem/B3clf.
|
136 |
+
# '''
|
137 |
+
# st.markdown(f'<p align="justify">{text_body}</p>',
|
138 |
+
# unsafe_allow_html=True)
|
139 |
+
|
140 |
+
# image = Image.open("images/b3clf_workflow.png")
|
141 |
+
# st.image(image=image, use_column_width=True)
|
142 |
+
|
143 |
+
# image_path = "images/b3clf_workflow.png"
|
144 |
+
# image_width_percent = 80
|
145 |
+
# info_column.markdown(
|
146 |
+
# f'<img src="{image_path}" style="max-width: {image_width_percent}%; height: auto;">',
|
147 |
+
# unsafe_allow_html=True
|
148 |
+
# )
|
149 |
+
|
150 |
# fmt: on
|
151 |
sdf_col, smi_col = st.columns(2)
|
152 |
with sdf_col:
|
|
|
178 |
with algorithm_col:
|
179 |
classifier = st.selectbox(
|
180 |
label="Classification Algorithm:",
|
181 |
+
options=("XGBoost", "kNN", "decision tree", "logistic regression"),
|
182 |
)
|
183 |
with resampler_col:
|
184 |
resampler = st.selectbox(
|
|
|
289 |
selected_result_rows = np.min(
|
290 |
[results.shape[0], pandas_display_options["line_limit"]]
|
291 |
)
|
292 |
+
results_df_display = results.iloc[
|
293 |
+
:selected_result_rows, :
|
294 |
+
].style.format({"B3clf_predicted_probability": "{:.6f}".format})
|
295 |
+
st.dataframe(results_df_display, hide_index=True)
|
296 |
# Add a button to download the predictions as a CSV file
|
297 |
predictions_csv = results.to_csv(index=True)
|
298 |
results_file_name = file.name.split(".")[0] + "_b3clf_predictions.csv"
|