當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。