Esempio n. 1
0
def single_experiment(mashup, g, range_tuple, df_weights):
    user_query = exp.compose_query(g, mashup)
    # M = exp.candidate_set(user_query, g)  # set of candidate services
    M = exp.candidate_set_all_activated(g)  # set of candidate services, all activated
    S = user_query["categories"]  # set of requested tags
    actual = user_query["services"]
    k = min(range_tuple[1] - 1, len(M))
    result = exp.Greedy(g, S, M, k, 1, 0, 1, df_weights)
    array_of_avg_precisions = []
    for i in range(range_tuple[0], k + 1):
        predicted = result[0][:i]
        array_of_avg_precisions.append(
            val.average_precision(actual, predicted, i, mashup, g)
        )  # compute average precision
    diff = range_tuple[1] - 1 - len(array_of_avg_precisions)
    if diff == 0:
        return array_of_avg_precisions
    else:
        return np.append(array_of_avg_precisions, np.repeat(np.nan, diff)).tolist()
Esempio n. 2
0
def single_experiment(mashup, g, range_tuple, df_weights):
    user_query = exp.compose_query(g, mashup)
    # M = exp.candidate_set(user_query, g)  # set of candidate services
    M = exp.candidate_set_all_activated(
        g)  # set of candidate services, all activated
    S = user_query["categories"]  # set of requested tags
    actual = user_query["services"]
    k = min(range_tuple[1] - 1, len(M))
    result = exp.Greedy(g, S, M, k, 1, 0, 1, df_weights)
    array_of_avg_precisions = []
    for i in range(range_tuple[0], k + 1):
        predicted = result[0][:i]
        array_of_avg_precisions.append(
            val.average_precision(actual, predicted, i, mashup,
                                  g))  # compute average precision
    diff = range_tuple[1] - 1 - len(array_of_avg_precisions)
    if diff == 0:
        return array_of_avg_precisions
    else:
        return np.append(array_of_avg_precisions, np.repeat(np.nan,
                                                            diff)).tolist()
Esempio n. 3
0
 def setUp(self):
     self.g = Graph()
     self.g.parse("../graph/for_test_graph.ttl", format="turtle")
     self.mashup = "http://www.programmableweb.com/mashup/fast-quick-online-translator"
     self.query = exp.compose_query(self.g, self.mashup)
     self.candidate_set = exp.candidate_set(self.query, self.g)
Esempio n. 4
0
 def setUp(self):
     self.g = Graph()
     self.g.parse("../graph/for_test_graph.ttl", format="turtle")
     self.mashup = "http://www.programmableweb.com/mashup/fast-quick-online-translator"
     self.query = exp.compose_query(self.g, self.mashup)
     self.candidate_set = exp.candidate_set(self.query, self.g)