<commit_before>from sklearn.cross_validation import train_test_split
import numpy as np
from csv2arrays import csv2arrays
__author__ = 'ronny'


def csv2train_test(file, y_col=None, test=0.3,
           sep=",",
           skip_header=0, skip_footer=0,
           missing_values={"NA", "NAN", "N/A"},
           filling_values=np.nan,
           seed=None):
    data = csv2arrays(file=file, y_col=y_col, shuffle=False,
               sep=sep,
               skip_header=skip_header, skip_footer=skip_footer,
               missing_values=missing_values,
               filling_values=filling_values,<commit_msg>Add docstring to csv2train_test()<commit_after>from sklearn.cross_validation import train_test_split
import numpy as np
from csv2arrays import csv2arrays
__author__ = 'ronny'


# ==============================================================================
#                                                                 CSV2TRAIN_TEST
# ==============================================================================
def csv2train_test(file, y_col=None, test=0.3,
           sep=",",
           skip_header=0, skip_footer=0,
           missing_values={"NA", "NAN", "N/A"},
           filling_values=np.nan,
           seed=None):
    """
    Takes a csv file and creates a tuple of arrays containing the data.
        X_train, Y_train, X_test, Y_test
    or if no y_col is specified, then:
        X_train, X_test

    NOTE: The rows are automatically shuffled.

    :param file: {string}
        file path to the csv file
    :param y_col: {int}(default=None)
        The column in the data containing the output labels. If this file
        doesnt contain any output labels, then use None.
    :param test: {float greater than 0.0 and less than 1.0}(default=0.3)
        proportion of the data to assign to the test set.
    :param sep: {str}(default=",")
        delimiter used to separate columns.
    :param skip_header: {int}(default=0)
        Skip this many rows from the top
    :param skip_footer: {int}(default=0)
        Skip this many rows from the end.
    :param missing_values: {set of strings} (default={"NA", "NAN", "N/A"})
        The set of characters to recognise as missing values
    :param filling_values: (default = np.nan)
        what to replace missing values with.
    :param seed: {int or None}(default = None)
        Set the random seed if you want reproducible results
    :return: {tuple of numpy arrays}
        If a y_col is specified, then it returns
            X_train, Y_train, X_test, Y_test
        Otherwise it returns:
            X_train, X_test
    """
    # ==========================================================================
    data = csv2arrays(file=file, y_col=y_col, shuffle=False,
               sep=sep,
               skip_header=skip_header, skip_footer=skip_footer,
               missing_values=missing_values,
               filling_values=filling_values,
{'fraction_non_alphanumeric': 0.15809199318568995, 'fraction_numerical': 0.008858603066439524, 'mean_word_length': 2.7023959646910467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7637199', 'n_tokens_mistral': 845, 'n_tokens_neox': 796, 'n_words': 249}