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

add minimum number of points parameter to AverageLearner #273

Closed
basnijholt opened this issue May 14, 2020 · 0 comments · Fixed by #274
Closed

add minimum number of points parameter to AverageLearner #273

basnijholt opened this issue May 14, 2020 · 0 comments · Fixed by #274

Comments

@basnijholt
Copy link
Member

basnijholt commented May 14, 2020

The AverageLearner samples a random

Like in #143 we should have an argument

    min_seeds_per_point : int, default 3
        Minimum amount of values per point. This means that the
        standard error of a point is infinity until there are
        'min_seeds_per_point' for a point.

Right now, it can happen that 2 consecutive sampling events happen to be the same up to some very small precision, resulting in a converged learner.

For example, in my case I sampled 2000 AverageLearners until convergence, most of them sampled ~3000 times except for this one:

image

The problem can be demonstrated using the following code.

Find a seed that produces two numbers that are close

for i in range(10_000_000):
    random.seed(i)
    r1 = random.random()
    r2 = random.random()
    if abs(r1 - r2) < 1e-7:
        break

random.seed(i)
print(i)

3317884

Then

random.seed(3317884)

def f(_):
    return random.random()

learner = adaptive.AverageLearner(f, rtol=0.01, atol=0.01)
adaptive.runner.simple(learner, goal=lambda l: l.loss() < 1)
print(learner.npoints, learner.data)

2 {0: 0.6232189044314053, 1: 0.6232188298033593}

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

Successfully merging a pull request may close this issue.

1 participant