AxeldeRomblay / MLBox

MLBox is a powerful Automated Machine Learning python library.
https://mlbox.readthedocs.io/en/latest/
Other
1.49k stars 274 forks source link

TypeError: 'generator' object is not subscriptable #47

Closed NickBuchny closed 6 years ago

NickBuchny commented 7 years ago

When running on a python 3.6 environment in a jupyter notebook, ubuntu 14.04 I get the following:

' from mlbox.preprocessing import from mlbox.optimisation import from mlbox.prediction import *

paths = ["train.csv", "test.csv"] target_name = "target"

data = Reader(sep=",").train_test_split(paths, target_name) #reading

space = {

    'ne__numerical_strategy' : {"space" : [0, 'mean']},

    'ce__strategy' : {"space" : ["label_encoding", "random_projection", "entity_embedding"]},

    'fs__strategy' : {"space" : ["variance", "rf_feature_importance"]},
    'fs__threshold': {"search" : "choice", "space" : [0.1, 0.2, 0.3]},

    'est__strategy' : {"space" : ["XGBoost"]},
    'est__max_depth' : {"search" : "choice", "space" : [5,6]},
    'est__subsample' : {"search" : "uniform", "space" : [0.6,0.9]}

    }

opt = Optimiser(scoring = 'roc_auc', n_folds = 4)

best = opt.optimise(space, data, max_evals = 5)

`

`TypeError Traceback (most recent call last)

in () 16 opt = Optimiser(scoring = 'roc_auc', n_folds = 4) 17 ---> 18 best = opt.optimise(space, data, max_evals = 5) 19 ~/anaconda2/envs/insurance_v2/lib/python3.6/site-packages/mlbox/optimisation/optimiser.py in optimise(self, space, df, max_evals) 565 space=hyper_space, 566 algo=tpe.suggest, --> 567 max_evals=max_evals) 568 569 # Displaying best_params ~/anaconda2/envs/insurance_v2/lib/python3.6/site-packages/hyperopt/fmin.py in fmin(fn, space, algo, max_evals, trials, rstate, allow_trials_fmin, pass_expr_memo_ctrl, catch_eval_exceptions, verbose, return_argmin) 312 313 domain = base.Domain(fn, space, --> 314 pass_expr_memo_ctrl=pass_expr_memo_ctrl) 315 316 rval = FMinIter(algo, domain, trials, max_evals=max_evals, ~/anaconda2/envs/insurance_v2/lib/python3.6/site-packages/hyperopt/base.py in __init__(self, fn, expr, workdir, pass_expr_memo_ctrl, name, loss_target) 784 before = pyll.dfs(self.expr) 785 # -- raises exception if expr contains cycles --> 786 pyll.toposort(self.expr) 787 vh = self.vh = VectorizeHelper(self.expr, self.s_new_ids) 788 # -- raises exception if v_expr contains cycles ~/anaconda2/envs/insurance_v2/lib/python3.6/site-packages/hyperopt/pyll/base.py in toposort(expr) 713 G.add_edges_from([(n_in, node) for n_in in node.inputs()]) 714 order = nx.topological_sort(G) --> 715 assert order[-1] == expr 716 return order 717 `
AxeldeRomblay commented 7 years ago

Hello, Thank you for reporting this issue ! I will have a look !

AxeldeRomblay commented 7 years ago

What happens if you try different parameters ??

alifanov commented 7 years ago

Looks like this https://github.com/hyperopt/hyperopt/issues/325

NickBuchny commented 7 years ago

Yes @alifanov the temp solution to that problem also fixed it for me (just found that today).

@AxeldeRomblay Check out that post.

AxeldeRomblay commented 6 years ago

Thank you @alifanov ! I'll modify setup.py then...

AxeldeRomblay commented 6 years ago

Done !