()
Set asside data for validation
Set asside data for validation
Set asside data for validation
def preprocess_partition_data():
    """Set asside data for validation"""
    answers = open(NEWS_FILE_NAME_SPLIT).read().decode('utf-8').split("\n")
    print('shuffle', end=" ")
    random_shuffle(answers)
    print("Done")
    # Explicitly set apart 10% for validation data that we never train over
    split_at = len(answers) - len(answers) // 10
    with open(NEWS_FILE_NAME_TRAIN, "wb") as output_file:
        output_file.write("\n".join(answers[:split_at]).encode('utf-8'))
    with open(NEWS_FILE_NAME_VALIDATE, "wb") as output_file:
        output_file.write("\n".join(answers[split_at:]).encode('utf-8'))
def preprocess_partition_data ( ) : answers = open ( NEWS_FILE_NAME_SPLIT ) . read ( ) . decode ( 'utf-8' ) . split ( "\n" ) print ( 'shuffle' , end = " " ) random_shuffle ( answers ) print ( "Done" ) # Explicitly set apart 10% for validation data that we never train over split_at = len ( answers ) - len ( answers ) // 10 with open ( NEWS_FILE_NAME_TRAIN , "wb" ) as output_file : output_file . write ( "\n" . join ( answers [ : split_at ] ) . encode ( 'utf-8' ) ) with open ( NEWS_FILE_NAME_VALIDATE , "wb" ) as output_file : output_file . write ( "\n" . join ( answers [ split_at : ] ) . encode ( 'utf-8' ) )