ScottfreeLLC / AlphaPy

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

Error in importing BalanceCascade from imblearn.ensemble #38

Closed toko-stephen-leo closed 3 years ago

toko-stephen-leo commented 4 years ago

Describe the bug ImportError: cannot import name 'BalanceCascade' from 'imblearn.ensemble' (/opt/conda/lib/python3.7/site-packages/imblearn/ensemble/init.py)

To Reproduce Steps to reproduce the behavior:

  1. Following instructions from here: https://alphapy.readthedocs.io/en/latest/tutorials/kaggle.html
  2. Running step 2 (alphapy) throws the following error. Seems like there is no BalanceCascade in imblearn

Expected behavior No error thrown.

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

Additional context Not sure what I'm doing wrong. Googled the imblearn package and they dont seem to have a BalanceCascade class in ensemble: https://github.com/scikit-learn-contrib/imbalanced-learn/blob/master/imblearn/ensemble/__init__.py Any help is appreciated!

sykesdev commented 4 years ago

Stephen,

Not sure if this will help you, but it took me ages to get a set of dependencies to play nicely together, here's what I ended up with (using conda), hope it's useful...

name: alphapy

channels:
 - conda-forge

dependencies:
- python=3.6
- bokeh>=1.3
- ipython>=7.2
- keras>=2.2
- matplotlib>=3.0
- numpy>=1.17
- pandas>=1.0
- pyyaml>=5.0
- scikit-learn==0.22.1
- scipy>=1.1
- seaborn>=0.9
- tensorflow>=1.15
- pip:
  - arrow>=0.13
  - category_encoders>=2.1
  - iexfinance>=0.4.3
  - imbalanced-learn==0.5
  - pandas-datareader>=0.8
  - pyfolio==0.9.0
  - xgboost==0.90
toko-stephen-leo commented 4 years ago

Thank you for your response. Creating a new conda environment with the above dependencies does seem to solve the initial problem but runs into another problem with imblearn as below. Any ideas on this?

Traceback (most recent call last):
  File "/opt/conda/envs/alphapy/bin/alphapy", line 5, in <module>
    from alphapy.__main__ import main
  File "/opt/conda/envs/alphapy/lib/python3.6/site-packages/alphapy/__main__.py", line 29, in <module>
    from alphapy.data import get_data
  File "/opt/conda/envs/alphapy/lib/python3.6/site-packages/alphapy/data.py", line 44, in <module>
    from imblearn.combine import SMOTEENN
  File "/opt/conda/envs/alphapy/lib/python3.6/site-packages/imblearn/__init__.py", line 37, in <module>
    from . import keras
  File "/opt/conda/envs/alphapy/lib/python3.6/site-packages/imblearn/keras/__init__.py", line 4, in <module>
    from ._generator import BalancedBatchGenerator
  File "/opt/conda/envs/alphapy/lib/python3.6/site-packages/imblearn/keras/_generator.py", line 59, in <module>
    class BalancedBatchGenerator(*ParentClass):
TypeError: duplicate base class Sequence

image

minger88 commented 4 years ago

I just pulled this repository to play around with. I had the same problem. After digging around, it seemed like there were related issues with imblearn on other programs ... they can be solved by importing the entire module rather than the specific method. Changing data.py to solved this problem for me.

import imblearn.ensemble #from imblearn.ensemble import BalanceCascade #from imblearn.ensemble import EasyEnsemble

Note that I also had to make a similar change in plot.py by importing sklearn.ensemble rather than the two partial_dependence methods.

mrconway commented 3 years ago

Fixed in 2.4.3