tbdavid2019 commited on
Commit
53beba1
·
1 Parent(s): 3c0fe99

修改這部分以使用最高預測值

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -130,12 +130,17 @@ def get_top_10_potential_stocks(period, selected_indices):
130
 
131
  predictions = predictor.predict(ts_data)
132
 
133
- # 修改這部分以正確處理預測結果
134
  last_actual = float(data['Close'].iloc[-1])
135
- last_pred = float(predictions.iloc[-1].values[0]) # 確保取得數值
136
- potential = (last_pred - last_actual) / last_actual
137
 
138
- stock_predictions.append((ticker, potential, last_actual, last_pred))
 
 
 
 
 
139
 
140
  except Exception as e:
141
  print(f"Stock {ticker} error: {str(e)}")
 
130
 
131
  predictions = predictor.predict(ts_data)
132
 
133
+ # 修改這部分以使用最高預測值
134
  last_actual = float(data['Close'].iloc[-1])
135
+ highest_pred = float(predictions.values.max()) # 找出預測序列中的最高值
136
+ potential = (highest_pred - last_actual) / last_actual
137
 
138
+ stock_predictions.append((
139
+ ticker,
140
+ potential,
141
+ last_actual,
142
+ highest_pred # 這裡也改為顯示最高預測值
143
+ ))
144
 
145
  except Exception as e:
146
  print(f"Stock {ticker} error: {str(e)}")