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

Join trials? #1

Open
mosscoder opened this issue Dec 15, 2020 · 1 comment
Open

Join trials? #1

mosscoder opened this issue Dec 15, 2020 · 1 comment

Comments

@mosscoder
Copy link

I'm interested in using this package to perform a parallel search and then join trials. This is demonstrated here in native python/hyperopt.

Would you have any time to demonstrate trials joining in the hopticulate wrapper? Joining an arbitrary number of trials would also be helpful.

@nfultz
Copy link
Contributor

nfultz commented Dec 15, 2020

Because of differences between how Python and R implement iterables, this is somewhat fiddly. Here is a corresponding MWE:

> trials1 = Trials(); trials2 = Trials();
> best = fmin(objective, space, algo=tpe.suggest, max_evals=100, trials=trials1)
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100.0 [00:00<00:00, 245.05trial/s, best loss: 0.0025786775660636965]
> best = fmin(objective, space, algo=tpe.suggest, max_evals=100, trials=trials2)
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100.0 [00:00<00:00, 284.47trial/s, best loss: 0.0006141434774347515]
> itertools <- reticulate::import("itertools")
> trials_from_docs <- hopticulate:::hyperopt$trials_from_docs
> joined <- trials_from_docs(itertools$chain( trials1$`__iter__`(), trials2$`__iter__`()   ))
> length(joined$trials)
[1] 200

Notes:

  • trials_from_docs is not package-visible in hopticulate right now, but is available on the hyperopt object.
  • using itertools to chain the iterators manually
    • reticulate does not seem to have an iter function ?
    • Using list() from R does not seem to delegate to the objects' __iter__ method either.
  • Differences in special characters between the two languages require backquoting in the R code

If you get parallelization working, please let me know what strategy you take. I would be curious if there are any interactions between the parallel package and reticulate.

EDIT:

I think the above is ugly, so I've posted this question on SO as well - https://stackoverflow.com/questions/65312460/concatenate-two-python-objects-using-reticulate

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

2 participants