unit.quit()


#------------------------------------------------------------------------------
#------------------------------------------------------------------------------


# Load results reads the log_file, and creates feature vectors
def load_results():
    pass


def test_stat(observed_values, unit_assignments):
    pass


adfisher.do_experiment(make_unit=make_browser,
                       treatments=[control_treatment, exp_treatment],
                       measurement=measurement,
                       end_unit=cleanup_browser,
                       load_results=load_results,
                       test_stat=test_stat,
                       ml_analysis=True,
                       num_blocks=13,
                       num_units=4,
                       timeout=2000,
                       log_file=log_file,
                       exp_flag=True,
                       analysis_flag=False,
                       treatment_names=["control", "experimental"])
    unit.visit_sites(site_file)


# Measurement - Collects ads
def measurement(unit):
    unit.collect_ads(reloads=10, delay=5, site='bbc')


# Shuts down the browser once we are done with it.
def cleanup_browser(unit):
    unit.quit()

# Load results reads the log_file, and creates feature vectors
def load_results():
    collection, names = converter.reader.read_log(log_file)
    return converter.reader.get_feature_vectors(collection, feat_choice='ads')

# If you choose to perform ML, then test_stat is redundant. By default, correctly_classified is used,
# If not, then you can choose something, and that will be used to perform the analysis. 

def test_stat(observed_values, unit_assignments):
    return analysis.statistics.difference(observed_values, unit_assignments)
#   return statistics.correctly_classified(observed_values, unit_assignments)

adfisher.do_experiment(make_unit=make_browser, treatments=[control_treatment, exp_treatment], 
                        measurement=measurement, end_unit=cleanup_browser,
                        load_results=load_results, test_stat=test_stat, ml_analysis=True, 
                        num_blocks=20, num_units=4, timeout=2000,
                        log_file=log_file, 
treatment_names=["control (null)", "experimental (substance abuse)"])
def exp_treatment(unit):
    pass

# Measurement - Collects ads
# checks all the sites that adfisher could previously collect on
# (~10 minutes for src and href)
def measurement(unit):

    sites = ['toi','bbc','guardian','reuters','bloomberg']
    for site in sites:
        unit.collect_ads(site=site, reloads=2, delay=5)

# Shuts down the browser once we are done with it.
def cleanup_browser(unit):
    unit.quit()

# Blank analysis
def load_results():
    pass

# Blank analysis
def test_stat(observed_values, unit_assignments):
    pass

adfisher.do_experiment(make_unit=make_browser, treatments=[control_treatment, exp_treatment], 
                        measurement=measurement, end_unit=cleanup_browser,
                        load_results=load_results, test_stat=test_stat, ml_analysis=False, 
                        num_blocks=1, num_units=4, timeout=2000,
                        log_file=log_file, exp_flag=True, analysis_flag=False, 
                        treatment_names=["control", "experimental"])
Esempio n. 4
0
    treatments = [exp_treatment2, control_treatment]
    treatment_names = [
        "experimental (TOPIC queries)",
        "control (null)",
    ]

if sys.argv[1] == 'measure':
    # CAN change parameters below

    adfisher.do_experiment(
        make_unit=make_browser,
        treatments=treatments,
        treatment_names=treatment_names,
        measurement=measurement,
        end_unit=cleanup_browser,
        exp_flag=True,
        analysis_flag=False,
        num_blocks=10,
        num_units=6,
        timeout=2000,
        log_file=log_file
    )


if sys.argv[1] == 'analyze':
    # CAN change parameters below

    adfisher.do_experiment(
        treatments=treatments,
        treatment_names=treatment_names,
        load_results=load_results,