Exemplo n.º 1
0
def print_tarantula_result(project_name, version, ranker_type, filter_type):
    failing_to_rankres = evaluator.get_ranker_results(project_name,
                                                      version,
                                                      ranker_type,
                                                      filter_type,
                                                      "normal")

    assert len(failing_to_rankres) == 1
    ranker_res = next(iter(failing_to_rankres.values()))

    ranks = ranker_res.ranks
    suspiciousness = ranker_res.suspiciousness
    line = ranker_res.line

    results = pd.DataFrame(data={'rank': ranks, 'susp': suspiciousness})
    results.sort_values('rank', inplace=True)
    print(results.head(100))
    print("line {0}: score {1}".format(line, ranker_res.score))
    print("susp: {0}".format(suspiciousness[line]))
    print("rank: {0}".format(ranks[line]))
Exemplo n.º 2
0
def get_total_scores(project_name, ranker_type, filter_type, provider_type,
                     versions=None):
    version_to_rankres = {}
    if versions is None:
        versions = projects.get_version_names(project_name)

    for version in versions:
        failing_to_rankres = evaluator.get_ranker_results(project_name,
                                                          version,
                                                          ranker_type,
                                                          filter_type,
                                                          provider_type)
        version_to_rankres.update(failing_to_rankres)
    

    version_to_score = {ver: rank_res.score for ver, rank_res in
                        version_to_rankres.items()}
    version_to_score = pd.Series(version_to_score)
    version_to_score.sort_values(inplace=True, ascending=False)
    return version_to_score
Exemplo n.º 3
0
def optimize_classifier(project_name):
    initial_scores = {}
    for version in projects.get_version_names(project_name):
        rank_res_d = evaluator.get_ranker_results(project_name,
                                                version,
                                                "intersection",
                                                "none",
                                                TrivialProvider())
        assert len(rank_res_d) == 1
        rank_res = next(iter(rank_res_d.values()))
        initial_scores[version] = rank_res.score

    def to_optimize(classify_vector_with_cutoff):
        cutoff = classify_vector_with_cutoff[-1]
        classify_vector = classify_vector_with_cutoff[:-1]

        score = evaluation_fn(project_name, initial_scores,
                              classify_vector, cutoff)
        # minimize negative
        return -1 * score


    vecsize = 14 + 1
    lower = [-1.0 for i in range(vecsize)]
    upper = [1.0 for i in range(vecsize)]
    x0 = [0.1 for i in range(vecsize)]

    res = scipy.optimize.anneal(to_optimize, x0,
                                #maxiter=1,
                                maxeval=10,
                                dwell=5,
                                full_output=True)

    x0 = res[0]
    print("Vec is {0}, cutoff {1}".format(x0[:-1], x0[-1]))
    print(res)