Skip to content

Commit cda0b4b

Browse files
committed
update code & file naming
1 parent 2565993 commit cda0b4b

20 files changed

+46
-25
lines changed

.github/workflows/clone.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
echo $gist_id | gh secret set GIST_ID
4545
echo ::set-output name=GIST::$gist_id
4646
cp NVDA-Price-Stock-Prediction_clone.json NVDA-Price-Stock-Prediction_clone_before.json
47-
git rm --ignore-unmatch Git_State/CLONE.md
47+
git rm --ignore-unmatch git_state/CLONE.md
4848
fi
4949
else
5050
echo "GIST_ID not found. Creating a gist..."
@@ -56,7 +56,7 @@ jobs:
5656
5757
- name: update NVDA-Price-Stock-Prediction_clone.json
5858
run: |
59-
curl https://raw.githubusercontent.com/Junwu0615/NVDA-Price-Stock-Prediction/main/Git_State/clone.py > clone.py
59+
curl https://raw.githubusercontent.com/Junwu0615/NVDA-Price-Stock-Prediction/main/git_state/clone.py > clone.py
6060
python3 clone.py
6161
6262
- name: Update gist with latest count
@@ -68,25 +68,25 @@ jobs:
6868
-H "Content-Type: application/json" \
6969
-d @NVDA-Price-Stock-Prediction_post_clone.json https://api.github.com/gists/${{ steps.set_id.outputs.GIST }} > /dev/null 2>&1
7070
71-
if [ ! -f Git_State/CLONE.md ]; then
71+
if [ ! -f git_state/CLONE.md ]; then
7272
shields="https://img.shields.io/badge/dynamic/json?color=success&label=Clone&query=count_total&url="
7373
url="https://gist.githubusercontent.com/${{ github.actor }}/${{ steps.set_id.outputs.GIST }}/raw/NVDA-Price-Stock-Prediction_clone.json"
7474
repo="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction"
75-
echo ''> Git_State/CLONE.md
75+
echo ''> git_state/CLONE.md
7676
echo '
7777
**Markdown**
7878
79-
```markdown' >> Git_State/CLONE.md
80-
echo "[![GitHub Clones]($shields$url&logo=github)]($repo)" >> Git_State/CLONE.md
79+
```markdown' >> git_state/CLONE.md
80+
echo "[![GitHub Clones]($shields$url&logo=github)]($repo)" >> git_state/CLONE.md
8181
echo '
8282
```
8383
8484
**HTML**
85-
```html' >> Git_State/CLONE.md
86-
echo "<a href='$repo'><img alt='GitHub Clones' src='$shields$url&logo=github'></a>" >> Git_State/CLONE.md
87-
echo '```' >> Git_State/CLONE.md
85+
```html' >> git_state/CLONE.md
86+
echo "<a href='$repo'><img alt='GitHub Clones' src='$shields$url&logo=github'></a>" >> git_state/CLONE.md
87+
echo '```' >> git_state/CLONE.md
8888
89-
git add Git_State/CLONE.md
89+
git add git_state/CLONE.md
9090
git config --global user.name "GitHub Action"
9191
git config --global user.email "action@github.com"
9292
git commit -m "create clone count badge"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ __pycache__
22
.idea
33
.ipynb_checkpoints
44
FMP-Get-NVDA-History.py
5-
Trained
5+
trained

Entry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
Update Time: 2024-11-24
55
"""
66

7-
from Depend.Model import Model
8-
from Depend.ArgumentParser import AP
7+
from package.Model import Model
8+
from package.ArgumentParser import AP
99

1010
class Entry:
1111
def __init__(self):

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Ping Chun, Wu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ python Entry.py -h
4848
```py
4949
python Entry.py -open T -high T -low T -vol T -utm F
5050
```
51-
- <img width='600' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/Output/output_model_open_high_low_volume.png"/>
51+
- <img width='600' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/sample/output_model_open_high_low_volume.png"/>
5252

5353
- 只使用「交易量」此特徵來預測「收盤價」。
5454
```py
5555
python Entry.py -open F -high F -low F -vol T -utm F
5656
```
57-
- <img width='600' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/Output/output_model_volume.png"/>
57+
- <img width='600' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/sample/output_model_volume.png"/>
5858

5959
- 使用已訓練過的模型進行預測。
6060
```py
@@ -65,13 +65,13 @@ python Entry.py -open F -high F -low F -vol T -utm T
6565

6666
### A. 資料取得
6767
我透過 [Financial Modeling Prep](https://site.financialmodelingprep.com/) 取得我想預測的標的 NVIDIA ,它需要註冊會員以取得 API key,接著使用日線圖的 API 叫出該 Symbol 歷史資料。另外,我已先將其內容存儲成 json 格式 -> [`NVDA_history_20190225_20240223.json`](/dataset/NVDA_history_20190225_20240223.json)
68-
- <img width='650' height='500' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/Output/NVDA_History_Price.png"/>
68+
- <img width='650' height='500' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/sample/NVDA_History_Price.png"/>
6969

7070
### B. 資料預處理
7171
- 原始資料如下圖所示。
72-
- <img width='400' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/Sample/origin.jpg"/>
72+
- <img width='400' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/sample/origin.jpg"/>
7373
- 將資料範圍大小,規範於 0 至 1 區間,標準化後的資料如下圖所示。
74-
- <img width='430' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/Sample/norm.jpg"/>
74+
- <img width='430' height='450' src="https://github.com/Junwu0615/NVDA-Price-Stock-Prediction/blob/main/sample/norm.jpg"/>
7575
- 接著將資料切割成訓練集 ( 90% ) 和測試集 ( 10% ),任務目標是預測「收盤價」,而其餘特徵都是餵給機器的輸入。
7676
```
7777
x_train = result[:int(number_train), :-1]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Depend/Model.py renamed to package/Model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, obj):
2323
self.use_trained_model = obj.use_trained_model
2424
self.norm_check = ['T', 'True', 't']
2525

26-
file = "./Dataset/NVDA_history_20190225_20240223.json"
26+
file = "./datasets/NVDA_history_20190225_20240223.json"
2727
self.loader = [json.loads(i) for i in open(file, "r")][0]
2828

2929
gpus = tf.config.experimental.list_physical_devices("GPU")
@@ -87,7 +87,7 @@ def origin_status(self):
8787
ax2.legend(loc='upper right')
8888

8989
ax1.tick_params(axis='x', labelrotation=90)
90-
plt.savefig("./Output/NVDA_History_Price.png")
90+
plt.savefig("./sample/NVDA_History_Price.png")
9191
plt.clf()
9292

9393
def normalize(self) -> pd.DataFrame:
@@ -162,12 +162,12 @@ def make_img(self, denorm_pred, denorm_ytest, model_name):
162162
plt.plot(denorm_ytest, color='blue', label='Answer')
163163
plt.legend(loc='best')
164164
# plt.show()
165-
plt.savefig(f"./Output/output_{model_name}.png")
165+
plt.savefig(f"./sample/output_{model_name}.png")
166166
plt.clf()
167167

168168
def main(self):
169-
self.check_folder('./Output')
170-
self.check_folder('./Trained')
169+
self.check_folder('./sample')
170+
self.check_folder('./trained')
171171

172172
if self.use_trained_model in ['T', 'True', 't']:
173173
self.use_trained_model = True
@@ -202,10 +202,10 @@ def main(self):
202202

203203
# 一個batch有128個instance,總共跑50個迭代
204204
if self.use_trained_model:
205-
model = tf.keras.models.load_model(f"./Trained/{model_name}.keras")
205+
model = tf.keras.models.load_model(f"./trained/{model_name}.keras")
206206
else:
207207
model.fit(x_train, y_train, batch_size=128, epochs=200, validation_split=0.1, verbose=1)
208-
model.save(f"./Trained/{model_name}.keras")
208+
model.save(f"./trained/{model_name}.keras")
209209

210210
# 用訓練好的 LSTM 模型對測試資料集進行預測
211211
pred = model.predict(x_test)

0 commit comments

Comments
 (0)