nmharmon8 / StockMarketGAN

Stock Market Prediction Using Unsupervised Features
53 stars 26 forks source link

train_xgb_boost - TypeError: Expected sequence or array-like, got <class 'map'> #1

Closed sunsetcoder closed 6 years ago

sunsetcoder commented 7 years ago

[869] train-mlogloss:0.114465 test-mlogloss:0.101589 [870] train-mlogloss:0.114394 test-mlogloss:0.101616 [871] train-mlogloss:0.114329 test-mlogloss:0.101662 Stopping. Best iteration: [771] train-mlogloss:0.119164 test-mlogloss:0.101021

Traceback (most recent call last):

File "", line 1, in runfile('D:/StockMarketGAN-master/train_xgb_boost.py', wdir='D:/StockMarketGAN-master')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/StockMarketGAN-master/train_xgb_boost.py", line 98, in boost_model.train()

File "D:/StockMarketGAN-master/train_xgb_boost.py", line 92, in train cm = confusion_matrix(self.test_labels, map(lambda x: int(x[1] > .5), clf.predict(test)))

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\metrics\classification.py", line 240, in confusion_matrix y_type, y_true, y_pred = _check_targets(y_true, y_pred)

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\metrics\classification.py", line 72, in _check_targets check_consistent_length(y_true, y_pred)

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 177, in check_consistent_length lengths = [_num_samples(X) for X in arrays if X is not None]

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 177, in lengths = [_num_samples(X) for X in arrays if X is not None]

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 122, in _num_samples type(x))

TypeError: Expected sequence or array-like, got <class 'map'>

sunsetcoder commented 7 years ago

Would really appreciate if you could advise me on the sequence of which scripts to run. Is it:

  1. get_stock_data.py
  2. train_gan
  3. train_cnn (the training seems to be in an infinite loop after 15hrs running, but it's already saved some models in the cnn_models directory)
  4. train_xgb_boost.py ?

The train_cnn.py seems to never end as the steps will never break the loop (2099...2199 .... the condition for it per the code is when the modulus is 0 but it will never be 0).

Thanks!

nmharmon8 commented 6 years ago

I am finishing adding some new updates. Once I get them up I will add run instructions.

nmharmon8 commented 6 years ago

I have added instructions on how to run. Let me know if you have any difficulties. You will note the results do not look as good as before. I had a bug with the indexing and was leaking data. I will add a script to get daily predictions, but need to clean up the code a bit.