Ejemplo n.º 1
0
def evaluate_and_print():
    """Evaluates the system and outputs per-network results to separate
    CSV files."""
    printer = pretty_print_summary

    twitter_entries = get_twitter_entries()
    twitter_start_time = int(time.time())
    print 'Evaluating Twitter', twitter_start_time
    twitter_evaluator = Evaluator(twitter_entries, TwitterProfile,
                                  TwitterSearch(), 'twitter')
    twitter_results = twitter_evaluator.evaluate()
    twitter_end_time = int(time.time())
    twitter_lines = ['\n' + x for x in printer('Twitter', twitter_results)]

    print 'Done', twitter_end_time, '. Total',\
          twitter_end_time - twitter_start_time

    with open('twitter_evaluation_results.csv', 'w') as twitter_result_file:
        twitter_result_file.writelines(twitter_lines)

    facebook_entries = get_facebook_entries()
    facebook_start_time = int(time.time())
    print 'Evaluating Facebook', facebook_start_time
    facebook_evaluator = Evaluator(facebook_entries, FacebookProfile,
                                   FacebookSearch(), 'facebook')
    facebook_results = facebook_evaluator.evaluate()
    facebook_end_time = int(time.time())
    facebook_lines = ['\n' + x for x in printer('Facebook', facebook_results)]

    print 'Done', facebook_end_time, '. Total',\
          facebook_end_time - facebook_start_time

    with open('facebook_evaluation_results.csv', 'w') as facebook_result_file:
        facebook_result_file.writelines(facebook_lines)

    output_lines = []
    output_lines += twitter_lines
    output_lines += ['\n']
    output_lines += facebook_lines

    with open('evaluation_results.csv', 'w') as result_file:
        result_file.writelines(output_lines)
Ejemplo n.º 2
0
def evaluate_to_file(converter=config.evaluate_converter, idx=0):
    """Evaluates the performance of the system, and saves the results
    to data files in network-specific folders."""
    name = converter.name
    basedir = os.path.dirname(__file__)
    results_directory = os.path.join(basedir, 'results')

    twitter_entries = get_twitter_entries()
    twitter_start_time = int(time.time())
    print 'Evaluating Twitter', name, twitter_start_time
    twitter_evaluator = Evaluator(twitter_entries, TwitterProfile,
                                  TwitterSearch(), 'twitter',
                                  converter=converter)
    twitter_results = twitter_evaluator.evaluate()
    twitter_end_time = int(time.time())

    processed_results = process_network_results(twitter_results)

    twitter_folder = os.path.join(results_directory, 'Twitter')
    results_file = os.path.join(twitter_folder, '%02d. ' % idx + name)
    cPickle.dump(processed_results, open(results_file, 'wb'))
    print 'Done', twitter_end_time, '. Total',\
          twitter_end_time - twitter_start_time

    facebook_entries = get_facebook_entries()
    facebook_start_time = int(time.time())
    print 'Evaluating Facebook', facebook_start_time
    facebook_evaluator = Evaluator(facebook_entries, FacebookProfile,
                                   FacebookSearch(), 'facebook',
                                   converter=converter)
    facebook_results = facebook_evaluator.evaluate()
    facebook_end_time = int(time.time())

    processed_results = process_network_results(facebook_results)

    facebook_folder = os.path.join(results_directory, 'Facebook')
    results_file = os.path.join(facebook_folder, '%02d. ' % idx + name)
    cPickle.dump(processed_results, open(results_file, 'wb'))
    print 'Done', facebook_end_time, '. Total',\
          facebook_end_time - facebook_start_time
Ejemplo n.º 3
0
def evaluate_statistical_significance(converter=config.evaluate_converter,
                                      idx=0):
    """Evaluates the performance of the system in terms of number of correct
    results, and saves the results to data files in network-specific folders.
    Used to determine if feature sets show statistical significance."""
    name = converter.__name__
    basedir = os.path.dirname(__file__)
    results_directory = os.path.join(basedir, 'results')

    twitter_entries = get_twitter_entries()
    twitter_start_time = int(time.time())
    print 'Evaluating Twitter', name, twitter_start_time
    twitter_evaluator = Evaluator(twitter_entries, TwitterProfile,
                                  TwitterSearch(), 'twitter',
                                  converter=converter)
    twitter_results = twitter_evaluator.evaluate_statistical()
    twitter_end_time = int(time.time())

    twitter_folder = os.path.join(results_directory, 'Twitter')
    results_file = os.path.join(twitter_folder, '%02d. ' % idx + name)
    cPickle.dump(twitter_results, open(results_file, 'wb'))
    print 'Done', twitter_end_time, '. Total',\
          twitter_end_time - twitter_start_time

    facebook_entries = get_facebook_entries()
    facebook_start_time = int(time.time())
    print 'Evaluating Facebook', facebook_start_time
    facebook_evaluator = Evaluator(facebook_entries, FacebookProfile,
                                   FacebookSearch(), 'facebook',
                                   converter=converter)
    facebook_results = facebook_evaluator.evaluate_statistical()
    facebook_end_time = int(time.time())

    facebook_folder = os.path.join(results_directory, 'Facebook')
    results_file = os.path.join(facebook_folder, '%02d. ' % idx + name)
    cPickle.dump(facebook_results, open(results_file, 'wb'))
    print 'Done', facebook_end_time, '. Total',\
          facebook_end_time - facebook_start_time