當前位置: 首頁>>代碼示例>>Python>>正文


Python Parallel.idxmin方法代碼示例

本文整理匯總了Python中joblib.Parallel.idxmin方法的典型用法代碼示例。如果您正苦於以下問題:Python Parallel.idxmin方法的具體用法?Python Parallel.idxmin怎麽用?Python Parallel.idxmin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在joblib.Parallel的用法示例。


在下文中一共展示了Parallel.idxmin方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Parallel

# 需要導入模塊: from joblib import Parallel [as 別名]
# 或者: from joblib.Parallel import idxmin [as 別名]
	output = pd.concat([output_aic, output_bic], axis = 0)    
	
	return output

best_aic = {}
best_bic = {}
	
for spec in ['abccare', 'abc', 'care']:
	selection = Parallel(n_jobs=1)(
		delayed(model_select)(data, yvar, bank, spec) for yvar in outcomes.index) 
	selection = pd.concat(selection, axis=0)
	selection.sort_index(inplace=True)

	# estimate rankings by AIC and BIC
	selection = selection.rank(axis=1).groupby(level=0).sum()
	best = selection.idxmin(axis = 1)
	model_list = list(itertools.chain.from_iterable([itertools.combinations(bank, 3)]))
	best_aic["{}".format(spec)] = model_list[selection.idxmin(axis = 1)[0]]
	best_bic["{}".format(spec)] = model_list[selection.idxmin(axis = 1)[1]]

	print 'Best AIC:', ('R', 'male', 'abc') + best_aic['{}'.format(spec)]
	print 'Best BIC:', ('R', 'male', 'abc') + best_bic['{}'.format(spec)]

record = open('best_controls.txt', 'wb')
        
record.write('ABCCARE Best AIC: {} \n\n'.format(' '.join(('R', 'male', 'abc') + best_aic['abccare'])))
record.write('ABCCARE Best BIC: {}'.format(' '.join(('R', 'male', 'abc') + best_bic['abccare'])))
record.write('ABC Best AIC: {} \n\n'.format(' '.join(('R', 'male') + best_aic['abc'])))
record.write('ABC Best BIC: {}'.format(' '.join(('R', 'male') + best_bic['abc'])))
record.write('CARE Best AIC: {} \n\n'.format(' '.join(('R', 'male') + best_aic['care'])))
record.write('CARE Best BIC: {}'.format(' '.join(('R', 'male') + best_bic['care'])))
開發者ID:jorgelgarcia,項目名稱:abc-treatmenteffects-finalseason,代碼行數:33,代碼來源:controls_selection.py


注:本文中的joblib.Parallel.idxmin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。