Algorithms¶
Userfeeds Platform allows running community written algorithms on too of data gathered from all supported sources like Ethereum blockchain (mainnet, ropsten, rinkeby, kovan, whisper messages), IPDB (BigchainDB) or direct messages.
Algorithms can be referenced by their identifier that depends on where the author decided to share them.
Some of algorithm sources and naming schemes are:
- Github -
github:username.repository.filename- Bitbucket -
bitbucket:username.repository.filename- Gist -
gist:hash
Note
More esoteric sources are possible, like downloading code from blockchain or encrypted algorithm code but their support is not planned at the moment.
Warning
Current support is limited to built-in algorithms through their short identifiers.
Built-in algorithms¶
Source code: https://github.io/Userfeeds/algorithms
All algorithms require one information: context.
They will get all claims intended for given context and sort them
according to their specification.
Note
Built-in algorithms can be referenced normally via eg. github:username.repo.filename or by their short name eg. latest
Claims (TODO)¶
Identifier: claims, github:Userfeeds.algorithms.claims
The simples algorithm of all. It just returns 100 latest claims for given context
Parameters¶
type- string
- optional
Type of claims to return
Example data¶
{
"items": [
{
"created_at": 1499676056549,
"id": "0xd10409e340b5f41be0c0c8db85a61b2db0e5f4fb6c87fd3a5e4b73adc9bee9bf",
"score": 1000000000000000000,
"target": "https://userfeeds.io/"
},
{
"created_at": 1499676053781,
"id": "0xcd05844f64d472d8aeceeafc1c14f377bc664a9f94574ee820128254c962bfdc",
"score": 5000000000000000000,
"target": "https://example.com/"
},
{
"created_at": 1499676051855,
"id": "0xaa6b523d72d1f0e9b00689f494ac622804e0552e55c939cabc97381bd401732b",
"score": 0,
"target": "0x64537b9f7c9d85bae5c52cb4fa2307e7da14c6f1cae6d710b66a4ddcc059e1a8"
},
{
"created_at": 1499676051757,
"id": "0x64537b9f7c9d85bae5c52cb4fa2307e7da14c6f1cae6d710b66a4ddcc059e1a8",
"score": 100000000000000,
"target": "https://some.path/"
}
]
}
Authored (TODO)¶
Identifier: authored, github:Userfeeds.algorithms.authored
This algorithm return all claims that were authored by context.
In other words all claims that have AUTHORED relation to Account node with id equal to context.
Parameters¶
type- string
- optional
Type of claims to return
Example data¶
{
"items": [
{
"created_at": 1499676051855,
"id": "0xaa6b523d72d1f0e9b00689f494ac622804e0552e55c939cabc97381bd401732b",
"score": 0,
"target": "0x64537b9f7c9d85bae5c52cb4fa2307e7da14c6f1cae6d710b66a4ddcc059e1a8"
},
{
"created_at": 1499675901184,
"id": "0xc3921abdd00ca53925e5a5b8559537d44e19165ff3ad4e89daf0bb034a4afa21",
"score": 10000000000000000,
"target": "Lorem ipsum dolor sit amet, consectetur adipisicing elit"
},
{
"created_at": 1499156515246,
"id": "0x85b6643f69e746c7525fc3ed88e1f18241068bcff6516fbf2dd0d967ebdaf390",
"score": 0,
"target": "0x794d0c42fc35af7eba9216261ea3799e19d079d24dcf795fda94acf20ad298f8"
}
]
}
Sponsored¶
Identifier: sponsored, github:Userfeeds.algorithms.sponsored
This algorithm is different form other as it does not use claims as a source of information but more low level transaction.input and as such works only for contexts like ethereum.
It just takes whatever is inside transaction.input sums up all transaction.value, sorts the result and returns those inputs as target.
The idea is that developer would send inside transaction.input only values that make sense for their application and only this application can display appropriate content for each entry.
An example application can be a gallery of images with identifiers like img1 img2... Using those identifiers as transaction.input values, developer can create special sponsored gallery in his application that will display images sorted by overall value of ether used to promote them.
Example application can be found at Quick Start.
Example data¶
{
"items": [
{
"bids": 2,
"score": 1.01,
"target": "0x636174"
},
{
"bids": 1,
"score": 1.0,
"target": "0x62697264"
},
{
"bids": 1,
"score": 0.333,
"target": "0x6b616e6761726f6f"
},
{
"bids": 1,
"score": 0.01,
"target": "0x646f67"
}
]
}
Links¶
Identifier: links, github:Userfeeds.algorithms.links
Time based algorithm that collects all claims with type link and sorts them according to formula:
period = 7 days
score = Sum(
if now - claim.create_at > period:
0
else:
claim.value / period * (now - claim.create_at)
)
Parameters¶
period- string
- optional
- default: 7 days
Period of time decay to use during calculations
whitelist- string
- optional
When present all claims type
whitelistandclaim.signature.creatorequal towhitelistparameter will be used as filtering mechanism. Whitelisting claim needs to specify link claimclaim.signature.signatureValuein it’sclaim.target.
Whitelisting¶
Ads algorithm has special property that allows for arbitrary list filtering based on whitelist parameter passed to it.
It works like that:
Algorithm gathers all claims with type link intended for given context and compares their signature.signatureValue with claim.target value of claims with signature.creator equal to whitelist parameter.
Example:
Link claims
| context | type | target | signatureValue |
|---|---|---|---|
| ethereum:0xA | link | http://some.url/1 | hashABC |
| ethereum:0xA | link | http://some.url/2 | hashDEF |
| ethereum:0xA | link | http://some.url/3 | hashGHI |
Whitelist claims
| target | creator |
|---|---|
| hashABC | ethereum:0xjohn |
| hashGHI | ethereum:0xjohn |
| hashABC | ethereum:0xalice |
| hashDEF | ethereum:0xbob |
Above combination will produce two links with whitelist parameter equal to ethereum:0xjohn:
| target |
|---|
| http://some.url/1 |
| http://some.url/3 |
with whitelist equal to ethereum:0xalice it will produce one link:
| target |
|---|
| http://some.url/1 |
and with ethereum:0xbob:
| target |
|---|
| http://some.url/2 |
if you omit whitelist in api call the algorithm will produce full set of links:
| target |
|---|
| http://some.url/1 |
| http://some.url/2 |
| http://some.url/3 |
Example data¶
{
"items": [
{
"id": "0xdddf6852e4e239cba808ebdb620535a30189cb5e66b2a4bdbc46e41c844543d6",
"score": 340000000000000000,
"summary": "Has nice pipelines",
"target": "https://bitbucket.org",
"title": "Bitbucket"
},
{
"id": "0xbc7dfcd2a2148cda1f763fb2d4713911c55c9f0d3fa56d62264c085f550a2586",
"score": 321923548932000000,
"summary": "Best social platform",
"target": "https://github.com",
"title": "GitHub"
},
{
"id": "0x943e5c024f04acd0352095a09c71b4e5ce6e5d789da588ad6aacdec859917cd6",
"score": 10000000000000000,
"summary": "Userfeeds Platform",
"target": "https://userfeeds.io/",
"title": "Userfeeds"
},
{
"id": "0xb4ed77fd554929f28c255279c307aedbd39510437e405693e5d84fd6a69b8fca",
"score": 10000000000000000,
"summary": "Status",
"target": "https://status.im/",
"title": "Status.im"
}
]
}
Hold (TODO)¶
Identifier: hold, github:Userfeeds.algorithms.hold
Simple algorithm that collects all claims and sorts them according to cumulative hold. Hold is holdings*time for given token. If someone has 10 ETH for 1 day then we can say he has hold of value 10, if he still has 10 ETH during next 6 days his hold will raise to 70.
Writing ranking algorithms¶
The best way to start writing your own algorithms is to look at the built-in one at https://github.io/Userfeeds/algorithms
TODO: ^^ more effort here please...
Data available for ranking algorithms¶
Database dumps can be found here:
Those data dumps are updated TODO:daily/hourly/constantly? and can be used for development and data analysis.
TODO: Import instructions
Note
Direct database access will be possible to our read-only instances for projects that require lower delays.
Claims¶
TODO
Balances and Aggregated data¶
TODO
Helper functions¶
TODO