Update app.py
Browse files
app.py
CHANGED
|
@@ -79,12 +79,21 @@ def predict_7_days(sell_features, buy_features, linear_model, scaler):
|
|
| 79 |
)
|
| 80 |
|
| 81 |
|
| 82 |
-
# Harga terakhir
|
| 83 |
-
last_price = [sell_features[7], buy_features[7]]
|
| 84 |
-
|
| 85 |
# Hitung persentase perubahan harian
|
| 86 |
-
|
| 87 |
-
predictions_df['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
# Hitung perubahan total dari hari ini ke hari ketujuh
|
| 90 |
total_sell_change = ((predictions_df['sell'].iloc[-1] - last_price[0]) / last_price[0]) * 100
|
|
|
|
| 79 |
)
|
| 80 |
|
| 81 |
|
| 82 |
+
# Harga terakhir dari data sebelumnya
|
| 83 |
+
last_price = [sell_features[7], buy_features[7]] # Harga jual dan beli terakhir
|
| 84 |
+
|
| 85 |
# Hitung persentase perubahan harian
|
| 86 |
+
# Data pertama dihitung berdasarkan last_price
|
| 87 |
+
predictions_df['sell_change'] = predictions_df['sell'].pct_change() * 100
|
| 88 |
+
predictions_df['buy_change'] = predictions_df['buy'].pct_change() * 100
|
| 89 |
+
|
| 90 |
+
# Perubahan untuk data pertama dihitung manual
|
| 91 |
+
predictions_df.loc[predictions_df.index[0], 'sell_change'] = ((predictions_df['sell'].iloc[0] - last_price[0]) / last_price[0]) * 100
|
| 92 |
+
predictions_df.loc[predictions_df.index[0], 'buy_change'] = ((predictions_df['buy'].iloc[0] - last_price[1]) / last_price[1]) * 100
|
| 93 |
+
|
| 94 |
+
# Ganti nilai NaN untuk baris lainnya dengan 0
|
| 95 |
+
predictions_df['sell_change'] = predictions_df['sell_change'].fillna(0)
|
| 96 |
+
predictions_df['buy_change'] = predictions_df['buy_change'].fillna(0)
|
| 97 |
|
| 98 |
# Hitung perubahan total dari hari ini ke hari ketujuh
|
| 99 |
total_sell_change = ((predictions_df['sell'].iloc[-1] - last_price[0]) / last_price[0]) * 100
|