def explained_variance(ypred,y):
assert y.ndim == <NUM_LIT:1> and ypred.ndim == <NUM_LIT:1><EOL>vary = np.var(y)<EOL>return np.nan if vary==<NUM_LIT:0> else <NUM_LIT:1> - np.var(y-ypred)/vary<EOL>
Computes fraction of variance that ypred explains about y.
Returns 1 - Var[y-ypred] / Var[y]

interpretation:
    ev=0  =>  might as well have predicted zero
    ev=1  =>  perfect prediction
    ev<0  =>  worse than just predicting zero