This service loads a knowledge base into an instance of Opencog and run Opencog's Pattern Miner. The best ranked results are returned as a list of atoms in Atomese.
It's part of our Opencog Services.
The service expects an URL to an Atomese knowledge base and 4 parameters which are passed to pattern miner itself to control its behavior (see here for an explanation on how those parameters control the pattern miner algorithm.
Parameters:
- minsup - Integer - Minimum support - the mining algorithm discards patterns with frequency below that value.
- maxiter - Integer - Maximum iterations - limits the number of iterations of the mining algorithm.
- incremental-expansion - Boolean (#t or #f) - allows increasing number of conjuncts.
- max-conjuncts - Integer - limits the number of conjunctions considered by the mining algorithm.
A simple example of knowledge base is presented here.
The service is meant to illustrate the implementation of an actual Opencog service. Unlike other example services (like echo), this service does some relevant Opencog processing.
You can use this service from SingularityNET DApp, clicking on SNET/Opencog
.
You can also call the service from SingularityNET CLI (snet
). See
here for detailed information on how SingularityNET CLI works or
use the helper scripts from opencog-services repository as described below.
Clone the repository to use the scripts.
git clone [email protected]:singnet/opencog-services.git
First, make sure your session have an identity with your private key.
$ snet identity create YOUR_ID key
YOUR_ID
is a local id used only in the current session so it's not really
important. Any string should work. You will be requested to enter your private
key.
Now you need to add funds to a MPE channel.
$ ./scripts/deposit_mpe.sh
This script will print the balances and a list of all chanels of your identity.
Look for the #channelId
of the last listed channel. This is the channel which
will be used to make the client calls below.
$ ./scripts/client_request.sh Miner KNOWLEDGE_BASE_URL MIN_SUP MAX_ITER INCR_EXP MAX_CONJ
The following command line will call the Pattern Miner on the Ugly male soda-drinkers knowledge base:
$ ./scripts/client_request.sh Miner https://raw.githubusercontent.com/singnet/opencog/master/examples/learning/miner/ugly-male-soda-drinker/kb.scm 5 100 \#t 3
Pattern Miner can take several minutes (or even hours) to execute depending on the size of the knowledge base and the parameters (max-conjuncts is a specially critical parameter). See Pattern Miner Documentation to understand how it works and how each parameter can affect the expected results.
So you may want to execute Pattern Miner asynchronously:
$ ./scripts/client_request_async.sh Miner https://raw.githubusercontent.com/singnet/opencog/master/examples/learning/miner/ugly-male-soda-drinker/kb.scm 5 100 \#t 3
In this case the command output is an URL where you can find the results as soon as they are available. Results will remain available for a limited time (see [general-guide](Opencog Services documentation) for details).
For the Ugly male soda-drinkers knowledge base, Pattern Miner (with aforementioned parameters) should output something like:
(SetLink
(LambdaLink
(VariableList
(VariableNode "$PM-793e6063")
(VariableNode "$PM-762382f3")
)
(AndLink
(InheritanceLink
(VariableNode "$PM-793e6063")
(VariableNode "$PM-762382f3")
)
(InheritanceLink
(VariableNode "$PM-793e6063")
(ConceptNode "ugly")
)
(InheritanceLink
(ConceptNode "Cason")
(VariableNode "$PM-762382f3")
)
)
)
(LambdaLink
(VariableNode "$PM-793e6063")
(AndLink
(InheritanceLink
(VariableNode "$PM-793e6063")
(ConceptNode "man")
)
(InheritanceLink
(VariableNode "$PM-793e6063")
(ConceptNode "soda drinker")
)
)
)
...
Please read our guidelines before submitting issues or pull requests.
- SNET service - Andre Senna - Maintainer - SingularityNET
- Opencog's Pattern Miner - see here