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


Python Parallel.to_pickle方法代码示例

本文整理汇总了Python中joblib.Parallel.to_pickle方法的典型用法代码示例。如果您正苦于以下问题:Python Parallel.to_pickle方法的具体用法?Python Parallel.to_pickle怎么用?Python Parallel.to_pickle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在joblib.Parallel的用法示例。


在下文中一共展示了Parallel.to_pickle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Attriters

# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import to_pickle [as 别名]
10. ABC Attriters (main sample)
11. ABC Post Attrition (main sample)
'''

for comparison in ['TC','AC'] :
    if comparison == 'TC': # comparing treatment against control
        data_pre = abccare.copy()
    if comparison == 'AC': # comparing ABC against CARE (so R = 1 if CARE, now)
        data_pre = abccare.copy()
        data_pre.loc[:, 'R'] = 1 - data_pre.loc[:, 'abc']
    
    for cohort in [0, 8]:
        if cohort == 0:
            data = data_pre
        if cohort == 7:
            data = data_pre.drop(crime_attrit, axis=0)
        if cohort == 8:   
            data = data_pre.loc[data_pre.si34y_complete==1]
    
        
        rslt = Parallel(n_jobs=1)(
        	delayed(diff_by_sex)(data, s, i) for i,s in samples.iterrows())
        rslt = pd.concat(rslt, axis=0, keys=range(len(rslt)), names=['draw'])
        
        if cohort == 0:    
            rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_{}.pkl'.format(comparison)))
        if cohort == 7:
            rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_crime_{}.pkl'.format(comparison)))
        if cohort == 8:
            rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_health_{}.pkl'.format(comparison)))
开发者ID:jorgelgarcia,项目名称:abc-treatmenteffects-finalseason,代码行数:32,代码来源:bootstrap.py

示例2: Parallel

# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import to_pickle [as 别名]
        data = abccare
    if cohort in [1,2,3,4]:
        data = abccare.loc[abccare.cohort == cohort]
    if cohort == 7:
        data = abccare.drop(crime_attrit, axis=0)
    if cohort == 8:   
        data = abccare.loc[abccare.si34y_complete==1]
    if cohort == 10:
        data = abccare.copy()
        data.R= 0
        data.loc[attriters, 'R'] = 1
    if cohort == 11:
        data = abccare.drop(attriters, axis=0)
    
    rslt = Parallel(n_jobs=1)(
    	delayed(diff_by_sex)(data, s, i) for i,s in samples.iterrows())
    rslt = pd.concat(rslt, axis=0, keys=range(len(rslt)), names=['draw'])
    
    if cohort == 0:    
        rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance.pkl'))
    if cohort in [1,2,3,4]:
        rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_coh{}.pkl'.format(cohort)))
    if cohort == 7:
        rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_crime.pkl'))
    if cohort == 8:
        rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_health.pkl'))
    if cohort == 10:
        rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_attrition.pkl'))
    if cohort == 11:
        rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_postattrition.pkl'))
开发者ID:jorgelgarcia,项目名称:abc-treatmenteffects-finalseason,代码行数:32,代码来源:bootstrap.py

示例3: Parallel

# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import to_pickle [as 别名]
     RV_s = 2
     
 if RV == 1:
     data_pre = abccare.copy()
     data_pre.drop(data_pre.loc[(data_pre.R==1)].index, inplace=True)
     data_pre.loc[:, 'R'] = data_pre.loc[:, 'RV']
     RV_s = 1
     
 for cohort in [0, 5, 6, 8]:
 
     if cohort == 0:
         data = data_pre
     if cohort in [5,6]:
         data = data_pre.loc[data_pre.cohort == cohort]
     if cohort == 7:
         data = data_pre.drop(crime_attrit, axis=0)
     if cohort == 8:   
         data = data_pre.loc[data_pre.si34y_complete==1]
     
     rslt = Parallel(n_jobs=1)(
     	delayed(diff_by_sex)(data, s, i) for i,s in samples.iterrows())
     rslt = pd.concat(rslt, axis=0, keys=range(len(rslt)), names=['draw'])
     
     if cohort == 0:    
         rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_{}.pkl'.format(RV_s)))
     if cohort in [5,6]:
         rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_coh{}_{}.pkl'.format(cohort, RV_s)))
     if cohort == 7:
         rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_crime_{}.pkl'.format(RV_s)))
     if cohort == 8:
         rslt.to_pickle(os.path.join(paths.rslt, 'bootstrap_balance_health_{}.pkl'.format(RV_s)))
开发者ID:jorgelgarcia,项目名称:abc-treatmenteffects-finalseason,代码行数:33,代码来源:bootstrap.py


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