def validate(self,tr,add_feat_tr): feats = build_feat(tr, add_feat_tr, window_length=self.window_length) feat_target = get_target(tr,window_length=self.window_length) net0,feats,feat_target = self.fit(tr,add_feat_tr) pred = clf.predict_feat(feats[0],net0,add_feat_tr,new_append_value=0,\ window_length = self.window_length,lags = len(add_feat_tr)-1) mse_error = clf.MSE(pred,feat_target.reshape(len(pred),).tolist()) return mse_error
def interpolate(self): if len(self.add_feat_pred)/10<=2: tr = np.asarray(self.tr) add_feat_tr = np.asarray(self.add_feat_tr) add_feat_pred = np.asarray(self.add_feat_pred) else: tr = np.asarray(downsampling(self.tr,len(self.tr)/10)).T[1] add_feat_tr = np.asarray(downsampling(self.add_feat_tr,len(self.add_feat_tr)/10)).T[1] add_feat_pred = np.asarray(downsampling(self.add_feat_pred,len(self.add_feat_pred)/10)).T[1] print len(tr),len(add_feat_tr),len(add_feat_pred) net0,feats,feat_target=self.fit(tr,add_feat_tr) pred_res = clf.predict_feat(feats[-1],net0,add_feat_pred,new_append_value=0,\ window_length = self.window_length,lags = len(add_feat_pred)) if len(self.add_feat_pred)/10>2: pred_res = upsampling(pred_res,upscale = len(self.add_feat_pred)) if self.trend==1: pred_res += self.trend_clf(tr,len(add_feat_pred)) return pred_res