-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.txt
39 lines (34 loc) · 1.67 KB
/
example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1. reviewed_book_embeddings = [
[0.5, 1.2, 3.4], # Embedding for Book 1
[2.3, 0.8, 4.1], # Embedding for Book 2
[1.1, 2.5, 3.0] # Embedding for Book 3
]
2. zip will produce: (it's "transposes" the data)
----------------------
[
(0.5, 2.3, 1.1), # First elements from each embedding
(1.2, 0.8, 2.5), # Second elements from each embedding
(3.4, 4.1, 3.0) # Third elements from each embedding
]
3. We calculate the average of each group
-----------------------------------------
avg_review_embedding = [
(0.5 + 2.3 + 1.1) / 3, # Average of the first elements
(1.2 + 0.8 + 2.5) / 3, # Average of the second elements
(3.4 + 4.1 + 3.0) / 3 # Average of the third elements
]
4. avg_review_embedding = [1.3, 1.5, 3.5]
Vector Operators
---------------------------
Operator Description Added
-------- -----------------
+ element-wise addition
- element-wise subtraction
* element-wise multiplication 0.5.0
|| concatenate 0.7.0
<-> Euclidean distance # Calculates the straight-line distance between two vectors in a multi-dimensional space.
<#> negative inner product # Computes the inner product (dot product) of two vectors and negates the result.
<=> cosine distance # Measures the cosine distance between two vectors, which indicates how similar they are in direction.
It's useful for comparing vectors' orientations regardless of their length.
<+> taxicab distance 0.7.0 # Also known as Manhattan distance, it calculates the distance between two points by only moving along grid
lines (like moving in a city with square blocks).