コード例 #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)
コード例 #2
0
import pandas as pd
from plots import EloPlot
import numpy as np

data = np.array(
    pd.read_csv("outputs/Best-5000/csv/NNAgent4Best-5000-EloOverTime.csv",
                header=None))[0, :]

with EloPlot(title=f'The Very Best',
             saves=[f'GoodPlots/BestSingle.png']) as plt:
    plt.plot(data, label='The Best', color='#4CAF50')
    plt.ylim((900, 2520))
    plt.doPrint = True

data = np.array(
    pd.read_csv("outputs/Fruit-5000/csv/NNAgent15Fruit-5000-EloOverTime.csv",
                header=None))[0, :]

with EloPlot(title=f'The Very Best Fruit',
             saves=[f'GoodPlots/BestSingleFruit.png'],
             CR=False,
             CRP=False) as plt:
    plt.plot(data, label='The Best Fruit', color='#4CAF50')
    plt.doPrint = True
    plt.axhline(y=1480.4,
                color='#E91E63',
                lw=1,
                label='CleverRandom+probs',
                zorder=1)
    plt.axhline(y=1289.0,
                color='#9C27B0',
コード例 #3
0
ファイル: Lamd0-9.py プロジェクト: FredslundMagnus/Myretuen
from plots import EloPlot, Data
import numpy as np

l = [('LAMBDA-0.9_DISCOUNT-0.01', 'discount=0.01, lambda=0.9', '#9C27B0'), ('LAMBDA-0.9_DISCOUNT-0.1', 'discount=0.1, lambda=0.9', '#2196F3'), ('LAMBDA-0.9_DISCOUNT-0.5', 'discount=0.5, lambda=0.9', '#4CAF50'), ('LAMBDA-0.9_DISCOUNT-0.9', 'discount=0.9, lambda=0.9', '#F44336'), ('LAMBDA-0.9_dISCOUNT-0.99', 'Discount=0.99, lambda=0.9', '#228B22')]

with EloPlot(title=f'Lambda and discount - lambda - 0.9', saves=[f'GoodPlots/LambdaDiscountLAMBD09.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)
コード例 #4
0
from plots import EloPlot, Data
import numpy as np

l = [('CleverRandomElo-fruit-CalcProb', 'CleverRandom+probs', '#E91E63'),
     ('CleverRandomElo-fruit', 'CleverRandom', '#9C27B0')]

with EloPlot(title=f'Clever Random - Fruit',
             saves=[f'GoodPlots/CleverRandomFruit.png'],
             CR=False,
             CRP=False) 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]

        theData = EloOverTime[0, 1000:, :]
        m = theData.mean()
        sd = theData.std() / np.sqrt(theData.size) * 1.96
        print(
            f'{name}: mean = {m:.6}    ,    95% = [{(m-sd):.6}, {(m+sd):.6}]      Calculated from {theData.shape[1]} samples.'
        )

        plt.varPlot(plt, EloOverTime, name, color)
コード例 #5
0
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)
コード例 #6
0
from plots import EloPlot, Data
import numpy as np

l = [('Best-2000', 'Explorer 2000', '#2196F3'),
     ('Best-5000', 'Explorer 5000', '#4CAF50')]

with EloPlot(title=f'The Best - Elo Rating',
             saves=[f'GoodPlots/BestNoFruit.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]

        theData = EloOverTime[0, 10000:, :]
        m = theData.mean()
        sd = theData.std() / np.sqrt(theData.size) * 1.96
        print(
            f'{name}: mean = {m:.6}    ,    95% = [{(m-sd):.6}, {(m+sd):.6}]      Calculated from {theData.shape[1]} samples.'
        )

        plt.varPlot(plt, EloOverTime, name, color)
コード例 #7
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)
コード例 #8
0
for chooser in ['random', 'weighted']:
    selfplay = 50
    l = [(f'NN-Selfplay-{selfplay}-{chooser}-lr=0.0002-K=2000', 'No Impala',
          '#673ab7'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-50-20', 'NN 50 20',
          '#9C27B0'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-100-10', 'NN 100 10',
          '#2196F3'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-200-5', 'NN 200 5',
          '#4CAF50'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-500-2', 'NN 500 20',
          '#795548'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-1000-1', 'NN 1000 1',
          '#ffeb3b')]

    with EloPlot(title=f'Chooserfunction, selfplay={selfplay} - Elo Rating',
                 saves=[f'GoodPlots/Impala-{chooser}-1000.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)

for chooser in ['random', 'weighted']:
    selfplay = 50
    l = [(f'NN-Selfplay-{selfplay}-{chooser}-lr=0.0002-K=2000-calcprobs',
          'No Impala', '#673ab7'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-50-20-calcprobs',
          'NN 50 20', '#9C27B0'),
         (f'NN-Selfplay-{selfplay}-{chooser}-impala-20-20-100-10-calcprobs',
          'NN 100 10', '#2196F3'),
コード例 #9
0
from plots import EloPlot, Data
import numpy as np

l = [('CleverRandomEloCalcProb', 'CleverRandom+probs', '#E91E63'), ('CleverRandomElo', 'CleverRandom', '#9C27B0')]

with EloPlot(title=f'Clever Random - Elo Rating', saves=[f'GoodPlots/CleverRandom.png'], CR=False, CRP=False) 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]

        theData = EloOverTime[0, 1000:, :]
        m = theData.mean()
        sd = theData.std() / np.sqrt(theData.size) * 1.96
        print(f'{name}: mean = {m:.6}    ,    95% = [{(m-sd):.6}, {(m+sd):.6}]      Calculated from {theData.shape[1]} samples.')

        plt.varPlot(plt, EloOverTime, name, color)
コード例 #10
0
from plots import EloPlot, Data

l = [('4000-Abs', 'Absolut Error', '#2196F3'),
     ('4000-MME', 'Mean Squared Error', '#4CAF50')]

with EloPlot(title=f'Cost function - Elo Rating',
             saves=[f'GoodPlots/Costfunction.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)
コード例 #11
0
from plots import EloPlot, Data, colors
import numpy as np

dropouts = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
l = [(f'Dropout-{dropout}', f'Dropout {dropout}', colors[i])
     for i, dropout in enumerate(dropouts)]

with EloPlot(title=f'Dropout', saves=[f'GoodPlots/Dropout.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)
コード例 #12
0
from plots import EloPlot, Data
import numpy as np

l = [('4000-Dis-0-lamd-0', 'Discount=0, lambda=0', '#9C27B0'),
     ('4000-Dis-1-lamd-0', 'Discount=1, lambda=0', '#2196F3'),
     ('4000-Dis-0-lamd-1', 'Discount=0, lambda=1', '#4CAF50'),
     ('4000-Dis-1-lamd-1', 'Discount=1, lambda=1', '#F44336')]

with EloPlot(title=f'Lambda and Discount - Elo Rating',
             saves=[f'GoodPlots/LambdaDiscount.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)
コード例 #13
0
from plots import EloPlot, Data

for selfplay in [20, 50, 100]:

    l = [(f'NN-Selfplay-{selfplay}-weighted-lr=0.0002', 'Weighted Chooser',
          '#9C27B0'),
         (f'NN-Selfplay-{selfplay}-random-lr=0.0002', 'Random Chooser',
          '#2196F3'),
         (f'NN-Selfplay-{selfplay}-incremental-lr=0.0002',
          'Incremental Chooser', '#4CAF50')]

    with EloPlot(title=f'Chooserfunction, selfplay={selfplay} - Elo Rating',
                 saves=[f'GoodPlots/Chooser-{selfplay}.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)

for selfplay in [20, 50, 100]:

    l = [(f'NN-Selfplay-{selfplay}-weighted-lr=0.0002-K=2000',
          'Weighted Chooser', '#9C27B0'),
         (f'NN-Selfplay-{selfplay}-random-lr=0.0002-K=2000', 'Random Chooser',
          '#2196F3'),
         (f'NN-Selfplay-{selfplay}-incremental-lr=0.0002-K=2000',
          'Incremental Chooser', '#4CAF50')]

    with EloPlot(
            title=f'Chooserfunction, selfplay={selfplay}, K=2000 - Elo Rating',
コード例 #14
0
from plots import EloPlot, Data
import numpy as np

l = [('Fruit-2000', 'Fruit - Explorer 2000', '#2196F3'),
     ('Fruit-5000', 'Fruit - Explorer 5000', '#4CAF50')]

with EloPlot(title=f'The Fruit - Elo Rating',
             saves=[f'GoodPlots/BestFruit.png'],
             CR=False,
             CRP=False) 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]

        theData = EloOverTime[0, 10000:, :]
        m = theData.mean()
        sd = theData.std() / np.sqrt(theData.size) * 1.96
        print(
            f'{name}: mean = {m:.6}    ,    95% = [{(m-sd):.6}, {(m+sd):.6}]      Calculated from {theData.shape[1]} samples.'
        )

        plt.varPlot(plt, EloOverTime, name, color)
    plt.axhline(y=1480.4,
                color='#E91E63',
                lw=1,
                label='CleverRandom+probs',
                zorder=1)
    plt.axhline(y=1289.0,
                color='#9C27B0',