<commit_before># -*- coding: utf-8 -*-
from database import TextDb
from value import ModelScorer
from othello import Board

import math
import numpy as np

def evaluate(db, model):
    directions = [(False, False), (False, True), (True, False), (True, True)]

    s = 0.0
    n = 0.0
    for d1,d2 in directions:
        for moves, result in db.xgames(d1, d2):
            if np.random.rand() > 0.1:
                continue
            b = Board()
            for p, r, c in moves:
                b.flip(r, c, p)
                s += (model(b) - result) * (model(b) - result)
                n += 1.0
    return (n, math.sqrt(s/n))

if __name__ == '__main__':
    model = ModelScorer()
    model.load("/Users/qiyiping/Projects/qiyiping/othello/model/model.cpt.npy")<commit_msg>update evaluate.py<commit_after># -*- coding: utf-8 -*-
from database import TextDb
from value import ModelScorer
from othello import Board

import math
import numpy as np

def evaluate(db, model):
    s = 0.0
    n = 0.0
    for moves, result in db.games:
        if np.random.rand() > 0.1:
            continue
        b = Board()
        for p, r, c in moves:
            b.flip(r, c, p)
            s += (model(b) - result) * (model(b) - result)
            n += 1.0
    return (n, math.sqrt(s/n))

if __name__ == '__main__':
    model = ModelScorer()
    model.load("/Users/qiyiping/Projects/qiyiping/othello/model/model.cpt.npy")
{'fraction_non_alphanumeric': 0.13861386138613863, 'fraction_numerical': 0.015558698727015558, 'mean_word_length': 2.0561555075593954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2701965', 'n_tokens_mistral': 508, 'n_tokens_neox': 488, 'n_words': 142}