<jupyter_start><jupyter_text>Questioning : Find odd one out<jupyter_code>import numpy as np
def odd_one_out(words):
    
    all_word_vectors=[word_vectors[w] for w in words]
    avg_vec=np.mean(all_word_vectors,axis=0)
    print(avg_vec.shape)
    
    odd_one_out=None
    min_similarity=1.0
    
    for w in words:
        sim=cosine_similarity([word_vectors[w]],[avg_vec])
        if sim < min_similarity:
            min_similarity=sim
            odd_one_out=w
            
    return odd_one_out
            
    
    
val=odd_one_out(["mango","apple","banana","sand","grapes"])
print(val)
def predict_words(a,b,c,word_vectors):
    a,b,c=a.lower(),b.lower(),c.lower()
    words=word_vectors.vocab.keys()
    wa,wb,wc=word_vectors[a],word_vectors[b],word_vectors[c]
    maxsimilarity=-100
    for w in words:
        if w in [a,b,c]:
            continue
            
        wv=word_vectors[w]
        sim=cosine_similarity([wb-wa],[wv-wc])
        if sim > maxsimilarity:
            maxsimilarity=sim
            d=w
            
    return d
print(predict_words("man","woman","king",word_vectors))<jupyter_output>queen<jupyter_text>Using Most Similar method<jupyter_code>word_vectors.most_similar(positive=["woman","king"],negative=["man"],)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12860483242400625, 'fraction_numerical': 0.004676539360872954, 'mean_word_length': 3.1022364217252396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '298910', 'license': 'MIT', 'n_tokens_mistral': 489, 'n_tokens_neox': 461, 'n_words': 61, 'path': 'DeepLearning/RNN/Word to vec.ipynb', 'repo_name': 'pulkit10251/cbData-Science-Master', 'size': '1283'}