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
usage of identity in cross-validation #40
Comments
All solvers we use expect to get a single number for each evaluation of an objective function (which is constructed via cross-validation in your case). The identity aggregator constructs a list of all results, which causes this error. The identity aggregator is mainly intended for other uses than you have now, for instance in the outer cross-validation procedure of a nested cross-validation setup. At this point I am not entirely sure what your intentions are: when you are optimizing hyperparameters you really need to return a single number for every set of hyperparameters that is tried. Note that you already get a trace of all objective function evaluations (that is the overall cross-validation score) in the return values of If you want to retain scores for each fold, you will need to modify optunity internally. I can make a quick code example if you like. |
I'd like to keep track of the scores obtained during the model selection in order to estimate the variance of the scores as a function of the hyper-parameters values. However, even like that, I would get only num_evals data points, i.e. the number of iterations configured in the "optimizer". I'd like anyway to get at least the points for each CV iteration. So, yes, if it is not a problem for you, some lines of code would be welcome. |
You can now freely return all fold-wise information during cross-validation. Solvers now have an extra layer between objective function evaluations and actually using the return value. If your objective function returns an indexable, it's first element is used in optimization. You can see an example of how to use this feature in bin/examples/python/advanced_cv.py, which returns the full cross-validation results. If this is not what you were looking for, please do let me know so I can reopen this issue. PS: you will need to update optunity from git to get the new feature. |
thanks for the update. Now it even works with a self-provided aggregator. Here is the one I have defined FYI. It computes mean,std,min and max for a list of list of scores, and provides as first element, the score to be used by the optimizer. ´´´ |
Glad to hear it is working! The current solution allows pretty much every use case I can think of, but feel free to let us know if there are still any remaining issues. |
I am getting the following error by setting the aggregator option to opt.cross_validation.identity
Here is my code
The objective is to keep track of all the scores from the various folds. Is it a bug? or am I using incorrectly the API ?
Thanks in advance
The text was updated successfully, but these errors were encountered: