9566
2022. 5. 25. 21:01
728x90
2022-05-25 벡터의 유사도(코사인,유클리디안,자카드 유사도).ipynb
0.34MB
# dict['key']가 가능
title_to_index = dict(zip(data['title'], data.index))
# 영화 제목 Father of the Bride Part II의 인덱스를 리턴
idx = title_to_index['Father of the Bride Part II']
print(idx)
array -> list변환 for 정렬
sim_scores = list(enumerate(cosine_sim[idx]))
# 유사도에 따라 영화들을 정렬한다.
sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)
728x90