本文整理汇总了Python中joblib.Parallel.merge方法的典型用法代码示例。如果您正苦于以下问题:Python Parallel.merge方法的具体用法?Python Parallel.merge怎么用?Python Parallel.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类joblib.Parallel
的用法示例。
在下文中一共展示了Parallel.merge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: predict
# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import merge [as 别名]
def predict(self, test_set=True, location=None):
Y, self.locations = self.data.get_y(location=location)
t = self.data.observations['time'].values
t = self._split_dataset(t, test_set=test_set)
Y = self._split_dataset(Y, test_set=test_set)
yhat_jobs = []
ytrue =[]
yoccur_jobs = []
if not self.nearest_neighbor:
X = self.data.get_X()
X = self._split_dataset(X, test_set=test_set)
if self.xtransform is not None:
X = self.xtrans.transform(X)
for j, row in self.locations.iterrows():
if self.nearest_neighbor:
X = self.data.get_nearest_X(row[self.data.reanalysis_latdim],
row[self.data.reanalysis_londim])
X = self._split_dataset(X, test_set=test_set)
if self.xtransform is not None:
X = self.xtrans[j].transform(X)
if self.conditional is not None:
yoccur_jobs += [delayed(worker_predict_prob)(self.occurance_models[j], copy.deepcopy(X))]
yhat_jobs += [delayed(worker_predict)(self.models[j], copy.deepcopy(X))]
ytrue += [Y[:, j]]
yhat = Parallel(n_jobs=self.num_proc)(yhat_jobs)
if self.ytransform is not None:
transform_jobs = [delayed(worker_invtrans)(self.ytrans[j], yhat[j]) for j in
range(len(yhat))]
yhat = Parallel(n_jobs=self.num_proc)(transform_jobs)
yhat = numpy.vstack(yhat).T
ytrue = numpy.vstack(ytrue).T
yhat = self.to_xarray(yhat, t).rename({"value": "projected"})
ytrue = self.to_xarray(ytrue, t).rename({"value": "ground_truth"})
if self.conditional is not None:
yoccur = Parallel(n_jobs=self.num_proc)(yoccur_jobs)
yoccur = numpy.vstack(yoccur).T > 0.5
yoccur = self.to_xarray(yoccur, t).rename({"value": "occurance"})
yhat['projected'] = yhat['projected']*yoccur['occurance']
yhat = yhat.merge(yoccur)
out = yhat.merge(ytrue)
out['error'] = out.projected - out.ground_truth
return out