Beispiel #1
0
from plots import EloPlot, Data
import numpy as np

for discount in [0.5, 0.75, 0.95]:

    l = [(f'SL-discount-{discount}-NoTrain-alpha-0.000003', 'Simple Linear',
          '#9C27B0'),
         (f'LA-discount-{discount}-NoTrain-alpha-0.000001',
          'Linear Approximation', '#2196F3'),
         (f'NN-discount-{discount}-NoTrain-lr-0.0002', 'Neural Network',
          '#4CAF50')]

    with EloPlot(title=f'Agents, discount={discount} - Elo Rating3',
                 saves=[f'GoodPlots/Agents-{discount}.png']) as plt:
        for EloOverTime, name, agent, color in Data(
            [f".\\outputs\\{a[0]}\\csv" for a in l],
                colors=[a[2] for a in l],
                elo=False):
            name = [a[1] for a in l if a[0] == name][0]
            plt.varPlot(plt, EloOverTime, name, color)
Beispiel #2
0
from plots import EloPlot, allDirs, Data

maxi, maxiplot = 0, None
for Elo, EloOverTime, name, agent, color in Data(allDirs()):
    with EloPlot(xlabel='Players',
                 title=f'{name} - Elo Rating',
                 saves=[
                     f'plots/EloRating/' + f'{name}' + '.png',
                     f'outputs/{name}/' + f'{name} - Elo Rating' + '.png'
                 ]) as plt:
        plt.varPlot(plt, Elo, agent, color)

    with EloPlot(
            title=f'{name} - Elo Rating over Time',
            saves=[
                f'plots/EloRatingOverTime/' + f'{name}' + '.png',
                f'outputs/{name}/' + f'{name} - Elo Rating over Time' + '.png'
            ]) as plt:
        plt.varPlot(plt, EloOverTime, agent, color)
        # plt.maxPlot(plt, EloOverTime, agent, color)

    try:
        temp = EloOverTime.max()
        if temp > maxi:
            maxi, maxiplot = temp, name
    except:
        pass

print(maxi, maxiplot)
from plots import EloPlot, Data

with EloPlot(title=f'Probability - Elo Rating',
             saves=[f'GoodPlots/Probability.png']) as plt:
    for EloOverTime, name, agent, color in Data([
            ".\\outputs\\4000-calcprob-True\\csv",
            ".\\outputs\\4000-calcprob-false\\csv"
    ],
                                                colors=['#4CAF50', '#2196F3'],
                                                elo=False):
        name = 'NNAgent+probs' if name == '4000-calcprob-True' else 'NNAgent'
        plt.varPlot(plt, EloOverTime, name, color)
l, d = 'LAMBDA-', '_DISCOUNT-'
files, vs, lamds, diss, mini, maxi = [], {}, set(), set(), float(
    'inf'), -float('inf')
for x in xs:
    vs[x] = {}

for filename in allDirs():
    if l in filename and d in filename:
        files.append(filename)


def meanAround(data, x, width=10):
    return data[0, x - width:x + width, :].mean()


for EloOverTime, name, agent, color in Data(files, elo=False):
    lamb = find_number(name, l)
    dis = find_number(name, d)
    lamds.add(lamb)
    diss.add(dis)
    for x in xs:
        val = meanAround(EloOverTime, x)
        vs[x][(lamb, dis)] = meanAround(EloOverTime, x)
        mini = val if val < mini else mini
        maxi = val if val > maxi else maxi

labdas = np.array(list(sorted(lamds, reverse=True)))
discounts = np.array(list(sorted(diss)))

for x, values in vs.items():
    heat = np.zeros((len(labdas), len(discounts)))