ScottfreeLLC / AlphaPy

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

Can't get --predict working #32

Closed sykesdev closed 4 years ago

sykesdev commented 4 years ago

Hi,

Firstly, really great project! There's an awful lot here, enjoying getting my head around it, although feel like I might need a bigger head! :-D

I'm running into this issue, and being mostly a java developer, and taking into account that no-one else is complaining, I'm struggling to understand if this is a limitation of my python knowledge or a genuine bug.

running the following...

cd Trading\ Model/
mflow
mflow --predict --pdate 2020-05-13

I get the following...

[05/13/20 10:06:23] INFO    Original Features : Index(['abovema_10[1]', 'abovema_20[1]', 'abovema_3[1]', 'abovema_5[1]',
       'abovema_50[1]', 'adx[1]', 'atr[1]', 'atr_10[1]', 'atr_14[1]',
       'atr_20[1]',
       ...
       'wr_2[1]', 'wr_3[1]', 'wr_5[1]', 'wr_6[1]', 'wr_7[1]', 'gap',
       'gapbadown', 'gapbaup', 'gapdown', 'gapup'],
      dtype='object', length=149)
[05/13/20 10:06:23] INFO    Feature Count     : 149
[05/13/20 10:06:23] INFO    Creating Base Features
Traceback (most recent call last):
  File "/usr/local/bin/mflow", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/alphapy/market_flow.py", line 430, in main
    model = market_pipeline(model, market_specs)
  File "/usr/local/lib/python3.6/site-packages/alphapy/market_flow.py", line 292, in market_pipeline
    run_analysis(a, lag_period, forecast_period, leaders, predict_history)
  File "/usr/local/lib/python3.6/site-packages/alphapy/analysis.py", line 270, in run_analysis
    analysis.model = main_pipeline(model)
  File "/usr/local/lib/python3.6/site-packages/alphapy/__main__.py", line 424, in main_pipeline
    model = prediction_pipeline(model)
  File "/usr/local/lib/python3.6/site-packages/alphapy/__main__.py", line 351, in prediction_pipeline
    X_all = create_features(model, X_all, X_train, X_predict, y_train)
  File "/usr/local/lib/python3.6/site-packages/alphapy/features.py", line 1049, in create_features
    features, fnames = get_text_features(fnum, fname, X, nunique, vectorize, ngrams_max)
  File "/usr/local/lib/python3.6/site-packages/alphapy/features.py", line 418, in get_text_features
    min_length = int(feature.str.len().min())
  File "/usr/local/lib/python3.6/site-packages/pandas/core/generic.py", line 5269, in __getattr__
    return object.__getattribute__(self, name)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/accessor.py", line 187, in __get__
    accessor_obj = self._accessor(obj)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/strings.py", line 2039, in __init__
    self._inferred_dtype = self._validate(data)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/strings.py", line 2096, in _validate
    raise AttributeError("Can only use .str accessor with string values!")
AttributeError: Can only use .str accessor with string values!

I'm running this in a docker env based on python:3.6-stretch with the following requirements.txt...

bokeh==1.3
ipython==7.2
keras-applications==1.0.8
keras-preprocessing==1.0.5
keras==2.2.4
matplotlib==3.0
numpy==1.18.4
pandas==1.0
pyyaml==5.1
scikit-learn==0.22.1
scipy==1.4.1
seaborn==0.9
tensorflow==1.15
xgboost==0.90
arrow==0.13
category_encoders==2.1
iexfinance==0.4.3
imbalanced-learn==0.5
pandas-datareader==0.8
pyfolio==0.9
joblib==0.14.1
alphapy==2.4.2
sykesdev commented 4 years ago

Here's a fuller set of requirements via pip freeze in case they're of use to anyone :-)

Unfortunately still seeing the same error though.

absl-py==0.9.0
alphapy==2.4.2
arrow==0.15.6
astor==0.7.1
attrs==19.3.0
backcall==0.1.0
bleach==3.1.5
blinker==1.4
bokeh==2.0.1
brotlipy==0.7.0
cachetools==3.1.1
category-encoders==2.2.2
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==7.1.2
cryptography==2.9.2
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
empyrical==0.5.3
entrypoints==0.3
gast==0.2.2
google-auth==1.14.3
google-auth-oauthlib==0.4.1
google-pasta==0.2.0
grpcio==1.27.2
h5py==2.10.0
idna==2.9
iexfinance==0.4.3
imbalanced-learn==0.5.0
importlib-metadata==1.6.0
ipykernel==5.2.1
ipython==7.14.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.17.0
Jinja2==2.11.2
joblib==0.14.1
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.3
jupyter-console==6.1.0
jupyter-core==4.6.3
Keras==2.3.1
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.2.0
lxml==4.5.0
Mako==1.1.0
Markdown==3.2.2
MarkupSafe==1.1.1
matplotlib==3.2.1
mistune==0.8.4
nbconvert==5.6.1
nbformat==5.0.6
notebook==6.0.3
numpy==1.18.4
oauthlib==3.0.1
olefile==0.46
opt-einsum==3.2.1
packaging==20.1
pandas==1.0.3
pandas-datareader==0.8.1
pandocfilters==1.4.2
parso==0.7.0
patsy==0.5.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==7.1.2
prometheus-client==0.7.1
prompt-toolkit==3.0.5
protobuf==3.11.3
ptyprocess==0.6.0
pyasn1==0.4.8
pyasn1-modules==0.2.7
pycparser==2.20
pyfolio==0.9.2
Pygments==2.6.1
PyJWT==1.7.1
pyOpenSSL==19.1.0
pyparsing==2.4.7
PyQt5==5.12.3
PyQt5-sip==4.19.18
PyQtChart==5.12.0
PyQtWebEngine==5.12.1
pyrsistent==0.16.0
PySocks==1.7.1
python-dateutil==2.8.1
pytz==2020.1
PyYAML==5.3.1
pyzmq==19.0.1
qtconsole==4.7.3
QtPy==1.9.0
requests==2.23.0
requests-oauthlib==1.2.0
rsa==4.0
scikit-learn==0.22.1
scipy==1.4.1
seaborn==0.10.1
Send2Trash==1.5.0
six==1.14.0
statsmodels==0.11.1
tensorboard==2.1.1
tensorflow==2.1.0
tensorflow-estimator==2.1.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
Theano==1.0.4
threadpoolctl==2.0.0
tornado==6.0.4
traitlets==4.3.3
typing-extensions==3.7.4.2
urllib3==1.25.9
wcwidth==0.1.9
webencodings==0.5.1
Werkzeug==1.0.1
widgetsnbextension==3.5.1
wrapt==1.12.1
xgboost==0.90
zipp==3.1.0
mrconway commented 4 years ago

Thanks, we'll take a look.

mrconway commented 4 years ago

This is a duplicate of #33 for fixing Pandas string accessors in files features.py and transforms.py.