예제 #1
0
def embeddings_cosine_sim(file, sp, df):
    print("Computing cosine similarity across image embeddings")
    create_embeddings(file[:file.rfind("/") + 1])
    id_embeddings = utils.get_out_file(file)
    embeddings = id_embeddings["embedding"].tolist()
    print("Normalizing image embeddings")
    normalized_embeddings = normalize(embeddings)
    common.cosine_similarity(vectors=normalized_embeddings, df=df, sp=sp)
예제 #2
0
 def similarity(other_post):
   return cosine_similarity(post.token_index, other_post.token_index)
예제 #3
0
 def similarity(other_post):
   return cosine_similarity(this, __token_dist(other_post.title))
예제 #4
0
def bio_tfidf_cosine_sim(sp, df):
    vectors = common.tfidf(df, FEATURE)
    common.cosine_similarity(sp, df, vectors)
예제 #5
0
def text_tfidf_cosine_sim_length_constrained(sp, df, n):
    df[FEATURE] = common.constrain_length(df, FEATURE, n)
    vectors = common.tfidf(df, FEATURE)
    common.cosine_similarity(sp, df, vectors)