{"id":50878395,"url":"https://github.com/Data2Semantics/mustard","last_synced_at":"2026-07-03T02:01:18.590Z","repository":{"id":13617404,"uuid":"16310572","full_name":"Data2Semantics/mustard","owner":"Data2Semantics","description":"mustard - Machine learning Using Svms To Analyse Rdf Data","archived":false,"fork":false,"pushed_at":"2017-04-25T07:48:21.000Z","size":2841,"stargazers_count":42,"open_issues_count":4,"forks_count":15,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-04-16T17:19:27.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Data2Semantics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-28T11:58:23.000Z","updated_at":"2024-01-13T14:18:02.000Z","dependencies_parsed_at":"2022-09-10T13:41:43.491Z","dependency_job_id":null,"html_url":"https://github.com/Data2Semantics/mustard","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Data2Semantics/mustard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Data2Semantics%2Fmustard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Data2Semantics%2Fmustard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Data2Semantics%2Fmustard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Data2Semantics%2Fmustard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Data2Semantics","download_url":"https://codeload.github.com/Data2Semantics/mustard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Data2Semantics%2Fmustard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35069183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-15T12:00:25.794Z","updated_at":"2026-07-03T02:01:18.584Z","avatar_url":"https://github.com/Data2Semantics.png","language":"Java","funding_links":[],"categories":["人工智能"],"sub_categories":["机器学习"],"readme":"mustard - Machine learning Using Svms To Analyse Rdf Data\n=========================================================\n\nVersion 0.1.0\n\nMustard is a machine learning library for learning from RDF data using kernel methods. Currently the library itself supports Support Vector Machines via the Java versions of the LibSVM and LibLINEAR libraries. Using mustard, classifiers can be learned for a set of nodes (i.e. resources, typically from the same rdfs:class) in an RDF graph/dataset. \n\nThis repository consists of 4 projects.\n\n- `mustard-kernels` is the heart of the library. It contains the graph kernels for RDF and the additional classes needed to handle RDF. This part of the library is the most well maintained and documented.\n- `mustard-learners` wraps LibSVM and LibLINEAR for use with the kernels defined in `mustard-kernels`. Together with `mustard-kernels` you can build SVM classifiers for RDF data.\n- `mustard-experiments` contains experiments and utility classes for experimenting with `mustard`.\n- `mustard-ducktape-experiments` contains classes to perform experiments with `mustard` using `ducktape`, which is also located in de Data2Semantics github. This part of the library is hardly maintained at the moment.\n\nContents\n--------\n1. Usage\n2. Kernel documentation\n3. LOD extension\n4. Dependencies\n5. JWS paper\n\n1. Usage\n--------\nThe `mustard-kernels` and `mustard-learners` project can be used together to build classifiers for RDF datasets. Examples of how this works in an experimental context can be found in `mustard-experiments`. Note that the library is currently mainly used for experimental comparisons between algorithms. \n\nThe general set up to build a classifier is as follows. Note that there are far more options and possibilities, the given example only contains the bare essentials.\n\nFirst, we need a dataset, for which we use the `RDFDataSet` class. Obviously other filetypes than N3 are also supported.\n```java\nRDFDataSet tripleStore = new RDFFileDataSet(\"some_filename.n3\", RDFFormat.N3);\n```\n\nThe instances that we want to build a classifier for are nodes/resources in this RDF graph. This list of instances can be supplied externally, or they can be extracted from the RDF, for example as shown below, where all resources that are the subject of `some_relation` are extracted. Note that the object of this relation is used as a label.\n```java\nList\u003cStatement\u003e stmts = tripleStore.getStatements(null, some_relation, null);\n\nList\u003cResource\u003e instances = new ArrayList\u003cResource\u003e();\nList\u003cValue\u003e labels \t = new ArrayList\u003cValue\u003e();\n\nfor (Statement stmt : stmts) {\n\tinstances.add(stmt.getSubject());\n\tlabels.add(stmt.getObject());\n}\n```\nIn a real-world classification task, the labels are typically only known for a part of the instances, i.e. the trainset. For the instances for which this label is unknown (i.e. the testset) we want to predict it. In our running example we know the label for all the instances.\n\nAfter the instances we likely also need a blacklist, which is a list of statements that should be ignored. Typically, we need this because these statements include the actual labels of the instances, which we do not want in the training (RDF) graph. There is a simple utility method for this.\n\n*NOTE 25/04/2017* - This method can be very dangerous if labels are primitives (like a boolean, int, etc.), since it puts any relation between the instance and its label on the blacklist (and also inverse relations). \n```java\nList\u003cStatement\u003e blackList = DataSetUtils.createBlacklist(tripleStore, instances, labels);\n```\n\nWith these object we can create an `RDFData` object, which can be used to compute a kernel matrix, as an example we take the `WLSubTreeKernel`, with some example parameters.\n```java\nRDFData data = new RDFData(tripleStore, instances, blackList);\nGraphKernel\u003cRDFData\u003e kernel = new RDFWLSubTreeKernel(4,2,true,true);\ndouble[][] matrix = kernel.compute(data);\n```\n\nThis kernel matrix can be used to train a Support Vector Machine (SVM) classifier) as follows.\n```java\nMap\u003cValue, Double\u003e labelMap = new HashMap\u003cValue,Double\u003e();\nList\u003cDouble\u003e target = EvaluationUtils.createTarget(labels, labelMap); // create a training target for LibSVM\n\ndouble[] cs = {1,10,100,1000};\t// C values to optimize the SVM over\nLibSVMParameters svmParms = new LibSVMParameters(LibSVMParameters.C_SVC, cs);\nLibSVMModel model = LibSVM.trainSVMModel(matrix, target, svmParms);\n```\n\nThis `model` can be used to make predictions using `LibSVM.testSVMModel()`. In a real-world scenario where not all the labels are known, the `KernelUtils` class contains utility functions to extract a train and test kernel matrix from a full  kernel matrix. This is needed because the kernel needs to be computed for both the training and test instances in one go. However, afterwards we need to get the part of the matrix that belongs to the trainset and the part that belongs to the testset.\n\n\n\n2. Kernel documentation\n-----------------------\nPlease see `/src/main/java/org/data2semantics/mustard/kernels/graphkernels/package-info.java` for the main documentation on the different graph kernels defined. Furthermore, see the Journal of Web Semantics 2015 paper: [“Substructure Counting Graph Kernels for Machine Learning from RDF data”, GKD de Vries, S de Rooij](http://www.sciencedirect.com/science/article/pii/S1570826815000657), for a detailed explanation and analysis of a large number of the kernels in this library.\n\n\n3. LOD extension\n----------------\nPart of the kernels available in this library are also available in the Linked Open Data extension, developed at the University of Mannheim, for the popular RapidMiner data mining software. See \u003chttp://dws.informatik.uni-mannheim.de/en/research/rapidminer-lod-extension/\u003e and \u003chttp://dws.informatik.uni-mannheim.de/en/research/rapidminer-lod-extension/rapid-miner-lod-extension-example-using-kernels-for-feature-generation/\u003e.\n\n4. Dependencies\n---------------\nMustard depends on the `nodes` graph library which is part of the Data2Semantics github. Furtermore, it depends on the SESAME triplestore (\u003chttp://rdf4j.org/\u003e) and `mustard-learners` depends on the Java version of LibLINEAR (\u003chttps://github.com/bwaldvogel/liblinear-java/\u003e).\n\nAll the 4 projects are Eclipse projects and congfigured using Maven, which takes care of the dependencies. The first 2 projects (`mustard-kernels` and `mustard-learners`) are submodules of one maven parent project (see the `pom.xml` in the root dir of this project). If you want to use them without Maven then you should make sure that the correct JAR's are on the classpath.\n\nIf you want to use `mustard-kernels` and `mustard-learners` (or the `nodes` project) as Maven artifacts, then this can easily be achieved using the excellent JitPack service (\u003chttps://jitpack.io/\u003e). Please see their documentation on multi module maven projects.\n\n\n5. JWS paper\n------------\nThis library was used for the Journal of Web Semantics 2015 paper: [“Substructure Counting Graph Kernels for Machine Learning from RDF data”, GKD de Vries, S de Rooij](http://www.sciencedirect.com/science/article/pii/S1570826815000657).\n\n\nWe used the following datasets in our experiments:\n  - The AIFB research portal (\u003chttp://figshare.com/articles/AIFB_DataSet/745364\u003e)\n  - The British Geological Survey (\u003chttp://figshare.com/articles/British_Geological_Survey/745365\u003e)\n  - Amsterdam Museum (\u003chttp://datahub.io/dataset/amsterdam-museum-as-edm-lod\u003e)\n  - DL Learner Mutagenic (\u003chttp://dl-learner.org/community/carcinogenesis/\u003e)\n\n\nMost of the experiments were run on a computing cluster. Using the `org.data2semantics.mustard.experiments.cluster.LocalExecutor.java` class the experiments can be rerun on a single machine. For the small experiments different settings are given as String constants in the top of the class. To rerun the large experiments, parameter files and susbsets of the datasets have to be created with `ParamsCreator.java` and `SubSetCreator.java`. Both of these are configured with some parameter settings at the top of the main() methods.\n\nThe computation time experiments can be found in `org.data2semantics.mustard.experiments.JWS2015`. In the top of the file a String constant sets the location of the dataset.\n\n\nAcknowledgements\n----------------\nThis library was developed in the context of the Data2Semantics project, part of the Dutch national project COMMIT/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FData2Semantics%2Fmustard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FData2Semantics%2Fmustard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FData2Semantics%2Fmustard/lists"}