ScottfreeLLC / AlphaPy

Python AutoML for Trading Systems and Sports Betting
Apache License 2.0
1.11k stars 201 forks source link

Error During save_predictions #39

Open minger88 opened 4 years ago

minger88 commented 4 years ago

Describe the bug Attempting to run the MarketFlow tutorial, the code throws an error after plot generation, during what seems like its attempt to write the data.

To Reproduce Steps to reproduce the behavior:

  1. ~> mflow --train 2019-01-01
  2. ~> mflow --predict 2020-07-21

both train and predict flags seem to exit at the same place.

Expected behavior I expected the code to finish and write out the file to the ./output/ directory

Desktop (please complete the following information):

Traceback [07/20/20 21:06:02] INFO Writing feature map to ./model/feature_map_20200720.pkl [07/20/20 21:06:02] INFO Loading data from ./input/test_20200720.csv Traceback (most recent call last): File "/home/michael/miniconda3/bin/mflow", line 8, in sys.exit(main()) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/market_flow.py", line 430, in main model = market_pipeline(model, market_specs) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/market_flow.py", line 292, in market_pipeline run_analysis(a, lag_period, forecast_period, leaders, predict_history) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/analysis.py", line 270, in run_analysis analysis.model = main_pipeline(model) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/main.py", line 426, in main_pipeline model = training_pipeline(model) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/main.py", line 289, in training_pipeline save_model(model, 'BEST', Partition.test) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/model.py", line 1315, in save_model preds, probas = save_predictions(model, tag, partition) File "/home/michael/miniconda3/lib/python3.7/site-packages/alphapy/model.py", line 1208, in save_predictions pd_indices = pf[pf.date >= predict_date].index.tolist() File "/home/michael/miniconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 5274, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'date'

AlexVaPe commented 2 years ago

Hi, I'm having the same issue and don't know how to run the tutorial example. Is there any solution to this bug?

Thanks

AlexVaPe commented 2 years ago

Hi, I'm having the same issue and don't know how to run the tutorial example. Is there any solution to this bug?

Thanks

I've found that the issue was in model.yml file, on line 8, as it drops the date column, so you have to avoid deleting it and it will not show any error.