MCPcopy Index your code
hub / github.com/clips/pattern / evaluations

Function evaluations

pattern/vector/svm/liblinearutil.py:50–77  ·  view source on GitHub ↗

evaluations(ty, pv) -> (ACC, MSE, SCC) Calculate accuracy, mean squared error and squared correlation coefficient using the true values (ty) and predicted values (pv).

(ty, pv)

Source from the content-addressed store, hash-verified

48 liblinear.save_model(model_file_name.encode(), model)
49
50def evaluations(ty, pv):
51 """
52 evaluations(ty, pv) -> (ACC, MSE, SCC)
53
54 Calculate accuracy, mean squared error and squared correlation coefficient
55 using the true values (ty) and predicted values (pv).
56 """
57 if len(ty) != len(pv):
58 raise ValueError("len(ty) must equal to len(pv)")
59 total_correct = total_error = 0
60 sumv = sumy = sumvv = sumyy = sumvy = 0
61 for v, y in zip(pv, ty):
62 if y == v:
63 total_correct += 1
64 total_error += (v-y)*(v-y)
65 sumv += v
66 sumy += y
67 sumvv += v*v
68 sumyy += y*y
69 sumvy += v*y
70 l = len(ty)
71 ACC = 100.0*total_correct/l
72 MSE = total_error/l
73 try:
74 SCC = ((l*sumvy-sumv*sumy)*(l*sumvy-sumv*sumy))/((l*sumvv-sumv*sumv)*(l*sumyy-sumy*sumy))
75 except:
76 SCC = float('nan')
77 return (ACC, MSE, SCC)
78
79def train(arg1, arg2=None, arg3=None):
80 """

Callers 2

trainFunction · 0.70
predictFunction · 0.70

Calls 2

lenFunction · 0.85
zipFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…