Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
609 B
2
Indexable
Never
# Preparando discursos de training y test
import shutil
from sklearn.model_selection import train_test_split
def SepararDiscursosTrainYtest(test_size=0.25):
    shutil.rmtree(PATH+'Train', ignore_errors=True)
    shutil.rmtree(PATH+'Test', ignore_errors=True)
    X = y = os.listdir(PATH)
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size, random_state=0)
    os.mkdir(PATH+'Train')
    os.mkdir(PATH+'Test')
    for x in X_train:
        shutil.copyfile(PATH+x, PATH+'Train/'+x)
    for x in X_test:
        shutil.copyfile(PATH+x, PATH+'Test/'+x)
SepararDiscursosTrainYtest()