Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine Learning/Query Optimization example TypeError: logger() got an unexpected keyword argument 'curr_min_score' #385

Open
llermaly opened this issue Nov 22, 2021 · 0 comments

Comments

@llermaly
Copy link

Hello, I'm trying to run the optimization query of the Machine Learning/Query Optimization example and I'm getting this error:

Using configuration
 - metric: {
  "mean_reciprocal_rank": {
    "k": 100,
    "relevant_rating_threshold": 1
  }
}
 - selected method: bayesian
 - default params: {}
/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/elasticsearch/connection/base.py:209: ElasticsearchWarning: Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.15/security-minimal-setup.html to enable security.
  warnings.warn(message, category=ElasticsearchWarning)
Traceback (most recent call last):
  File "bin/optimize-query", line 84, in <module>
    main()
  File "bin/optimize-query", line 71, in main
    args.template_id, queries, qrels, logger)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/qopt/optimize.py", line 223, in optimize_query
    return optimize(config, objective_fn, initial_points=None, logger_fn=logger_fn)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/qopt/optimize.py", line 265, in optimize
    x0=initial_points)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/optimizer/gp.py", line 268, in gp_minimize
    callback=callback, n_jobs=n_jobs, model_queue_size=model_queue_size)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/optimizer/base.py", line 304, in base_minimize
    if eval_callbacks(callbacks, result):
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/utils.py", line 99, in eval_callbacks
    decision = c(result)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/qopt/optimize.py", line 176, in __call__
    params=params)
TypeError: logger() got an unexpected keyword argument 'curr_min_score'

real	0m0.988s
user	0m0.927s
sys	0m0.271s

This is the method that failes

    def logger(iteration, total_iterations, score, _, duration, params):
        print(f"   - iteration {iteration}/{total_iterations} ({duration:.04f}s) scored {score:.04f} with: {json.dumps(params)}")

If I replace the "_" with curr_min_score then throws a different error:

 - iteration 39/75 (0.0159s) scored 1.0000 with: {"tie_breaker": 0.5699173276454137, "title.english|boost": 4.3273304062411615, "title|boost": 1.6393208127999483, "category|boost": 0.9826987511047194, "category.english|boost": 9.580933015419806, "descriptors|boost": 3.503736851987736, "file_name|boost": 8.566968785271335, "vendor_name|boost": 1.757893690628294, "snippet|boost": 7.494445295285921, "snippet.english|boost": 4.513989505981226, "assetId|boost": 7.035638672539559, "operator": "OR"}
Traceback (most recent call last):
  File "bin/optimize-query", line 84, in <module>
    main()
  File "bin/optimize-query", line 71, in main
    args.template_id, queries, qrels, logger)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/qopt/optimize.py", line 223, in optimize_query
    return optimize(config, objective_fn, initial_points=None, logger_fn=logger_fn)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/qopt/optimize.py", line 265, in optimize
    x0=initial_points)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/optimizer/gp.py", line 268, in gp_minimize
    callback=callback, n_jobs=n_jobs, model_queue_size=model_queue_size)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/optimizer/base.py", line 302, in base_minimize
    result = optimizer.tell(next_x, next_y)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/optimizer/optimizer.py", line 493, in tell
    return self._tell(x, y, fit=fit)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/optimizer/optimizer.py", line 536, in _tell
    est.fit(self.space.transform(self.Xi), self.yi)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/skopt/learning/gaussian_process/gpr.py", line 195, in fit
    super(GaussianProcessRegressor, self).fit(X, y)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/sklearn/gaussian_process/_gpr.py", line 234, in fit
    self.kernel_.bounds))]
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/sklearn/gaussian_process/_gpr.py", line 503, in _constrained_optimization
    bounds=bounds)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/_minimize.py", line 618, in minimize
    callback=callback, **options)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/lbfgsb.py", line 308, in _minimize_lbfgsb
    finite_diff_rel_step=finite_diff_rel_step)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 262, in _prepare_scalar_function
    finite_diff_rel_step, bounds, epsilon=epsilon)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/_differentiable_functions.py", line 76, in __init__
    self._update_fun()
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/_differentiable_functions.py", line 166, in _update_fun
    self._update_fun_impl()
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/_differentiable_functions.py", line 73, in update_fun
    self.f = fun_wrapped(self.x)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/_differentiable_functions.py", line 70, in fun_wrapped
    return fun(x, *args)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 74, in __call__
    self._compute_if_needed(x, *args)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 68, in _compute_if_needed
    fg = self.fun(x, *args)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/sklearn/gaussian_process/_gpr.py", line 225, in obj_func
    theta, eval_gradient=True, clone_kernel=False)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/sklearn/gaussian_process/_gpr.py", line 476, in log_marginal_likelihood
    alpha = cho_solve((L, True), y_train)  # Line 3
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/scipy/linalg/decomp_cholesky.py", line 194, in cho_solve
    b1 = asarray_chkfinite(b)
  File "/home/gllermaly/examples/Machine Learning/Query Optimization/venv/lib/python3.6/site-packages/numpy/lib/function_base.py", line 486, in asarray_chkfinite
    "array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs

It fails in the iteration number 39 , and num_initial_points is set to 40 as the default , num_iterations set to 70

Any advice would be appreciated.

@llermaly llermaly changed the title TypeError: logger() got an unexpected keyword argument 'curr_min_score' Machine Learning/Query Optimization example TypeError: logger() got an unexpected keyword argument 'curr_min_score' Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant