Wiki
Clone wikirealKD / using_realkd_in_java_project
Using realKD in your Java Project
##Dependency declaration via Maven##
In order to add realKD to a Java project that is managed via Maven you just have to add two snippets into your pom.xml.
First you have to register the realKD release repository to your <repositories>
section (create one if your pom does not yet contain one).
<repository> <id>realKD-releases</id> <url>https://bitbucket.org/realKD/releases/raw/master/releases</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>warn</checksumPolicy> </snapshots> </repository>
Moreover, you have to declare the realKD dependency in your <dependencies>
secion.
<dependency> <groupId>de.unibonn</groupId> <artifactId>realKD</artifactId> <version>0.5.1</version> <scope>compile</scope> </dependency>
##Example Code## When the dependency is declared correctly, you can use realKD. In the following basic example we also assume that the titanic example data file is available in the resource folder.
#!java /** * Runs the exceptional subgroup sampler on the titanic dataset with target * attribute "survived" and positive category "1". */ public class ExceptionalSubgroupSamplingForTitanic { public static void main(String[] args) { // Set up workspace with data import for algorithm Workspace workspace = workspace(); DataTable table = xarfImport("src//main//resources//titanic_1.0.0.xarf").get(); PropositionalLogic propositions = propositionalLogic(table); workspace.addAll(table, propositions); // Set up algorithm Attribute<?> survived = table.attribute(identifier("survived")).get(); ExceptionalSubgroupSampler sampler = exceptionalSubgroupSampler(workspace); sampler.targetAttributes(survived).useSingleEventModel().positiveCategory("1").numberOfResults(5) .numberOfSeeds(500); // Run and print results Collection<Pattern<?>> subgroups = sampler.call(); System.out.println(subgroups); } }
#!java import static de.unibonn.realkd.algorithms.emm.ExceptionalSubgroupSampler.exceptionalSubgroupSampler; import static de.unibonn.realkd.common.workspace.Identifier.identifier; import static de.unibonn.realkd.common.workspace.Workspaces.workspace; import static de.unibonn.realkd.data.propositions.Propositions.propositionalLogic; import static de.unibonn.realkd.data.table.XarfImport.xarfImport; import java.util.Collection; import de.unibonn.realkd.algorithms.emm.ExceptionalSubgroupSampler; import de.unibonn.realkd.common.workspace.Workspace; import de.unibonn.realkd.data.propositions.PropositionalLogic; import de.unibonn.realkd.data.table.DataTable; import de.unibonn.realkd.data.table.attribute.Attribute; import de.unibonn.realkd.patterns.Pattern;
Updated