train_model.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:kaggle-right-whale 作者: felixlaumon 项目源码 文件源码
def train_test_split(X, y, test_size=0.25, random_state=42, stratify=True):
    if stratify:
        n_folds = int(round(1 / test_size))
        sss = StratifiedKFold(y, n_folds=n_folds, random_state=random_state)
    else:
        sss = ShuffleSplit(len(y), test_size=test_size, random_state=random_state)
    train_idx, test_idx = iter(sss).next()
    return X[train_idx], X[test_idx], y[train_idx], y[test_idx]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号