Package: typedb-ml
TypeDB-MLPreviously known as KGLIB.TypeDB-ML provides tools to enable graph algorithms and machine learning withTypeDB.There are integrations forNetworkXand forPyTorch Geometric (PyG).NetworkXintegration allows you to use alarge library of algorithmsover graph data exported from TypeDB.PyTorch Geometric (PyG)integration gives you a toolbox to build Graph Neural Networks (GNNs) for your TypeDB data, with an example included for link prediction (or: binary relation prediction, in TypeDB terms). The structure of the GNNs are totally customisable, with network components for popular topics such as graph attention and graph transformers built-in.FeaturesNetworkXDeclare the graph structure of your queries, with optional sampling functions.Query a TypeDB instance and combine many results across many queries into a single graph (build_graph_from_queries).PyTorch GeometricADataSetobject to lazily load graphs from a TypeDB instance. Each graph is converted to a PyGDataobject.It's most natural to work with PyGHeteroDataobjects since all data in TypeDB has a type. Conversion fromDatatoHeteroDatais available in PyG, but it loses node ordering information. To remedy this, TypeDB-ML providesstore_concepts_by_typeto store concepts consistent with aHeteroDataobject. This enables concepts to be properly re-associated with predictions after learning is finished.AFeatureEncoderto orchestrate encoders to generate features for graphs.Encoders for Continuous and Categorical values to apply encodings/embedding spaces to the types and attribute values present in TypeDB data.Afull example for link predictionOtherExample usage of Tensorboard for PyGHeteroDataResourcesYou may find the following resources useful, particularly to understand why TypeDB-ML started:Strongly Typed Data for Machine Learning(YouTube, 2021)How Can We Complete a Knowledge Graph?(YouTube, 2018)QuickstartInstallPython >= 3.7.xGrab therequirements.txtfile fromhereand install the requirements withpip install -r requirements.txt. This is due to some intricacies installing PyG's dependencies, seeherefor details.Installed TypeDB-ML:pip install typedb-ml.TypeDB 2.11.1running in the background.typedb-client-python2.11.x (PyPi,GitHub release). This should be installed automatically when youpip install typedb-ml.Run the ExampleTake a look at thePyTorch Geometric heterogeneous link prediction exampleto see how to use TypeDB-ML to build a GNN on TypeDB data.DevelopmentTo follow the development conversation, please join theVaticle Discord, and join the#typedb-mlchannel. Alternatively, start a new topic on theVaticle Discussion Forum.TypeDB-ML requires that you have migrated your data into aTypeDBor TypeDB
Cluster instance. There is anofficial examples repofor how to go about this, and information available onmigration in the docs. Alternatively, there are fantastic community-led projects growing in theTypeDB OSIto facilitate fast and easy data loading, for exampleTypeDB Loader.Building from SourceIt's expected that you will use Pip to install, but should you need to make your own changes to the library, and import it into your project, you can build from source as follows:Clone TypeDB-ML:git clone git@github.com:vaticle/typedb-ml.gitGo into the project directory:cd typedb-mlBuild all targets:bazel build //...Run all tests. Requires Python 3.7+ on yourPATH. Test dependencies are for Linux since that is the CI environment:bazel test //typedb_ml/... --test_output=streamed --spawn_strategy=standalone --action_env=PATHBuild the pip distribution. Outputs tobazel-bin:bazel build //:assemble-pip