def train_test_val_split(X, y, test_size=0.2, val_size=0.1):
    """Performs 2 successive train_test_splits to produce a training, testing, and validation dataset"""
    from sklearn.model_selection import train_test_split
    if val_size == 0:
        X_train, X_test, y_train, y_test = train_test_split(X, y, test_size
            =test_size)
        return X_train, X_test, y_train, y_test
    else:
        first_split_size = test_size + val_size
        second_split_size = val_size / (test_size + val_size)
        X_train, X_test_val, y_train, y_test_val = train_test_split(X, y,
            test_size=first_split_size)
        X_test, X_val, y_test, y_val = train_test_split(X_test_val,
            y_test_val, test_size=second_split_size)
        return X_train, X_test, X_val, y_train, y_test, y_val
