I have two dictionaries:
dict1 = {'A':'3','B':'6','E':'9'}
dict2 = {'A':'4','B':'8','C':'12','D':'16','E':'20'}
I need to extract key-value
pairs from dict2
such that those keys
are present in dict1
as well and then find the cosine similarity.
I need to make a new dictionary:
dict3 = {'A':'4','B':'8','E':'20'}
from dict2, how do I do that? I have tried looping through both dictionaries but I'm not able to append.
How do I find the cosine similarity between dict1 & dict3? Should the values be converted to vectors first or is there a way to find it by keeping them as dictionaries?