Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,17 +6,17 @@ import joblib
|
|
| 6 |
model = joblib.load("biochar_lightgbm_model.pkl")
|
| 7 |
le = joblib.load("biochar_label_encoder.pkl")
|
| 8 |
|
| 9 |
-
#
|
| 10 |
feature_names = ['SurfaceArea', 'Fixed Carbon', 'pH', 'Pore Volume', 'Pore Size', 'Energy Content']
|
| 11 |
|
| 12 |
-
#
|
| 13 |
def recommend_with_probs(surface_area, fixed_carbon, pH, pore_volume, pore_size, energy_content):
|
| 14 |
input_data = pd.DataFrame([[surface_area, fixed_carbon, pH, pore_volume, pore_size, energy_content]],
|
| 15 |
columns=feature_names)
|
| 16 |
pred_class = model.predict(input_data)[0]
|
| 17 |
pred_label = le.inverse_transform([pred_class])[0]
|
| 18 |
|
| 19 |
-
#
|
| 20 |
probs = model.predict_proba(input_data)[0]
|
| 21 |
prob_labels = le.inverse_transform(range(len(probs)))
|
| 22 |
prob_df = pd.DataFrame({
|
|
@@ -35,8 +35,8 @@ h1, h2, h3, h4 {text-align: center;}
|
|
| 35 |
"""
|
| 36 |
|
| 37 |
with gr.Blocks(css=css, title="Biochar Application Recommender") as demo:
|
| 38 |
-
gr.Markdown("# 🌱
|
| 39 |
-
gr.Markdown("**
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
with gr.Column():
|
|
|
|
| 6 |
model = joblib.load("biochar_lightgbm_model.pkl")
|
| 7 |
le = joblib.load("biochar_label_encoder.pkl")
|
| 8 |
|
| 9 |
+
# Danh sách các tính năng
|
| 10 |
feature_names = ['SurfaceArea', 'Fixed Carbon', 'pH', 'Pore Volume', 'Pore Size', 'Energy Content']
|
| 11 |
|
| 12 |
+
# Chức năng dự đoán
|
| 13 |
def recommend_with_probs(surface_area, fixed_carbon, pH, pore_volume, pore_size, energy_content):
|
| 14 |
input_data = pd.DataFrame([[surface_area, fixed_carbon, pH, pore_volume, pore_size, energy_content]],
|
| 15 |
columns=feature_names)
|
| 16 |
pred_class = model.predict(input_data)[0]
|
| 17 |
pred_label = le.inverse_transform([pred_class])[0]
|
| 18 |
|
| 19 |
+
# Dự đoán xác suất
|
| 20 |
probs = model.predict_proba(input_data)[0]
|
| 21 |
prob_labels = le.inverse_transform(range(len(probs)))
|
| 22 |
prob_df = pd.DataFrame({
|
|
|
|
| 35 |
"""
|
| 36 |
|
| 37 |
with gr.Blocks(css=css, title="Biochar Application Recommender") as demo:
|
| 38 |
+
gr.Markdown("# 🌱 Chuyên gia AI tư vấn ứng dụng Than sinh học")
|
| 39 |
+
gr.Markdown("** Hệ thống khuyến nghị ứng dụng than sinh học dựa trên tính chất hóa học và vật lý **")
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
with gr.Column():
|