def cv_LinearRegression_Bias( xM, yV):
"""
N_it times iteration is performed for cross_validation in order to make further average effect.
The flag of 'disp' is truned off so each iteration will not shown.
"""
#print( "cv_LinearRegression_None", xM.shape, yV.shape)
X, y = np.array( xM)[:,0], np.array( yV)[:,0]
# only 1-dim is allowed for both X and y
assert (X.ndim == 1) or (X.shape[2] == 1) and (yV.ndim == 1) or (yV.shape[2] == 1)
loo_c = model_selection.LeaveOneOut()
loo = loo_c.split( X)
yP = y.copy()
for train, test in loo:
bias = np.mean(y[train] - X[train])
yP[test] = X[test] + bias
cv_score_le = np.abs( np.array( y - yP)).tolist()
o_d = {'median_abs_err': np.median( cv_score_le),
'mean_abs_err': np.mean( cv_score_le),
'std_abs_err': np.std( cv_score_le), # this can be std(err)
'list': cv_score_le,
'ci': "t.b.d",
'yVp': X.tolist()}
return o_d
评论列表
文章目录