Exemple #1
0
    plt.legend()
    plt.xscale('log')
    plt.show()

    # Linear plot
    plt.plot(c_1, label='eps = .1')
    plt.plot(c_05, label='eps = .05')
    plt.plot(c_01, label='eps = .01')
    plt.legend()
    plt.show()


if __name__ == '__main__':
    m1, m2, m3 = 1.0, 2.0, 3.0
    upper_limit = 10
    eps_1 = run_experiment_eps(m1, m2, m3, 0.1, 100000)
    eps_01 = run_experiment_eps(m1, m2, m3, 0.01, 100000)
    opt = run_experiment(m1, m2, m3, 100000, upper_limit)

    # Log scale plot
    plt.plot(eps_1, label='eps = .1')
    plt.plot(eps_01, label='eps = .01')
    plt.plot(opt, label='optimistic')
    plt.legend()
    plt.xscale('log')
    plt.show()

    # Linear plot
    plt.plot(eps_1, label='eps = .1')
    plt.plot(eps_01, label='eps = .01')
    plt.plot(opt, label='optimistic')
Exemple #2
0
    plt.plot(np.ones(N) * m2)
    plt.plot(np.ones(N) * m3)
    plt.xscale('log')
    plt.show()

    # Print our esimate of each bandits mean and their actual mean
    print('Estimate of mean    Actual mean')
    for bandit in bandits:
        print('{:<20}{}'.format(bandit.mean, bandit.m))

    return cumulative_avg


if __name__ == '__main__':
    m1, m2, m3 = 1.0, 2.0, 3.0
    eps_1 = run_experiment_eps(m1, m2, m3, .1, 100000)
    ucb = run_experiment(m1, m2, m3, 100000)

    # Log scale plot
    plt.plot(eps_1, label='eps = .1')
    plt.plot(ucb, label='UCB')
    plt.legend()
    plt.xscale('log')
    plt.show()

    # Linear plot
    plt.plot(eps_1, label='eps = .1')
    plt.plot(ucb, label='UCB')
    plt.legend()
    plt.show()
        data[i] = x

    cumulative_average = np.cumsum(data) / (np.arange(N) + 1)

    plt.plot(cumulative_average)
    plt.plot(np.ones(N)*m1)
    plt.plot(np.ones(N)*m2)
    plt.plot(np.ones(N)*m3)
    plt.xscale('log')
    plt.show()

    for b in bandits:
        print(b.mean)

    return cumulative_average

if __name__ == '__main__':
    c_1 = run_experiment_eps(1.0, 2.0, 3.0, 0.1, 100000)
    ucb1 = run_experiment(1.0, 2.0, 3.0, 100000)

    plt.plot(c_1, label='eps = 0.1')
    plt.plot(ucb1, label='ucb1')
    plt.legend()
    plt.xscale('log')
    plt.show()

    plt.plot(c_1, label='eps = 0.1')
    plt.plot(ucb1, label='ucb1')
    plt.legend()
    plt.show()
  # plot moving average ctr
  plt.plot(cumulative_average)
  plt.plot(np.ones(N)*m1)
  plt.plot(np.ones(N)*m2)
  plt.plot(np.ones(N)*m3)
  plt.xscale('log')
  plt.show()

  for b in bandits:
    print(b.mean)

  return cumulative_average

if __name__ == '__main__':
  c_1 = run_experiment_eps(1.0, 2.0, 3.0, 0.1, 100000)
  oiv = run_experiment(1.0, 2.0, 3.0, 100000)

  # log scale plot
  plt.plot(c_1, label='eps = 0.1')
  plt.plot(oiv, label='ucb1')
  plt.legend()
  plt.xscale('log')
  plt.show()


  # linear plot
  plt.plot(c_1, label='eps = 0.1')
  plt.plot(oiv, label='ucb1')
  plt.legend()
  plt.show()