当前位置: 首页>>代码示例>>Python>>正文


Python Parallel.merge方法代码示例

本文整理汇总了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
开发者ID:liyi-1989,项目名称:pydownscale,代码行数:49,代码来源:downscale.py


注:本文中的joblib.Parallel.merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。