Giter Site home page Giter Site logo

verenablaschke / psl-ragviewer Goto Github PK

View Code? Open in Web Editor NEW
1.0 5.0 0.0 112 KB

JavaFX-based GUI for inspecting PSL inference results

License: Apache License 2.0

Java 97.38% CSS 2.62%
visual-model-inspection probabilistic-soft-logic explainable-reasoning

psl-ragviewer's Introduction

PSL RAGviewer

This package contains code for inspecting the inference results of a Probabilistic Soft Logic (PSL) model by navigating its rule-atom graph (RAG).

The FactWindow is a JavaFX-based atom browser that explains each atom's inferred value based on the ground rules in which appears. The associated rules can be shown in the form of rule groundings or as textual explanations that express how the context atom's value fits into the rule's reasoning pattern, or how it violates it. To create a PSL RAG that is inspectable this way, use the code in the psl-infrastructure package, which provides a Java API for the PSL framework as well as the code necessary for creating natural language verbalization templates of rules and predicates.

Usage

import de.tuebingen.sfs.psl.engine.InferenceResult;
import de.tuebingen.sfs.psl.engine.ProblemManager;
import de.tuebingen.sfs.psl.engine.RuleAtomGraph;
import de.tuebingen.sfs.psl.gui.StandaloneFactWindowLauncher;

public class MyApp {

	public static void main(String[] args) {
		ProblemManager problemManager = ProblemManager.defaultProblemManager();

		// Create custom classes MyConfig, MyProblem, and MyIdeaGenerator
		// that extend the de.tuebingen.sfs.psl.engine classes
		// PslProblemConfig, PslProblem, and IdeaGenerator, respectively.
		MyConfig config = new MyConfig();
		// Use the PslProblem class to define the rules and predicates:
		MyProblem problem = new MyProblem(config);
		MyIdeaGenerator ideaGen = new MyIdeaGenerator(problem);
		// Add all (target and observation) atoms that should be used for the inference:
		ideaGen.generateAtoms();
		// Run the inference:
		InferenceResult result = problemManager.registerAndRunProblem(problem);
		// Inspect the results:
		ConstantRenderer constantRenderer = null;
		boolean sortSidebar = true;
		boolean printExplanationsToConsole = false;
		StandaloneFactWindowLauncher.launchWithData(constantRenderer, problem, result, sortSidebar, printExplanationsToConsole);
	}

}

Example

For a very simple example problem, please run the sample application. The logic behind the corresponding psl-infrastructure class is explained in that package's wiki.

To run the sample code, you need to create a new IntelliJ project into which you clone both psl-infrastructure and psl-ragviewer. IntelliJ should recognize both of them as Java modules. (Make sure each module's src/main/java and src/main/resources directories are added as module roots! If there are build problems, open the Java compiler settings via File > Settings > Build, Execution, Deployment > Compiler > Java Compiler and deselect Use '--release' option for cross-compilation.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.