サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
GPT-4o
qiita.com/Qiitaman
X = np.array([0.789, 0.515, 0.335,0]) Y = np.array([0.832, 0.555,0,0]) # cos(X,Y) = (0.789×0.832)+(0.515×0.555)+(0.335×0)+(0×0)≒0.942 print(cos_sim(X, Y)) #=> 0.9421693704700748 # Define a function to calculate the dot product of two vectors. def dot_product(a, b): return sum(x * y for x, y in zip(a, b)) # Define a function to calculate the magnitude (norm or length) of a vector. def magnitude(vec
このページを最初にブックマークしてみませんか?
『qiita.com』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く