Kwackwon101 commited on
Commit
2c02a83
·
verified ·
1 Parent(s): e5efa60

requirements.txt

Browse files

streamlit==1.32.2
numpy==1.26.4
tensorflow==2.16.1
pandas==2.2.1
plotly==5.18.0
scikit-learn==1.4.0

Files changed (1) hide show
  1. app.py +23 -33
app.py CHANGED
@@ -3,21 +3,20 @@ import numpy as np
3
  import pandas as pd
4
  import tensorflow as tf
5
  from tensorflow.keras.models import Sequential
6
- from tensorflow.keras.layers import LSTM, Dense, Dropout
7
  from sklearn.preprocessing import MinMaxScaler
8
- import plotly.graph_objs as go
9
 
10
  # إعدادات الصفحة
11
  st.set_page_config(
12
- page_title="Aviator AI",
13
  layout="wide",
14
  initial_sidebar_state="collapsed"
15
  )
16
 
17
  # إعدادات النموذج
18
- WINDOW_SIZE = 3
19
- EPOCHS = 50
20
- BATCH_SIZE = 2
21
 
22
  # إعداد حالة الجلسة
23
  if "values" not in st.session_state:
@@ -38,46 +37,37 @@ def prepare_data(data):
38
 
39
  def build_model():
40
  model = Sequential([
41
- LSTM(64, activation='relu', input_shape=(WINDOW_SIZE, 1)),
42
- Dropout(0.2),
43
- Dense(32, activation='relu'),
44
  Dense(1)
45
  ])
46
  model.compile(
47
- optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),
48
  loss='mse'
49
  )
50
  return model
51
 
52
  # واجهة المستخدم
53
- st.title("تنبؤات Aviator AI")
54
- st.markdown("أدخل القيم ثم اضغط على زر الإضافة")
55
 
56
  col1, col2 = st.columns([3, 1])
57
  with col1:
58
- new_value = st.number_input("القيمة الجديدة:", format="%.2f", key="input")
59
 
60
  with col2:
61
- if st.button("➕ أضف"):
62
- st.session_state.values.append(new_value)
63
  st.rerun()
64
- if st.button("🗑️ مسح"):
65
  st.session_state.values = []
66
  st.session_state.model = None
67
  st.rerun()
68
 
69
  # عرض البيانات
70
  if len(st.session_state.values) > 0:
71
- st.subheader("📈 الرسم البياني")
72
- df = pd.DataFrame(st.session_state.values, columns=['القيم'])
73
- fig = go.Figure()
74
- fig.add_trace(go.Scatter(
75
- x=df.index,
76
- y=df['القيم'],
77
- mode='lines+markers',
78
- name='البيانات الفعلية',
79
- line=dict(color='#2E86C1')
80
- ))
81
  st.plotly_chart(fig, use_container_width=True)
82
 
83
  # التدريب والتنبؤ
@@ -92,7 +82,6 @@ if len(st.session_state.values) >= WINDOW_SIZE + 1:
92
  history = st.session_state.model.fit(
93
  X, y,
94
  epochs=EPOCHS,
95
- batch_size=BATCH_SIZE,
96
  verbose=0
97
  )
98
 
@@ -100,18 +89,19 @@ if len(st.session_state.values) >= WINDOW_SIZE + 1:
100
  np.array(st.session_state.values[-WINDOW_SIZE:]).reshape(-1,1)
101
  ).reshape(1, WINDOW_SIZE, 1)
102
 
103
- predicted_scaled = st.session_state.model.predict(last_sequence, verbose=0)
104
- prediction = st.session_state.scaler.inverse_transform(predicted_scaled)[0][0]
 
105
 
106
- st.success(f"التنبؤ القادم: {prediction:.2f}x")
107
- st.markdown(f"**آخر 3 قيم:** {st.session_state.values[-3:]}")
108
 
109
  except Exception as e:
110
- st.error(f"حدث خطأ: {str(e)}")
111
 
112
  elif len(st.session_state.values) > 0:
113
  needed = WINDOW_SIZE + 1 - len(st.session_state.values)
114
  st.warning(f"أدخل {needed} قيم أخرى لبدء التنبؤات")
115
 
116
  st.markdown("---")
117
- st.caption("الإصدار 3.0 | تم التطوير بواسطة الذكاء الصناعي")
 
3
  import pandas as pd
4
  import tensorflow as tf
5
  from tensorflow.keras.models import Sequential
6
+ from tensorflow.keras.layers import LSTM, Dense
7
  from sklearn.preprocessing import MinMaxScaler
8
+ import plotly.express as px
9
 
10
  # إعدادات الصفحة
11
  st.set_page_config(
12
+ page_title="Aviator Predictor",
13
  layout="wide",
14
  initial_sidebar_state="collapsed"
15
  )
16
 
17
  # إعدادات النموذج
18
+ WINDOW_SIZE = 2 # تم التخفيض لتقليل استهلاك الذاكرة
19
+ EPOCHS = 30 # تم التخفيض لتسريع التدريب
 
20
 
21
  # إعداد حالة الجلسة
22
  if "values" not in st.session_state:
 
37
 
38
  def build_model():
39
  model = Sequential([
40
+ LSTM(32, activation='relu', input_shape=(WINDOW_SIZE, 1)), # تم التبسيط
 
 
41
  Dense(1)
42
  ])
43
  model.compile(
44
+ optimizer='adam',
45
  loss='mse'
46
  )
47
  return model
48
 
49
  # واجهة المستخدم
50
+ st.title("🛩 Aviator Predictor Pro")
51
+ st.markdown("أدخل القيم (مثال: 1.23) ثم اضغط إضافة")
52
 
53
  col1, col2 = st.columns([3, 1])
54
  with col1:
55
+ new_value = st.number_input("القيمة الجديدة:", format="%.2f", key="input", step=0.1)
56
 
57
  with col2:
58
+ if st.button("➕ إضافة"):
59
+ st.session_state.values.append(float(new_value))
60
  st.rerun()
61
+ if st.button("🗑️ مسح البيانات"):
62
  st.session_state.values = []
63
  st.session_state.model = None
64
  st.rerun()
65
 
66
  # عرض البيانات
67
  if len(st.session_state.values) > 0:
68
+ st.subheader("📊 التطور التاريخي")
69
+ df = pd.DataFrame({'القيم': st.session_state.values})
70
+ fig = px.line(df, y='القيم', markers=True)
 
 
 
 
 
 
 
71
  st.plotly_chart(fig, use_container_width=True)
72
 
73
  # التدريب والتنبؤ
 
82
  history = st.session_state.model.fit(
83
  X, y,
84
  epochs=EPOCHS,
 
85
  verbose=0
86
  )
87
 
 
89
  np.array(st.session_state.values[-WINDOW_SIZE:]).reshape(-1,1)
90
  ).reshape(1, WINDOW_SIZE, 1)
91
 
92
+ prediction = st.session_state.scaler.inverse_transform(
93
+ st.session_state.model.predict(last_sequence, verbose=0)
94
+ )[0][0]
95
 
96
+ st.success(f"التنبؤ للجولة القادمة: {prediction:.2f}x")
97
+ st.info(f"آخر {WINDOW_SIZE} قيم: {st.session_state.values[-WINDOW_SIZE:]}")
98
 
99
  except Exception as e:
100
+ st.error(f"حدث خطأ تقني: {str(e)}")
101
 
102
  elif len(st.session_state.values) > 0:
103
  needed = WINDOW_SIZE + 1 - len(st.session_state.values)
104
  st.warning(f"أدخل {needed} قيم أخرى لبدء التنبؤات")
105
 
106
  st.markdown("---")
107
+ st.caption("الإصدار 4.0 | تم التطوير باستخدام خوارزميات التعلم العميق")