# Path: insults/util.py
# def make_sure_path_exists(path):
# def data_file(category, name=None):
# def data_directory(category):
# def log_file(name):
# def save_folds(folds):
# def saved_folds():
# def save_model( clf, location=SAVEFILE_LOCATION ):
# def load_model( location=SAVEFILE_LOCATION, model_filename=MODEL_FILENAME):
# def get_parser():
# def tied_rank(x):
# def auc(actual, posterior):
# def score():
# SAVEFILE_LOCATION = "models/stored/"
# MODEL_FILENAME = "insult_classifier.joblib.pkl"
# 
# Path: insults/pipeline.py
# def make_pipeline(options):
#     vect = ('vect', feature_extraction.text.CountVectorizer(lowercase=False,
#                                                             analyzer='char',
#                                                             ngram_range=(1, 5)))
#     tfidf = ('tfidf', feature_extraction.text.TfidfTransformer(sublinear_tf=True, norm='l2'))
#     clf = ("clf",InsultsSGDRegressor(alpha=options.sgd_alpha,
#                                      penalty=options.sgd_penalty,
#                                      learning_rate='constant',
#                                      eta0=options.sgd_eta0,
#                                      max_iter=options.sgd_max_iter,
#                                      n_iter_per_step=options.sgd_n_iter_per_step))
# 
#     return InsultsPipeline([vect, tfidf, clf])


import pandas
import numpy as np
import os
import itertools
import logging
import argparse
import sys
import concurrent.futures
from sklearn import model_selection
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from insults.util import (data_file,
                          data_directory,
                          log_file,
                          save_folds,
                          saved_folds,
                          argsets,
                          auc,
                          score,
                          save_model,
                          get_parser)
from insults.pipeline import make_pipeline
            submission.to_csv(arguments.predictions, index=False)
            logging.info('Saved %s' % arguments.predictions)

    save_model(clf) # Save the classifier
    logging.info("Finished predictions")


def run_prediction(parser=None, args_in=None, production=False):
    """
    Either pick up the arguments from the command line or use the
    ones pre-packaged for the script.
    """
    global train
    global test_examples

    if production:
        logging.info('Running prepackaged arguments (%r)' % args_in)
        arguments = parser.parse_args(args_in)
    else:
        logging.info('Using arguments from command line %r' % args_in)
        arguments = args_in

    train,test_examples = initialize(arguments)
    if arguments.tune:
        folds = tuning(arguments)
        save_folds(folds)
    else:
        folds = saved_folds()
    predict(folds,arguments)
    if arguments.score:

# Path: insults/util.py
# def make_sure_path_exists(path):
# def data_file(category, name=None):
# def data_directory(category):
# def log_file(name):
# def save_folds(folds):
# def saved_folds():
# def save_model( clf, location=SAVEFILE_LOCATION ):
# def load_model( location=SAVEFILE_LOCATION, model_filename=MODEL_FILENAME):
# def get_parser():
# def tied_rank(x):
# def auc(actual, posterior):
# def score():
# SAVEFILE_LOCATION = "models/stored/"
# MODEL_FILENAME = "insult_classifier.joblib.pkl"
# 
# Path: insults/pipeline.py
# def make_pipeline(options):
#     vect = ('vect', feature_extraction.text.CountVectorizer(lowercase=False,
#                                                             analyzer='char',
#                                                             ngram_range=(1, 5)))
#     tfidf = ('tfidf', feature_extraction.text.TfidfTransformer(sublinear_tf=True, norm='l2'))
#     clf = ("clf",InsultsSGDRegressor(alpha=options.sgd_alpha,
#                                      penalty=options.sgd_penalty,
#                                      learning_rate='constant',
#                                      eta0=options.sgd_eta0,
#                                      max_iter=options.sgd_max_iter,
#                                      n_iter_per_step=options.sgd_n_iter_per_step))
# 
#     return InsultsPipeline([vect, tfidf, clf])


# Path: insults/train.py
import pandas
import numpy as np
import os
import itertools
import logging
import argparse
import sys
import concurrent.futures
from sklearn import model_selection
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from insults.util import (data_file,
                          data_directory,
                          log_file,
                          save_folds,
                          saved_folds,
                          argsets,
                          auc,
                          score,
                          save_model,
                          get_parser)
from insults.pipeline import make_pipeline

            submission.to_csv(arguments.predictions, index=False)
            logging.info('Saved %s' % arguments.predictions)

    save_model(clf) # Save the classifier
    logging.info("Finished predictions")


def run_prediction(parser=None, args_in=None, production=False):
    """
    Either pick up the arguments from the command line or use the
    ones pre-packaged for the script.
    """
    global train
    global test_examples

    if production:
        logging.info('Running prepackaged arguments (%r)' % args_in)
        arguments = parser.parse_args(args_in)
    else:
        logging.info('Using arguments from command line %r' % args_in)
        arguments = args_in

    train,test_examples = initialize(arguments)
    if arguments.tune:
        folds = tuning(arguments)
        save_folds(folds)
    else:
        folds = saved_folds()
    predict(folds,arguments)
    if arguments.score:

        score()