def disRe(par,lnd_cho,X,Y,Xtst=None,Ytst = None): mu_tr = pln_ebeding(par[0],X,lnd_cho) kernel = GaussianKernel(float(par[1])) if Xtst is None: beta = kernel.ridge_regress(mu_tr,Y,par[2]) else: mu_tt = pln_ebeding(par[0],Xtst,lnd_cho) if Ytst is None: beta,prdt = kernel.ridge_regress(mu_tr,Y,par[2],mu_tt) else: beta,prdt,mse = kernel.ridge_regress(mu_tr,Y,par[2], mu_tt, Ytst) return beta,prdt,np.sqrt(mse)
def disRe_corc(par,eta,lnd_cho,X,Y,Xtst = None,Ytst = None): mu_tr,sigma_tr = bag_cor(par[0],eta,X,lnd_cho) kernel = GaussianKernel(float(par[1])) if Xtst is None: beta = kernel.ridge_regress(mu_tr,Y,par[2]) else: mu_tt,sigma_tt = bag_cor(par[0],eta,Xtst,lnd_cho) if Ytst is None: beta,prdt = kernel.ridge_regress(mu_tr,Y,par[2],mu_tt) else: beta,prdt,mse = kernel.ridge_regress(mu_tr,Y,par[2],mu_tt,Ytst) return beta,prdt,np.sqrt(mse)
def err_pre(xs,ys,xt,yt,sgma = 1.0,lamda = 0.1): kernel = GaussianKernel(float(sgma)) aa,y_pre,err_pre0 = kernel.ridge_regress(xs,ys,lamda,Xtst=xt,ytst=yt) return y_pre,err_pre0