Publishing Rankings with OpenRank SDK

Publishing rankings after running the OpenRank SDK

Introduction

The OpenRank SDK allows you to compute and publish trust rankings using the EigenTrust algorithm. This document provides the documentation of the available methods, including description of the parameters and an example for quick reference.

The published urls can be found on -

http://openrank-sdk-api.k3l.io/download/eigentrust/{id}

Methods

run_and_publish_eigentrust

Description

Runs the EigenTrust algorithm using local trust and pre-trust data, and publishes the results.

Parameters

NameTypeDescriptionDefault

id_

str

The ID for publishing the results. (This will be used to query the published rankings)

-

localtrust

List[IJV]

List of local trust values. Each item is a dictionary with keys: i (source node), j (destination node), and v (trust value).

-

pretrust

List[IV]

List of pre-trust values. Each item is a dictionary with keys: i (node) and v (pre-trust value).

None

kwargs

dict

Additional keyword arguments.

-

overwrite

bool

If True, existing results with the same ID will be overwritten.

False

Returns

  • Tuple[List[Score], str]: A tuple containing:

    • List[Score]: List of computed scores.

    • str: URL of the published results.

publish_eigentrust

Description

Publishes the EigenTrust results.

Parameters

NameTypeDescriptionDefault

id_

str

The ID for publishing the results.

-

result

List[Score]

List of computed scores.

-

kwargs

dict

Additional keyword arguments.

-

overwrite

bool

If True, existing results with the same ID will be overwritten.

False

Returns

  • str: URL of the published results.

Example

from openrank_sdk import EigenTrust

# Initialize local trust data
localtrust = [
    {'i': 'Node1', 'j': 'Node2', 'v': 0.8},
    {'i': 'Node2', 'j': 'Node3', 'v': 0.6},
    {'i': 'Node3', 'j': 'Node1', 'v': 0.4},
]

# Initialize pre-trust data (optional)
pretrust = [{'i': 'Node1', 'v': 1.0}]

et = EigenTrust(api_key=api_key)

# Run the EigenTrust algorithm and publish the results
scores, publish_url = et.run_and_publish_eigentrust('my_results', localtrust, pretrust, overwrite=True)

# Output the results
print(f'Computed scores: {scores}')
print(f'Results published at: {publish_url}')
# http://openrank-sdk-api.k3l.io/download/eigentrust/my_results

# Publish EigenTrust results separately
url = et.publish_eigentrust('my_results2', scores, overwrite=True)
print(f'Results published at: {url}')
# http://openrank-sdk-api.k3l.io/download/eigentrust/my_results2

Last updated

Logo

Copyright 2024