school_info=inst, 
                                                                                  ranking='pi_rescaled',
                                                                                  year_start=1970, 
                                                                                  year_stop=2012, 
                                                                                  year_step=1)

    if args.validation:  # if specified years are to be evaluated
        hold_out = [int(year) for year in args.validation.split(',')]
        testing_candidates, testing_jobs, testing_job_ranks = [], [], []
        for i, year in enumerate(year_range):
            if year in hold_out:
                testing_candidates.append(candidate_pools[i])
                testing_jobs.append(job_pools[i])
                testing_job_ranks.append(job_ranks[i])
        # Overwrite originals 
        candidate_pools, job_pools, job_ranks = testing_candidates, testing_jobs, testing_job_ranks

    model = SigmoidModel(prob_function=args.prob_function)
    simulator = SimulationEngine(candidate_pools, job_pools, job_ranks, inst, model, iters=1, reg=0)
    if model.num_weights() > 0:
        w = np.array([float(x) for x in args.weights.split(',')])
        if len(w) != model.num_weights():
            print len(w), model.num_weights()
            raise ValueError('Invalid number of weights/model parameters!')
    else:
        w = None

    for i in xrange(args.num_iters):
        simulator.simulate(weights=w, ranking=args.ranking)

Exemple #2
0
    for i, year in enumerate(year_range):
        if year in hold_out:
            testing_candidates.append(candidate_pools[i])
            testing_jobs.append(job_pools[i])
            testing_job_ranks.append(job_ranks[i])
        else:
            training_candidates.append(candidate_pools[i])
            training_jobs.append(job_pools[i])
            training_job_ranks.append(job_ranks[i])

    # Find a decent starting place (using the training set)
    simulator = SimulationEngine(training_candidates, training_jobs, training_job_ranks, inst, model, power=args.power, reg=args.reg, iters=20)
    w0 = None
    best_error = np.inf
    for i in xrange(args.num_steps):
        wtemp = np.random.randn(model.num_weights()) 
        error = simulator.simulate(weights=wtemp)
        if error < best_error:
            w0 = wtemp.copy()
            best_error = error

    # Optimize from there (for the training set)
    simulator = SimulationEngine(training_candidates, training_jobs, training_job_ranks, inst, model, power=args.power, reg=args.reg, iters=args.num_iters)
    opt = {'maxiter':args.num_steps}
    res = minimize(simulator.simulate, w0, method='Nelder-Mead', options=opt)
    final_weights = res.x
    print 'FINAL_WEIGHTS:', final_weights

    # Compute test set error
    simulator = SimulationEngine(testing_candidates, testing_jobs, testing_job_ranks, inst, model, power=args.power, reg=0., iters=args.num_iters)
    final_error = simulator.simulate(weights=final_weights)
        # Overwrite originals:
        candidate_pools, job_pools, job_ranks = training_candidates, training_jobs, training_job_ranks
        hiring_orders, hiring_probs = training_orders, training_probs
    
    # Which model?
    model = SigmoidModel(prob_function=args.prob_function)

    # Find a starting place
    simulator = SimulationEngine(candidate_pools, job_pools, job_ranks, inst, model, power=1, reg=args.reg,
                                 hiring_orders=hiring_orders, hiring_probs=hiring_probs)

    w0 = None
    best_neg_likelihood = np.inf
    for i in xrange(10): #args.num_steps):
        #wtemp = 100*np.random.randn(model.num_weights())  # ~[-100, 100]
        wtemp = 100*(np.random.random(model.num_weights()) - 0.5)  # ~[-100, 100]
        temp = simulator.calculate_neg_log_likelihood(weights=wtemp)
        if temp < best_neg_likelihood:
            w0 = wtemp.copy()
            best_neg_likelihood = temp

    # Optimize from there
    simulator = SimulationEngine(candidate_pools, job_pools, job_ranks, inst, model, power=1, reg=args.reg, 
                                 hiring_orders=hiring_orders, hiring_probs=hiring_probs)
    opt = {'maxiter':args.num_steps}
    method = 'Nelder-Mead'

    res = minimize(simulator.calculate_neg_log_likelihood, w0, method=method, options=opt, tol=args.tolerance)
    print res

Exemple #4
0
            training_jobs.append(job_pools[i])
            training_job_ranks.append(job_ranks[i])

    # Find a decent starting place (using the training set)
    simulator = SimulationEngine(training_candidates,
                                 training_jobs,
                                 training_job_ranks,
                                 inst,
                                 model,
                                 power=args.power,
                                 reg=args.reg,
                                 iters=20)
    w0 = None
    best_error = np.inf
    for i in xrange(args.num_steps):
        wtemp = np.random.randn(model.num_weights())
        error = simulator.simulate(weights=wtemp)
        if error < best_error:
            w0 = wtemp.copy()
            best_error = error

    # Optimize from there (for the training set)
    simulator = SimulationEngine(training_candidates,
                                 training_jobs,
                                 training_job_ranks,
                                 inst,
                                 model,
                                 power=args.power,
                                 reg=args.reg,
                                 iters=args.num_iters)
    opt = {'maxiter': args.num_steps}
Exemple #5
0
    model = SigmoidModel(prob_function=args.prob_function)

    # Find a decent starting place
    simulator = SimulationEngine(candidate_pools,
                                 job_pools,
                                 job_ranks,
                                 inst,
                                 model,
                                 power=1,
                                 reg=args.reg,
                                 iters=20)
    w0 = None
    best_error = np.inf
    for i in xrange(args.num_steps):
        wtemp = 200 * (np.random.random(model.num_weights()) - 0.5
                       )  # ~[-100, 100]
        error = simulator.simulate(weights=wtemp)
        if error < best_error:
            w0 = wtemp.copy()
            best_error = error

    # Optimize from there
    simulator = SimulationEngine(candidate_pools,
                                 job_pools,
                                 job_ranks,
                                 inst,
                                 model,
                                 power=1,
                                 reg=args.reg,
                                 iters=args.num_iters)
Exemple #6
0
    if args.validation:  # if specified years are to be evaluated
        hold_out = [int(year) for year in args.validation.split(',')]
        testing_candidates, testing_jobs, testing_job_ranks = [], [], []
        for i, year in enumerate(year_range):
            if year in hold_out:
                testing_candidates.append(candidate_pools[i])
                testing_jobs.append(job_pools[i])
                testing_job_ranks.append(job_ranks[i])
        # Overwrite originals
        candidate_pools, job_pools, job_ranks = testing_candidates, testing_jobs, testing_job_ranks

    model = SigmoidModel(prob_function=args.prob_function)
    simulator = SimulationEngine(candidate_pools,
                                 job_pools,
                                 job_ranks,
                                 inst,
                                 model,
                                 iters=1,
                                 reg=0)
    if model.num_weights() > 0:
        w = np.array([float(x) for x in args.weights.split(',')])
        if len(w) != model.num_weights():
            print len(w), model.num_weights()
            raise ValueError('Invalid number of weights/model parameters!')
    else:
        w = None

    for i in xrange(args.num_iters):
        simulator.simulate(weights=w, ranking=args.ranking)