def create_cv_id(target, n_folds_ = 5, cv_id_name=cv_id_name, seed=407):
try:
a = StratifiedKFold(target['target'],n_folds=n_folds_, shuffle=True, random_state=seed)
cv_index = a.test_folds
print 'Done StratifiedKFold'
except:
cv_index = np.empty(len(target))
a = KFold(len(target),n_folds=n_folds_, shuffle=True, random_state=seed)
for idx, i in enumerate(a):
cv_index[i[1]] = idx
cv_index = cv_index.astype(int)
print 'Done Kfold'
np.save(INPUT_PATH + cv_id_name, cv_index)
return
######### Utils #########
#feature list????????????util??
评论列表
文章目录