Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -3,11 +3,12 @@ import numpy as np
|
|
| 3 |
import joblib
|
| 4 |
|
| 5 |
# =========================
|
| 6 |
-
# Load model
|
| 7 |
# =========================
|
| 8 |
-
model = joblib.load("
|
|
|
|
| 9 |
# =========================
|
| 10 |
-
#
|
| 11 |
# =========================
|
| 12 |
st.set_page_config(
|
| 13 |
page_title="EV Performance Prediction",
|
|
@@ -15,31 +16,72 @@ st.set_page_config(
|
|
| 15 |
layout="centered"
|
| 16 |
)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# =========================
|
| 24 |
-
#
|
| 25 |
-
# (encoded giống như lúc train)
|
| 26 |
# =========================
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# =========================
|
| 35 |
-
#
|
| 36 |
# =========================
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
prediction = model.predict(X)
|
| 44 |
|
| 45 |
-
st.success(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import joblib
|
| 4 |
|
| 5 |
# =========================
|
| 6 |
+
# Load model
|
| 7 |
# =========================
|
| 8 |
+
model = joblib.load("model.joblib")
|
| 9 |
+
|
| 10 |
# =========================
|
| 11 |
+
# Page config
|
| 12 |
# =========================
|
| 13 |
st.set_page_config(
|
| 14 |
page_title="EV Performance Prediction",
|
|
|
|
| 16 |
layout="centered"
|
| 17 |
)
|
| 18 |
|
| 19 |
+
# =========================
|
| 20 |
+
# Header
|
| 21 |
+
# =========================
|
| 22 |
+
st.markdown(
|
| 23 |
+
"""
|
| 24 |
+
<h1 style='text-align: center;'>🔋 Electric Vehicle Performance Prediction</h1>
|
| 25 |
+
<p style='text-align: center; font-size:18px;'>
|
| 26 |
+
Dự báo hiệu suất kỹ thuật xe điện (Electric Range)
|
| 27 |
+
</p>
|
| 28 |
+
<hr>
|
| 29 |
+
""",
|
| 30 |
+
unsafe_allow_html=True
|
| 31 |
+
)
|
| 32 |
|
| 33 |
# =========================
|
| 34 |
+
# Sidebar (thầy cô rất thích)
|
|
|
|
| 35 |
# =========================
|
| 36 |
+
st.sidebar.header("📌 Thông tin mô hình")
|
| 37 |
+
st.sidebar.markdown(
|
| 38 |
+
"""
|
| 39 |
+
- **Bài toán**: Hồi quy (Regression)
|
| 40 |
+
- **Thuật toán**: XGBoost
|
| 41 |
+
- **Đầu ra**: Electric Range
|
| 42 |
+
- **Triển khai**: Hugging Face
|
| 43 |
+
"""
|
| 44 |
+
)
|
| 45 |
|
| 46 |
# =========================
|
| 47 |
+
# Input section
|
| 48 |
# =========================
|
| 49 |
+
st.subheader("📥 Nhập thông tin xe")
|
| 50 |
+
|
| 51 |
+
col1, col2 = st.columns(2)
|
| 52 |
+
|
| 53 |
+
with col1:
|
| 54 |
+
year = st.number_input("Model Year", 1990, 2035, 2020)
|
| 55 |
+
make = st.number_input("Make (encoded)", value=10)
|
| 56 |
+
model_code = st.number_input("Model (encoded)", value=20)
|
| 57 |
|
| 58 |
+
with col2:
|
| 59 |
+
ev_type = st.number_input("EV Type (encoded)", value=1)
|
| 60 |
+
cafv = st.number_input("CAFV Eligibility (encoded)", value=0)
|
| 61 |
+
utility = st.number_input("Electric Utility (encoded)", value=60)
|
| 62 |
|
| 63 |
+
# =========================
|
| 64 |
+
# Predict button
|
| 65 |
+
# =========================
|
| 66 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 67 |
+
|
| 68 |
+
if st.button("🚀 Dự báo hiệu suất"):
|
| 69 |
+
X = np.array([[year, make, model_code, ev_type, cafv, utility]])
|
| 70 |
prediction = model.predict(X)
|
| 71 |
|
| 72 |
+
st.success(
|
| 73 |
+
f"🔍 **Electric Range dự đoán:** `{prediction[0]:.2f}` km"
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
# =========================
|
| 77 |
+
# Footer
|
| 78 |
+
# =========================
|
| 79 |
+
st.markdown(
|
| 80 |
+
"""
|
| 81 |
+
<hr>
|
| 82 |
+
<p style='text-align: center; font-size:14px;'>
|
| 83 |
+
Student Research Project – Academic Year 2024–2025
|
| 84 |
+
</p>
|
| 85 |
+
""",
|
| 86 |
+
unsafe_allow_html=True
|
| 87 |
+
)
|