Example #1
0
def main() -> None:
    input_dir, judgement_year, dividing_point = parse_arguments()
    files_to_be_processed = get_files_to_be_processed(input_dir)
    numbers, references_number, detriment_words_number = process_files(
        files_to_be_processed, input_dir, judgement_year)
    exercise1(numbers, judgement_year)
    exercise2(numbers, dividing_point, judgement_year)
    exercise3(references_number, judgement_year)
    exercise4(detriment_words_number, judgement_year)
Example #2
0
def main(cl_args):
    args = parse_arguments(cl_args)
    run_all(
        args.emb_models,
        args.data_paths,
        args.folds,
        args.sizes,
        args.classifiers,
        args.ptv_names,
    )
Example #3
0
def main():
    input_dir, judgement_year = parse_arguments()
    create_index_with_analyzer()
    files = get_files_to_be_processed(input_dir)
    for file in tqdm(files, mininterval=15, unit='files'):
        extract_and_upload_data(file, judgement_year, INDEX_DATA_URL, HEADERS)
    save_data(
        'Word {} occurred {} times in judgements from year {}.'.format(
            DETRIMENT_WORD, count_detriment_words(), judgement_year),
        'exercise-6.txt')
    save_data(
        'Given phrase has occurred {} times in judgements from year {}.'.
        format(find_phrase(PHRASE, 0), judgement_year), 'exercise-7.txt')
    save_data(
        'Given phrase has occurred {} times in judgements from year {}.'.
        format(find_phrase(PHRASE, 2), judgement_year), 'exercise-8.txt')
    save_data(search_top_judges(NUMBER_OF_JUDGES, judgement_year),
              'exercise-9.txt')
    create_bar_chart(prepare_bar_chart_data(judgement_year), 'exercise-10.png',
                     judgement_year)
Example #4
0
-- Interspersed Sharing Task with Four Hidden Layers
"""

import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '../..'))
from Experiments.experiment import Experiment
from Models.interspersed_sharing_four_hidden import InterspersedSharingModel
from utils.argument_parser import parse_arguments
from utils.data_utils.data_handler import fetch_data
from utils.training_utils.task_set import Coupled

EXPERIMENT_NAME = 'multi-interspersed-final'

if __name__ == '__main__':
    args = parse_arguments()

    # Target tasks.
    task = Coupled.tasks[args.task_type]

    to_run = {('%s-%s' % (EXPERIMENT_NAME, args.task_type)): task}

    # These are the training sizes which we will test.
    training_sizes = [
        500, 1000, 2000, 3000, 4000, 5000, 7500, 10000, 15000, 25000
    ]

    for name, tasks in to_run.iteritems():
        # Produce the training, validation, and test sets.
        x_train, x_validate, x_test, y_train, y_validate, y_test, task_ids = fetch_data(
            tasks)
Example #5
0
from MlMerchant import MLMerchant
from abstract_merchant import AbstractMerchant
from ml_engines.rand_for import RandomForestEngine
from utils.argument_parser import parse_arguments
from utils.cross_validator import CrossValidator
from utils.settingsbuilder import SettingsBuilder


class RandomForestMerchant(AbstractMerchant):
    def get_cross_validator(self, settings):
        return CrossValidator(settings, RandomForestEngine())

    def start_merchant(self):
        settings = SettingsBuilder() \
            .with_data_file('rand_for_models.pkl') \
            .build()
        ml_merchant = MLMerchant(settings, RandomForestEngine())
        ml_merchant.initialize()
        return ml_merchant


if __name__ == "__main__":
    args = parse_arguments('PriceWars Merchant doing Random Forest Regression')
    if args.train and args.buy and args.merchant and args.test and args.output:
        RandomForestMerchant().start_cross_validation(args)
    else:
        RandomForestMerchant().start_server(args)
Example #6
0
from MlMerchant import MLMerchant
from abstract_merchant import AbstractMerchant
from ml_engines.log_reg import LogisticRegressionEngine
from utils.argument_parser import parse_arguments
from utils.cross_validator import CrossValidator
from utils.settingsbuilder import SettingsBuilder


class LogisticRegressionMerchant(AbstractMerchant):
    def get_cross_validator(self, settings):
        return CrossValidator(settings, LogisticRegressionEngine())

    def start_merchant(self):
        settings = SettingsBuilder() \
            .with_data_file('log_reg_models.pkl') \
            .build()
        ml_merchant = MLMerchant(settings, LogisticRegressionEngine())
        ml_merchant.initialize()
        return ml_merchant


if __name__ == "__main__":
    args = parse_arguments('PriceWars Merchant doing Logistic Regression')
    if args.train and args.buy and args.merchant and args.test and args.output:
        LogisticRegressionMerchant().start_cross_validation(args)
    else:
        LogisticRegressionMerchant().start_server(args)
Example #7
0
        # Sort predictions according to IDs
        test_ids, y_pred = zip(*sorted(zip(ids_prediction, predictions)))

    else:

        # Visualize the histogram of data without outliers
        if params['visualize']:
            plot_distribution(input_data, 'input_data', verbose=True)

        # Initialize weight vector coefficients as zeros
        initial_w = np.zeros(input_data.shape[1])

        # Train the model
        w, loss = least_squares_sgd(yb,
                                    input_data,
                                    initial_w,
                                    batch_size=params['batch_size'],
                                    max_iters=params['max_iters'],
                                    gamma=params['gamma'],
                                    loss_function=params['loss_function'],
                                    verbose=params['verbose'])

        y_pred = predict_labels(w, test_data)

    # Create a CSV with the predictions either if it was by splitting jets or not
    create_csv_submission(test_ids, y_pred, results_path + '/results.csv')


if __name__ == '__main__':
    main(**vars(parse_arguments()))
Example #8
0
from MlMerchant import MLMerchant
from abstract_merchant import AbstractMerchant
from ml_engines.mlp import MlpEngine
from utils.argument_parser import parse_arguments
from utils.cross_validator import CrossValidator
from utils.settingsbuilder import SettingsBuilder


class MlpMerchant(AbstractMerchant):
    def get_cross_validator(self, settings):
        return CrossValidator(settings, MlpEngine())

    def start_merchant(self):
        settings = SettingsBuilder() \
            .with_data_file('mlp_models.pkl') \
            .build()
        ml_merchant = MLMerchant(settings, MlpEngine())
        ml_merchant.initialize()
        return ml_merchant


if __name__ == "__main__":
    args = parse_arguments('PriceWars Merchant doing MLP Regression')
    if args.train and args.buy and args.merchant and args.test and args.output:
        MlpMerchant().start_cross_validation(args)
    else:
        MlpMerchant().start_server(args)