produvia / kryptos

Kryptos AI is a virtual investment assistant that manages your cryptocurrency portfolio
http://twitter.com/kryptos_ai
MIT License
48 stars 8 forks source link

Error when generating classification report #91

Open treethought opened 6 years ago

treethought commented 6 years ago

When running strat -ml xgboost with the following (or any) config

"trading": {
      "EXCHANGE": "bitfinex",
      "ASSET": "btc_usd",
      "DATA_FREQ": "daily",
      "HISTORY_FREQ": "1d",
      "CAPITAL_BASE": 5000,
      "BASE_CURRENCY": "usd",
      "START": "2015-04-01",
      "END": "2018-06-07",
      "BARS": 50,
      "ORDER_SIZE": 0.5,
      "SLIPPAGE_ALLOWED": 0.05

No trades are made and I receive the following error:

 File "/Users/cam/.local/share/virtualenvs/kryptos-Q_28oakj/lib/python3.6/site-packages/catalyst/algorithm.py", line 486, in analyze
    self._analyze(self, perf)
  File "/Users/cam/produvia/kryptos/kryptos/platform/strategy/strategy.py", line 327, in _analyze
    i.analyze(self.name)
  File "/Users/cam/produvia/kryptos/kryptos/platform/strategy/indicators/ml.py", line 109, in analyze
    classification_metrics(namespace, file_name, self.results_real, self.results_pred)
  File "/Users/cam/produvia/kryptos/kryptos/platform/utils/ml/metric.py", line 14, in classification_metrics
    f.write(classification_report(y_true, y_pred, target_names=target_names))
  File "/Users/cam/.local/share/virtualenvs/kryptos-Q_28oakj/lib/python3.6/site-packages/sklearn/metrics/classification.py", line 1457, in classification_report
    np.average(p, weights=s),
  File "/Users/cam/.local/share/virtualenvs/kryptos-Q_28oakj/lib/python3.6/site-packages/numpy/lib/function_base.py", line 1158, in average
    "Weights sum to zero, can't be normalized")
ZeroDivisionError: Weights sum to zero, can't be normalized

I think this may be related to #22, regarding the pandas dependency mismatch.

When I checkout 70349dca5d472fb7e02476981f516afb053508c7, and restore the repo dependencies to the commit before tsfresh was added, the error does not occur and trading works again.

We may need to disable tsfresh functionality until https://github.com/enigmampc/catalyst/issues/388 is resolved as it breaks our dependencies.

treethought commented 6 years ago

Until we can resolve the dependency issues, I have created a new branch ml-tsfresh which includes the latest changes made by @bukosabino (commits 70349dc to 085c6cee22c8ef46f7cd9989f386b4312b2e90da). I then reverted those commits on the develop branch, so that development can proceed without dependency issues.

@bukosabino I realize not all of those commits are directly related to tsfresh. We can selectively merge in certain commits.

bukosabino commented 6 years ago

I save some changes on ml-tsfresh branch (hyperopt, tsfresh and fbprophet).

We need to wait for zipline or catalyst update pandas requirements: https://github.com/enigmampc/catalyst/issues/269

We can continue working while they work on this issue.