rsteca / sklearn-deap

Use evolutionary algorithms instead of gridsearch in scikit-learn
MIT License
771 stars 131 forks source link

ZeroDivisionError: float division by zero #18

Closed arnaudsj closed 7 years ago

arnaudsj commented 7 years ago

Anybody got this error before? `/home/ubuntu/anaconda2/envs/python3/lib/python3.5/site-packages/evolutionary_search/init.py in _evalFunction(individual, name_values, X, y, scorer, cv, iid, fit_params, verbose, error_score) 98 score += _score 99 n_test += 1 --> 100 score /= float(n_test) 101 score_cache[paramkey] = score 102

ZeroDivisionError: float division by zero`

Here is my EASC call:

gscv = EvolutionaryAlgorithmSearchCV(estimator=KnnDtw(), params=param_grid, scoring="f1_weighted", cv=StratifiedKFold(n_splits=10, shuffle=False, random_state=SEED).split(X["eda"], y), verbose=1, population_size=50, gene_mutation_prob=0.10, gene_crossover_prob=0.5, tournament_size=3, generations_number=5, n_jobs=-1)

ryanpeach commented 7 years ago

Can you print what was in n_test before?

ryanpeach commented 7 years ago

I got it, if you scroll up a bit and format the code properly, lines 98 and 99 are nested in an if statement. It never adds anything to n_test, because the length of your test set is 0.

We may want to add an assertion error for this.

This issue can be closed.