A package for reasoning with tensors
Project description
tensor-reasoning
Represent Knowledge Graphs as tensors to perform logic calculus and regression.
Usage
This module can be used for different tasks, as demonstrated in the examples
folder.
Generation of Random Knowledge Graphs
Given a set of logical formulas a Markov Logic Network can be created using the Basis Calculus. One can then sample from the model to generate random data, in this case interpreted as a Random Knowledge Graph.
An example can be found in examples/generation/generate_accounting_kg.py
.
Learning of logical formulas
Given a Knowledge Graph and positive and negative examples (each a pair of individuals), one can learn a logical formula true on the positive and false on the negative examples. To this end optimization via Alternating Least Squares has been implemented.
Examples can be found in examples/learning/
.
Packages
Logic
Coordinate Calculus: CoordinateCalculus
main class for coordinate-based calculus of logical formulas.
Basis Calculus: BasisCalculus
main class for basis-vector-based calculus of logical formulas.
Expression Calculus: Evaluation of expressions given dictionaries of CoordinateCalculus
/BasisCalculus
objects.
Optimization
generalized_als.py
Performs the Alternating Least Squares to solve tensor regression problems.
Learning
expression_learning.py
Optimizes formulas using Coordinate Calculus and the Alternating Least Squares.
mln_learning.py
Learns Markov Logic Networks based on data.
Models
markov_logic_network.py
Creates a Markov Logic Network using Basis Calculus based on pgmpy.models.MarkovNetwork
.
Representation
On KG represented in turtle files:
ttl_to_csv.py
Transform turtle file into a DataFrame containing facts.
factdf_to_cores.py
Transforms the fact DataFrame into CoordinateCalculus Cores in the variable-based representation.
pairdf_to_cores.py
Uses the pair DataFrame to initialize the targetCore.
sampledf_to_cores.py
Transform sample DataFrame into CoordinateCalculus Cores in the atom-based representation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tnreason-0.0.tar.gz
.
File metadata
- Download URL: tnreason-0.0.tar.gz
- Upload date:
- Size: 32.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3393b174d354477760168685f780fbf2b9ec1b20cf96e46117821577e936cb4 |
|
MD5 | 74aa448aa7d5bfcd9ebc1d6b954edcc1 |
|
BLAKE2b-256 | 6c917b4907560129b82e395f43c9a723060baa0f0146c64631d17bbe39b4c1a8 |
File details
Details for the file tnreason-0.0-py3-none-any.whl
.
File metadata
- Download URL: tnreason-0.0-py3-none-any.whl
- Upload date:
- Size: 39.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a60a427fe8e355afd0f63a99e2be97c5fcfd5a12399e4d17b2d39bfe55e7ebfe |
|
MD5 | 25c9faa40286789bdc536d228f0f3249 |
|
BLAKE2b-256 | 4d7312c4dc49f0ae2f2ae2c548c3a97e12335b0e18101a7bbf5c39bbc16c2fde |