df split into train 2c validation 2c test

Solutions on MaxInterview for df split into train 2c validation 2c test by the best coders in the world

showing results for - "df split into train 2c validation 2c test"
Alberto
23 Sep 2016
1In [305]: train, validate, test = \
2              np.split(df.sample(frac=1, random_state=42), 
3                       [int(.6*len(df)), int(.8*len(df))])
4
5In [306]: train
6Out[306]:
7          A         B         C         D         E
80  0.046919  0.792216  0.206294  0.440346  0.038960
92  0.301010  0.625697  0.604724  0.936968  0.870064
101  0.642237  0.690403  0.813658  0.525379  0.396053
119  0.488484  0.389640  0.599637  0.122919  0.106505
128  0.842717  0.793315  0.554084  0.100361  0.367465
137  0.185214  0.603661  0.217677  0.281780  0.938540
14
15In [307]: validate
16Out[307]:
17          A         B         C         D         E
185  0.806176  0.008896  0.362878  0.058903  0.026328
196  0.145777  0.485765  0.589272  0.806329  0.703479
20
21In [308]: test
22Out[308]:
23          A         B         C         D         E
244  0.521640  0.332210  0.370177  0.859169  0.401087
253  0.333348  0.964011  0.083498  0.670386  0.169619
26