Installation and Use
Using OpenRank SDK - Hubs & Authorities to generate your first set of rankings.
Amazon often recommends items with the "Customers who bought this also bought" feature. This can be achieved by tracing a product-customer-product round trip: from the original product to all its purchasers and back to all products also purchased by them.
We can replicate this using the OpenRank SDK by focusing on actor-to-artifact relationships, mirroring them bidirectionally, and running EigenTrust with the original item as the seed peer.
In this example, we will check for book P by seeding trust in P and observing the resulting trust scores for other books.
Installation
Here's the Github repo.
Parameters
Local Trust (lt)
i
From Peer ID: Address of the user initiating the interest arc
*(Required)
j
To Peer ID: Address of the entity receiving trust
*(Required)
v
Value of Interaction: Score/Weight/Value of the trust
*(Required)
Seed Peers (PreTrust / pt)
I
Seed Peers: Hub we want to get recommendations of
Defaults to using all i in the Local Trust as Seed Peers
V
Trust Score: set to 1
1/n (n = no of peers)
Parameters
Alpha
Needs to be 0
0.5 (50%) as the strength
max_iter
The maximum number of iterations. Needs to be 2
NA
Input:
We use the following CSV dataset representing user-to-book (vested interest) arcs. Here, users are represented by A, B, C, D, and E, while books are represented by P, Q, R, S, and T.
v value cannot be negative or 0.
Sample local trust data:
Here we have purposely named it localtrust2 as to build the final localtrust we need extend this array to also include arcs from books back to users
Sample Local Trust 2 CSV:
In this example:
A, B, C, D, E: Users who have purchased books.
P, Q, R, S, T: Books that have been purchased by the users.
v: The strength of the connection between users and books, representing how many times the book was purchased or a similar metric.
Pre-trust Vector:
We initialize the pre-trust vector with a trust value for book P:
Here, this will let us get rankings of other books as compared to P based on customer activity
Running:
The EigenTrust algorithm is executed by first transforming the input trust relationships. We start with localtrust2
, a list of trust values from users to items, and generate localtrust
by adding both the original and symmetric (item-to-user) trust entries.
Pretrust values, which provide initial trust levels, are also defined. After initializing the EigenTrust
instance with specified parameters, the algorithm is run using localtrust
and pretrust
. Finally, the results are sorted by item identifier and printed. This process ensures both direct and mutual trust relationships are considered in the computation of global trust values.
Note: Please ensure the following settings are applied:
Set the alpha parameter to 0.
Set the pretrust score to 1.
Set the maximum number of iterations to 2.
Output:
The output will be a list of dictionaries, where each dictionary contains an item (P, Q, R, T) and its corresponding trust score (v).
P has the highest trust score (0.731), indicating users with a vested interest in P are highly likely to be interested in it again.
Q and T also have significant trust scores (0.102 and 0.117 respectively), suggesting they are relevant recommendations.
R has a lower trust score (0.050), showing a lesser degree of interest.
S has no entries, so it naturally has no trust score.
This method effectively replicates the "Customers who bought this also bought" recommendation feature using the OpenRank SDK. Adjust the parameters alpha
and max_iter
as needed to suit different datasets or recommendation scenarios.
Note as max_iter is made to increase, the rankings converge more proportionally.
Last updated