Spaces:
Running
Running
Refactor prediction logic in historis view; prepare data for model prediction with renamed columns and improved error handling
Browse files- __pycache__/db_manager.cpython-313.pyc +0 -0
- app.py +12 -6
__pycache__/db_manager.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/db_manager.cpython-313.pyc and b/__pycache__/db_manager.cpython-313.pyc differ
|
|
|
app.py
CHANGED
|
@@ -220,12 +220,18 @@ def get_historis_view():
|
|
| 220 |
df['Tanggal'] = pd.to_datetime(df['Tanggal'], format='%d/%m/%Y', errors='coerce')
|
| 221 |
df = df.dropna(subset=['Tanggal']).sort_values('Tanggal')
|
| 222 |
|
| 223 |
-
#
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
df['
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
# Create display table
|
| 231 |
df_display = df[['Tanggal', 'average', 'ketebalan_prediksi', 'Ketebalan BTA (mm)']].copy()
|
|
|
|
| 220 |
df['Tanggal'] = pd.to_datetime(df['Tanggal'], format='%d/%m/%Y', errors='coerce')
|
| 221 |
df = df.dropna(subset=['Tanggal']).sort_values('Tanggal')
|
| 222 |
|
| 223 |
+
# Prepare data for model prediction
|
| 224 |
+
# Rename columns to match model expectations
|
| 225 |
+
df_model = pd.DataFrame({
|
| 226 |
+
'cone_depan': df['Cone Depan (°C)'],
|
| 227 |
+
'bodi_tengah': df['Bodi Tengah (°C)'],
|
| 228 |
+
'cone_belakang': df['Cone Belakang (°C)'],
|
| 229 |
+
'suhu_avg': df['average']
|
| 230 |
+
})
|
| 231 |
+
|
| 232 |
+
# Get predictions from actual model
|
| 233 |
+
predictions = model_mgr.predict_batch(df_model)
|
| 234 |
+
df['ketebalan_prediksi'] = predictions
|
| 235 |
|
| 236 |
# Create display table
|
| 237 |
df_display = df[['Tanggal', 'average', 'ketebalan_prediksi', 'Ketebalan BTA (mm)']].copy()
|