Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

df split into train, validation, test

In [305]: train, validate, test = 
              np.split(df.sample(frac=1, random_state=42), 
                       [int(.6*len(df)), int(.8*len(df))])

In [306]: train
Out[306]:
          A         B         C         D         E
0  0.046919  0.792216  0.206294  0.440346  0.038960
2  0.301010  0.625697  0.604724  0.936968  0.870064
1  0.642237  0.690403  0.813658  0.525379  0.396053
9  0.488484  0.389640  0.599637  0.122919  0.106505
8  0.842717  0.793315  0.554084  0.100361  0.367465
7  0.185214  0.603661  0.217677  0.281780  0.938540

In [307]: validate
Out[307]:
          A         B         C         D         E
5  0.806176  0.008896  0.362878  0.058903  0.026328
6  0.145777  0.485765  0.589272  0.806329  0.703479

In [308]: test
Out[308]:
          A         B         C         D         E
4  0.521640  0.332210  0.370177  0.859169  0.401087
3  0.333348  0.964011  0.083498  0.670386  0.169619
Comment

PREVIOUS NEXT
Code Example
Python :: how to use assert in python 
Python :: np.arrange 
Python :: If elif else 
Python :: scipy check normal distribution 
Python :: use a csv file on internet as an api in python 
Python :: self in python 
Python :: isoformat datetime python 
Python :: how to join tables in python 
Python :: list pakages installed in python 
Python :: models in django 
Python :: pandas como quitar comillas simples de una columna 
Python :: add a tuple to a dictionary python 
Python :: python convert bytes to string 
Python :: table in sqlite python 
Python :: manage python environment in jupyterlab 
Python :: how to stop thread python 
Python :: python for loop index 
Python :: how to install ffmpeg_streaming in python 
Python :: activate virtual environment 
Python :: comtypes python 
Python :: how to find the longest string python 
Python :: Group by a column, count sum of other columns 
Python :: matrix diagonal sum leetcode 
Python :: appending items to a tuple python 
Python :: python min key 
Python :: read list stored as a string with pandas read csv 
Python :: python captcha bypass 
Python :: convert string to int dataframe column 
Python :: check audio playing on windows python 
Python :: python encode file 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =