30 lines
615 B
Python
30 lines
615 B
Python
import re
|
|
import os
|
|
import math
|
|
|
|
prawdziwe = []
|
|
przewidziane = []
|
|
|
|
|
|
def wrozka(line):
|
|
f = open("test","w")
|
|
f.write(line)
|
|
f.close()
|
|
return float(os.popen("vw -i model_ai test -p /dev/stdout --quiet").read())
|
|
|
|
|
|
def ocena(praw,prze):
|
|
bledy = 0.0
|
|
for n in range(len(praw)):
|
|
bledy += math.fabs(praw[n]-prze[n])
|
|
return bledy/float(len(praw))
|
|
|
|
|
|
file = open("development", "r")
|
|
for n in file:
|
|
reg = re.search(r"^([0-9]+)( *|-*)([^0-9].*)", n)
|
|
prawdziwe.append(float(reg.group(1)))
|
|
przewidziane.append(wrozka(reg.group(3)))
|
|
file.close()
|
|
|
|
print(ocena(prawdziwe, przewidziane)) |