train 2ctest 2cdev python

Solutions on MaxInterview for train 2ctest 2cdev python by the best coders in the world

showing results for - "train 2ctest 2cdev python"
Veronica
25 Jan 2019
1import numpy as np
2import pandas as pd
3
4def train_validate_test_split(df, train_percent=.6, validate_percent=.2, seed=None):
5    np.random.seed(seed)
6    perm = np.random.permutation(df.index)
7    m = len(df.index)
8    train_end = int(train_percent * m)
9    validate_end = int(validate_percent * m) + train_end
10    train = df.iloc[perm[:train_end]]
11    validate = df.iloc[perm[train_end:validate_end]]
12    test = df.iloc[perm[validate_end:]]
13    return train, validate, test