Information Technology Reference
In-Depth Information
Algorithm 4
User-based K-nearest Neighbor CF
Input set of users
U
, set of items
I
, similarity function
˃(
·
,
·
)
, number of neighbors
l
, number of
item to recommend
k
Output list of
k
recommended items
1:
u
target user
2:
N
ₐ∅
set of neighbors
3: recommendations
ₐ∅
list of recommendations
4:
for all
v
∈
U
\
u
do
5:
s
ₐ
˃(u,v)
6:
if
s
≥
˃(u,
N
l
)
then
7:
N
ₐ
N
∪
(v,
s
)
8:
end if
9:
end for
10:
for all
i
∈
I
\
I
u
do
(
I
u
refers to items which
u
already knows)
11:
for all
n
∈
N
do
12:
if
I
(
n
,
i
)
=
1
then
13:
r
n
ˆ
ₐ
s
n
r
(
n
,
i
)
14:
end if
15:
end for
ₐ
I
(
n
,
i
)
=
1
ˆ
16:
r
ˆ
r
n
17:
if
r
ˆ
>
sort
(
recommendations
k
)
then
18:
add
(
i
)
19:
if
|
recommendations
|
> k
then
20:
remove
(
recommendations
k
+
1
)
21:
end if
22:
end if
23:
end for
Algorithm 5
Item-based K-nearest Neighbor CF
Input set of users
U
, set of items
I
, similarity function
˃(
·
,
·
)
, number of items to recommend
k
Output list of
k
recommended items
1:
u
target user
2:
S
|
I
|×|
I
|
similarity matrix for all combinations of items
3:
N
ₐ∅
set of neighbors
4: recommendations
ₐ∅
list of recommendations
5:
for all
i
∈
I
do
6:
for all
j
∈
I
\
i
do
7:
S
i
,
j
ₐ
˃(
i
,
j
)
8:
end for
9:
end for
10:
for all
i
c
u
c
u
∈
I
do
I
refers to all items the target user
u
did not interact with
11:
r
i
ˆ
ₐ
u
↗
S
i
u
refers to items a user has interacted with
c
u
)
12:
recommendations
ₐ
top
(k,
ˆ
r
, I
13:
end for
Search WWH ::
Custom Search