Code Monkey home page Code Monkey logo

lex-hue / stock-predictor-v4 Goto Github PK

View Code? Open in Web Editor NEW
23.0 5.0 9.0 152 KB

A reinforcement learning model specialized in stock prediction utilizing deep learning techniques, incorporating reward mechanisms, compatible with any machine equipped with Python.

License: MIT License

Python 81.66% Jupyter Notebook 18.34%
lstm accurate-algorithm ai data-preprocessing reward-functions stock-price-prediction deep-learning machine-learning prediction python

stock-predictor-v4's People

Contributors

lex-hue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

stock-predictor-v4's Issues

Training on each stock

when i put like 80 different stocks and prepare the data , it only take the mean. I think the model would be more efficient if we could train it on every stock that we want and not only on One or the Mean .

sorry if my english is bad . BTW good job with this project . keep going !

Error while running train.py

Hello,

I went with installation 1a on Ubuntu 20.04 LTS. Prepared data like on step 2. Even I selected the same stock BTC.

python3 prepare_data.py run and created the data.csv without a problem.

However I am stuck on step 3. I am getting an error.

2023-04-04 17:07:03.878874: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-04-04 17:07:05.439034: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_2_grad/concat/split_2/split_dim' with dtype int32
[[{{node gradients/split_2_grad/concat/split_2/split_dim}}]]
2023-04-04 17:07:05.440261: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_grad/concat/split/split_dim' with dtype int32
[[{{node gradients/split_grad/concat/split/split_dim}}]]
2023-04-04 17:07:05.441407: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_1_grad/concat/split_1/split_dim' with dtype int32
[[{{node gradients/split_1_grad/concat/split_1/split_dim}}]]
Epoch 1/50
2023-04-04 17:07:05.793970: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_2_grad/concat/split_2/split_dim' with dtype int32
[[{{node gradients/split_2_grad/concat/split_2/split_dim}}]]
2023-04-04 17:07:05.795366: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_grad/concat/split/split_dim' with dtype int32
[[{{node gradients/split_grad/concat/split/split_dim}}]]
2023-04-04 17:07:05.796644: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_1_grad/concat/split_1/split_dim' with dtype int32
[[{{node gradients/split_1_grad/concat/split_1/split_dim}}]]
2023-04-04 17:07:06.328748: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_2_grad/concat/split_2/split_dim' with dtype int32
[[{{node gradients/split_2_grad/concat/split_2/split_dim}}]]
2023-04-04 17:07:06.330149: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_grad/concat/split/split_dim' with dtype int32
[[{{node gradients/split_grad/concat/split/split_dim}}]]
2023-04-04 17:07:06.331417: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_1_grad/concat/split_1/split_dim' with dtype int32
[[{{node gradients/split_1_grad/concat/split_1/split_dim}}]]
43/43 [==============================] - ETA: 0s - loss: nan2023-04-04 17:07:09.669125: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_2_grad/concat/split_2/split_dim' with dtype int32
[[{{node gradients/split_2_grad/concat/split_2/split_dim}}]]
2023-04-04 17:07:09.670382: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_grad/concat/split/split_dim' with dtype int32
[[{{node gradients/split_grad/concat/split/split_dim}}]]
2023-04-04 17:07:09.671529: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_1_grad/concat/split_1/split_dim' with dtype int32
[[{{node gradients/split_1_grad/concat/split_1/split_dim}}]]
2023-04-04 17:07:10.233026: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_2_grad/concat/split_2/split_dim' with dtype int32
[[{{node gradients/split_2_grad/concat/split_2/split_dim}}]]
2023-04-04 17:07:10.234314: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_grad/concat/split/split_dim' with dtype int32
[[{{node gradients/split_grad/concat/split/split_dim}}]]
2023-04-04 17:07:10.235491: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'gradients/split_1_grad/concat/split_1/split_dim' with dtype int32
[[{{node gradients/split_1_grad/concat/split_1/split_dim}}]]
9/9 [==============================] - 1s 17ms/step
Traceback (most recent call last):

File "train.py", line 63, in
history = model.fit(X_train, y_train, epochs=50, batch_size=32, validation_data=(X_test, y_test), callbacks=[rl_callback])
File "/home/test/.local/lib/python3.8/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "train.py", line 24, in on_epoch_end
reward = get_reward(self.y, y_pred)
File "train.py", line 13, in get_reward
acc_score = accuracy_score(y_true, np.round(y_pred))
File "/home/test/.local/lib/python3.8/site-packages/sklearn/utils/_param_validation.py", line 192, in wrapper
return func(*args, **kwargs)
File "/home/test/.local/lib/python3.8/site-packages/sklearn/metrics/_classification.py", line 221, in accuracy_score
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
File "/home/test/.local/lib/python3.8/site-packages/sklearn/metrics/_classification.py", line 88, in _check_targets
type_pred = type_of_target(y_pred, input_name="y_pred")
File "/home/test/.local/lib/python3.8/site-packages/sklearn/utils/multiclass.py", line 381, in type_of_target
_assert_all_finite(data, input_name=input_name)
File "/home/test/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 161, in _assert_all_finite
raise ValueError(msg_err)
ValueError: Input y_pred contains NaN.

I guess it is safe to ignore up until "File "train.py", line 63, in " line. Could you help what is the problem?

Issue running with --eval

Describe the bug
Error getting model eval

To Reproduce
Steps to reproduce the behavior:

git clone https://github.com/Qerim-iseni09/Stock-Predictor-V4.git
cd Stock-Predictor-V4
python SPV4.py --install
python SPV4.py --prepare_data
python SPV4.py --train
python SPV4.py --eval

Expected behavior
In README.md is says it should print out the root mean squared error (RMSE), the MAPE and Total Rewards will be plotted

Desktop (please complete the following information):

  • OS: [e.g. iOS] linux
  • Browser [e.g. chrome, safari] Brave (don't see why this matters'
  • Version [e.g. 22] 3.11.4

Error while train.py: loading "model.h5"

Describe the bug
After epoch stage throw an error:

Traceback (most recent call last):
  File "/****/Stock-Predictor-V4/train.py", line 129, in <module>
    model = load_model("model.h5")
  File "/****/Documents/Stock-Predictor-V4/venv/lib/python3.10/site-packages/keras/saving/saving_api.py", line 212, in load_model
    return legacy_sm_saving_lib.load_model(
  File "/****/Stock-Predictor-V4/venv/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/****/Stock-Predictor-V4/venv/lib/python3.10/site-packages/keras/saving/legacy/save.py", line 230, in load_model
    raise IOError(
OSError: No file or directory found at model.h5

To Reproduce
Steps to reproduce the behavior:

install

  1. create venv python -m venv venv
  2. source ./venv/bin/activate
  3. chmod +x install.sh && ./install.sh
  4. enter sudo password when need

prepare

  1. Donwload csv from yahoo move the file to data/
  2. modify prepare_data.py script from example.csv to my_stock.csv
  3. run python prepare_data.py
  4. run python train.py

Expected behavior
Finish python train.py without an errror

Screenshots
image

Desktop (please complete the following information):

  • OS:6.1.29-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed May 17 14:00:55 UTC 2023 x86_64 GNU/Linux
  • Python: 3.10.10
  • Working directory: Stock-Predictor-V4

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.