salman-mhmd-khan commited on
Commit
b685424
·
verified ·
1 Parent(s): af07741

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -226,20 +226,27 @@ def build_lstm_model(input_shape):
226
  return model
227
 
228
  # Calculate prediction based of LTSM model learning
229
- def calculate_prediction_with_ltsm(symbol="BTC", period="5d", interval="5m"):
 
230
  data = get_crypto_data(symbol, period, interval)
231
  prices = [(pd.to_datetime(index, unit='m'), price) for index, price in data['Close'].items()]
232
  df = pd.DataFrame(prices, columns=['Date', 'Price'])
233
 
 
234
  X, Y, scaler = prepare_lstm_data(df)
 
 
235
  model = build_lstm_model((X.shape[1], 1))
236
 
237
  # Train the model
238
- print("Model training on the latest data from CoinGecko!")
239
  model.fit(X, Y, batch_size=32, epochs=10)
240
 
241
  # Predict the next price point
 
242
  last_sequence = X[-1].reshape(1, X.shape[1], 1)
 
 
243
  scaled_prediction = model.predict(last_sequence)
244
  predicted_price = scaler.inverse_transform(scaled_prediction)
245
 
@@ -452,5 +459,18 @@ elif predict_lstm_button:
452
  interval = "5m"
453
  predicted_price = calculate_prediction_with_ltsm(symbol, period, interval)
454
 
455
- st.write("### **Final Predicted value by learned LTSM model based on last 5 days with 5 interval of closing data** ###")
456
- st.write(f"**Predicted next realtime price: ${predicted_price[0][0]:.10f}**")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  return model
227
 
228
  # Calculate prediction based of LTSM model learning
229
+ def calculate_prediction_with_ltsm(symbol="BTC", period="5d", interval="5m"):
230
+ st.write("**Fetched Data...")
231
  data = get_crypto_data(symbol, period, interval)
232
  prices = [(pd.to_datetime(index, unit='m'), price) for index, price in data['Close'].items()]
233
  df = pd.DataFrame(prices, columns=['Date', 'Price'])
234
 
235
+ st.write("**Preparing data for LTSM Model training......")
236
  X, Y, scaler = prepare_lstm_data(df)
237
+
238
+ st.write("**Build LTSM Model with X shape data.........")
239
  model = build_lstm_model((X.shape[1], 1))
240
 
241
  # Train the model
242
+ st.write("**Train LTSM Model with X,Y shape data with batch_size(32), epochs(10)............")
243
  model.fit(X, Y, batch_size=32, epochs=10)
244
 
245
  # Predict the next price point
246
+ st.write("**Sequence LTSM Model with X,Y shape data with batch_size(32), epochs(10)...............")
247
  last_sequence = X[-1].reshape(1, X.shape[1], 1)
248
+
249
+ st.write("**Predict realtime price with LTSM Model trained with X,Y shape data with batch_size(32), epochs(10)..................")
250
  scaled_prediction = model.predict(last_sequence)
251
  predicted_price = scaler.inverse_transform(scaled_prediction)
252
 
 
459
  interval = "5m"
460
  predicted_price = calculate_prediction_with_ltsm(symbol, period, interval)
461
 
462
+ #st.write("### **Final Predicted value by learned LTSM model based on last 5 days with 5 interval of closing data** ###")
463
+ #st.write(f"**Predicted next realtime price: ${predicted_price[0][0]:.10f}**")
464
+
465
+ st.markdown(
466
+ """
467
+ <h3 style="color: #FFD700;">Final Predicted Value by Learned LSTM Model</h3>
468
+ <p style="font-size: 1.5em; color: #32CD32;">
469
+ Based on the last 5 days with 5-minute intervals of closing data:
470
+ </p>
471
+ <p style="font-size: 2em; font-weight: bold; color: #FF4500;">
472
+ Predicted Next Realtime Price: ${predicted_price[0][0]:.10f}
473
+ </p>
474
+ """,
475
+ unsafe_allow_html=True
476
+ )