예제 #1
0
def trial_init(recdr, logr):
    logr.log('Initializing new trial...', 'standard')
    b = DataGenerator()
    b.set_baseline_response_prob(baseline)
    b.add_random_user_attrs(num_user_atts, min_user_att_levels,
                            max_user_att_levels)
    b.add_random_inter_attrs(num_msg_atts, min_msg_att_levels,
                             max_msg_att_levels)
    templates = b.set_random_propensities(
        num_propensity_groups, min_group_user_atts, max_group_user_atts,
        min_group_msg_atts, max_group_msg_atts, min_group_pos_prob,
        max_group_pos_prob)
    # -> Returns: a pair (user templates, interaction templates)
    logr.log('Generating data...', 'standard')
    messages = b.gen_random_inters(num_test_messages)
    rows = ut.unzip(b.gen_crossprod_rows(b.unique_users(), messages))
    logr.log('Number of rows: ' + str(len(rows)), 'standard')
    # Split data into train, calibration, and test.
    train, calibrate, test = ut.split_data(rows, 0.5, 0.25, 0.25)
    calibration_users = map(lambda (u, m, r): u, calibrate)
    test_users = map(lambda (u, m, r): u, test)
    controls = su.build_std_control_solvers(calibrate, b, messages, 15)
    treatments = su.build_std_knn_optims(train, calibrate, b, recorder, 1, 15)
    solvers = controls + treatments
    return (train, test_users, b, solvers)
예제 #2
0
def trial_init(recdr, logr):
	logr.log('Initializing new trial...', 'standard')
	b = DataGenerator()
	b.set_baseline_response_prob(baseline)
	b.add_random_user_attrs(num_user_atts, min_user_att_levels, max_user_att_levels) 
	b.add_random_inter_attrs(num_msg_atts, min_msg_att_levels, max_msg_att_levels) 
	templates = b.set_random_propensities(num_propensity_groups, 
							  min_group_user_atts, max_group_user_atts, 
							  min_group_msg_atts, max_group_msg_atts,
							  min_group_pos_prob, max_group_pos_prob)
	# -> Returns: a pair (user templates, interaction templates)
	logr.log('Generating data...', 'standard')
	messages = b.gen_random_inters(num_test_messages)
	users = b.gen_random_users(num_users)
	#rows = ut.unzip(b.gen_crossprod_rows(b.unique_users(), messages))
	rows = ut.unzip(b.gen_random_rows_from(users, messages))
	logr.log('Number of rows: ' + str(len(rows)), 'standard')
	# Split data into train, calibration, and test.
	train, calibrate, test = ut.split_data(rows, 0.5, 0.25, 0.25)
	calibration_users = map(lambda (u, m, r): u, calibrate)
	test_users = map(lambda (u, m, r): u, test)
	controls = su.build_std_control_solvers(calibrate, b, messages, 15)
	treatments = su.build_std_knn_optims(train, calibrate, b, recorder, 1, 15)
	solvers = controls + treatments
	return (train, test_users, b, solvers)
예제 #3
0
def trial_init(recdr, logr):
	# Split data into train, calibration, and test.
	train, calibrate, test = ut.split_data(rows, 0.5, 0.25, 0.25)
	calibration_users = map(lambda (u, m, r): u, calibrate)
	test_users = map(lambda (u, m, r): u, test)
	controls = su.build_std_control_solvers(calibrate, b, 100, 15)
	treatments = su.build_std_knn_optims(train, calibrate, b, recorder, 1, 15)
	solvers = controls + treatments
	return (train, test_users, b, solvers)
예제 #4
0
def trial_init(recdr, logr):
    # Split data into train, calibration, and test.
    train, calibrate, test = ut.split_data(rows, 0.5, 0.25, 0.25)
    calibration_users = map(lambda (u, m, r): u, calibrate)
    test_users = map(lambda (u, m, r): u, test)
    controls = su.build_std_control_solvers(calibrate, b, 100, 15)
    treatments = su.build_std_knn_optims(train, calibrate, b, recorder, 1, 15)
    solvers = controls + treatments
    return (train, test_users, b, solvers)
예제 #5
0
mt5 = {'IA_2':'L_4', 'IA_4':'L_3'}

b.set_user_inter_propensity(ut1, mt1, 0.5)
b.set_user_inter_propensity(ut2, mt2, 0.5)
b.set_user_inter_propensity(ut3, mt3, 0.5)
b.set_user_inter_propensity(ut4, mt4, 0.99)
b.set_user_inter_propensity(ut5, mt5, 0.5)

rows = []
rows += ut.unzip(b.gen_random_rows_from_template(ut1, mt1, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut2, mt2, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut3, mt3, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut4, mt4, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut5, mt5, 100))
rows += ut.unzip(b.gen_random_rows(2000))

log = su.BasicLogger()
recorder = su.ScenarioRecorder()

# Split data into train, calibration, and test.
train, calibrate, test = ut.split_data(rows, 0.5, 0.25, 0.25)
calibration_users = map(lambda (u, m, r): u, calibrate)
test_users = map(lambda (u, m, r): u, test)

controls = su.build_std_control_solvers(calibrate, b, 100, 15)
treatments = su.build_std_knn_optims(train, calibrate, b, recorder, 1, 15)

solvers = controls + treatments
		   
su.execute_trial(train, test_users, b, solvers, recorder, logger = log)
예제 #6
0
mt5 = {'IA_2': 'L_4', 'IA_4': 'L_3'}

b.set_user_inter_propensity(ut1, mt1, 0.5)
b.set_user_inter_propensity(ut2, mt2, 0.5)
b.set_user_inter_propensity(ut3, mt3, 0.5)
b.set_user_inter_propensity(ut4, mt4, 0.99)
b.set_user_inter_propensity(ut5, mt5, 0.5)

rows = []
rows += ut.unzip(b.gen_random_rows_from_template(ut1, mt1, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut2, mt2, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut3, mt3, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut4, mt4, 100))
rows += ut.unzip(b.gen_random_rows_from_template(ut5, mt5, 100))
rows += ut.unzip(b.gen_random_rows(2000))

log = su.BasicLogger()
recorder = su.ScenarioRecorder()

# Split data into train, calibration, and test.
train, calibrate, test = ut.split_data(rows, 0.5, 0.25, 0.25)
calibration_users = map(lambda (u, m, r): u, calibrate)
test_users = map(lambda (u, m, r): u, test)

controls = su.build_std_control_solvers(calibrate, b, 100, 15)
treatments = su.build_std_knn_optims(train, calibrate, b, recorder, 1, 15)

solvers = controls + treatments

su.execute_trial(train, test_users, b, solvers, recorder, logger=log)