Skip to content
Snippets Groups Projects
Unverified Commit bf555849 authored by marc's avatar marc Committed by BARBIER Marc
Browse files

Settings and workspange changes

Added a setting to change the memory allocated to TPMS and simplifing the change of the timeout (i will later crate somthing in the web ui for that)

removed IDE files from the project and gitignored them.
this way no user-specific information is stored with the code and only what matter is kept
parent a2a91baf
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,14 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/spmf.jar"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
......@@ -28,5 +30,22 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
......@@ -4,3 +4,7 @@
/target/
*.class
/bin/
data/
.vscode
.project
.settings
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tipm_pub</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
......@@ -13,7 +13,7 @@ import ca.pfv.spmf.algorithmmanager.DescriptionOfAlgorithm;
public class MineUsingSPMF {
public File runItemsetMining(File arff, List<String> columns, String algorithm, double support) throws Exception {
public static File runItemsetMining(File arff, List<String> columns, String algorithm, double support) throws Exception {
//check if algorithm exists
if(!checkAlgorithmExists(algorithm, true))
return null;
......@@ -21,16 +21,20 @@ public class MineUsingSPMF {
//java -jar spmf.jar run Apriori contextPasquier99.txt output.txt 40%
File log = new File("./temp/pattern_mining_" + arff.getName() + ".log");
File outputRaw = new File("./temp/" + algorithm + "_out_raw_" + arff.getName() + ".txt");
long timeOutSeconds = 10;
CommandLineUtils.runCommandInUserDir(new String[]{"java","-jar", new File(Settings.SPMF_JAR).getAbsolutePath(), "run", algorithm,
CommandLineUtils.runCommandInUserDir(new String[]{"java", "-Xmx" + Settings.SMPF_MAX_RAM_ALLOCATION, "-jar", new File(Settings.SPMF_JAR).getAbsolutePath(), "run", algorithm,
dictFile_transFile_pair.getSecond().getAbsolutePath(),
outputRaw.getAbsolutePath(), "" + support + "%"}, log,
timeOutSeconds);
Settings.SMPF_TIMEOUT);
IOUtils.printHead(log, 100);
String logStr = IOUtils.readFileFlat(log);
if(logStr.contains("Exception")) {
throw new Exception("Exception during mining with SPMF.\n" + logStr);
}
if(logStr.contains("Invalid maximum heap size: -Xmx")) {
throw new Exception("Invalid maximum heap size" + Settings.SMPF_MAX_RAM_ALLOCATION);
}
File outputReadable = new File(Settings.FILE_FOLDER, arff.getName() + "_" + algorithm + "_" + CollectionUtils.join(columns,"_") + "_" + support + "_patterns.csv");
ArffToSPMF.saveOutputReadable(arff.getName(), dictFile_transFile_pair.getFirst(), outputRaw, outputReadable);
if(outputReadable.exists() && !IOUtils.isEmptyFile(outputReadable)) {
......@@ -42,7 +46,7 @@ public class MineUsingSPMF {
return outputReadable;
}
public File runSequentialPatternMining(File arff, List<String> columns, String algorithm, double support) throws Exception {
public static File runSequentialPatternMining(File arff, List<String> columns, String algorithm, double support) throws Exception {
//check if algorithm exists
if(!checkAlgorithmExists(algorithm, false))
return null;
......@@ -50,16 +54,21 @@ public class MineUsingSPMF {
//java -jar spmf.jar run Apriori contextPasquier99.txt output.txt 40%
File log = new File("./temp/pattern_mining_" + arff.getName() + ".log");
File outputRaw = new File("./temp/" + algorithm + "_out_raw_" + arff.getName() + ".txt");
long timeOutSeconds = 10;
CommandLineUtils.runCommandInUserDir(new String[]{"java","-jar", new File(Settings.SPMF_JAR).getAbsolutePath(), "run", algorithm,
CommandLineUtils.runCommandInUserDir(new String[]{"java", "-Xmx" + Settings.SMPF_MAX_RAM_ALLOCATION, "-jar", new File(Settings.SPMF_JAR).getAbsolutePath(), "run", algorithm,
dictFile_transFile_pair.getSecond().getAbsolutePath(),
outputRaw.getAbsolutePath(), "" + support + "%"}, log,
timeOutSeconds);
Settings.SMPF_TIMEOUT);
IOUtils.printHead(log, 100);
String logStr = IOUtils.readFileFlat(log);
if(logStr.contains("Exception")) {
throw new Exception("Exception during mining with SPMF.\n" + logStr);
}
if(logStr.contains("Invalid maximum heap size: -Xmx")) {
throw new Exception("Invalid maximum heap size" + Settings.SMPF_MAX_RAM_ALLOCATION);
}
File outputReadable = new File(Settings.FILE_FOLDER, arff.getName() + "_" + algorithm + "_" + CollectionUtils.join(columns,"_") + "_" + support + "_patterns.csv");
ArffToSPMF.saveOutputReadable(arff.getName(), dictFile_transFile_pair.getFirst(), outputRaw, outputReadable);
if(outputReadable.exists() && !IOUtils.isEmptyFile(outputReadable)) {
......@@ -71,7 +80,7 @@ public class MineUsingSPMF {
return outputReadable;
}
private boolean checkAlgorithmExists(String algorithm, boolean itemsets) {
private static boolean checkAlgorithmExists(String algorithm, boolean itemsets) {
try {
DescriptionOfAlgorithm description = AlgorithmManager.getInstance().getDescriptionOfAlgorithm(algorithm);
if(description == null) {
......
package be.uantwerpen.mime_webapp;
public class Settings {
public static String FILE_FOLDER = "./data/upload/";
public static String DATA_FILE = "./data/projects.xml";
public static String SPMF_JAR = "./lib/spmf.jar";
public static String PBAD = "../pbad-public/";
public static String PYTHON3 = "/usr/local/bin/python3";
//we mask the constructor to protect from any useless instances
private Settings(){}
public static final String SMPF_MAX_RAM_ALLOCATION = "2G";
public static final String FILE_FOLDER = "./data/upload/";
public static final String DATA_FILE = "./data/projects.xml";
public static final String SPMF_JAR = "./lib/spmf.jar";
public static final String PBAD = "../pbad-public/";
public static final String PYTHON3 = "/usr/local/bin/python3";
public static final long SMPF_TIMEOUT = 10;
}
......@@ -54,7 +54,6 @@ public class PatternMiningController {
@Autowired
ProjectRepository repository;
MineUsingSPMF minerSPMF = new MineUsingSPMF();
MakePatternOccurrences makePatternOccurrences = new MakePatternOccurrences();
MakePatternOccurrencesSpan makePatternOccurrencesSpan = new MakePatternOccurrencesSpan();
RunPBADEmbeddingOnly runPBADEmbeddingOnly = new RunPBADEmbeddingOnly();
......@@ -73,16 +72,12 @@ public class PatternMiningController {
throw new RuntimeException("Only Arff supported");
File data = currentInput.getFile();
Double supportAsFloat = Double.valueOf(support);
File outputReadable = minerSPMF.runItemsetMining(data, Arrays.asList(columnsArr), algorithm, supportAsFloat);
File outputReadable = MineUsingSPMF.runItemsetMining(data, Arrays.asList(columnsArr), algorithm, supportAsFloat);
savePatterns(request.getSession(), currentInput.getFile(), outputReadable, "itemsets", columns, algorithm, support);
File occurrencesFile = storePatternSetOccurrences(outputReadable.getName(),request);
savePatternsWithMetadata(outputReadable, occurrencesFile,currentInput.getFile());
return String.format("Found %d patterns.",IOUtils.countLines(outputReadable)-1);
}
catch(InterruptedException e) {
e.printStackTrace();
throw(new RuntimeException(e.getMessage()));
}
catch (Exception e) {
e.printStackTrace();
throw(new RuntimeException(e.getMessage()));
......@@ -103,7 +98,7 @@ public class PatternMiningController {
throw new RuntimeException("Only Arff supported");
File data = currentInput.getFile();
Double supportAsFloat = Double.valueOf(support);
File outputReadable = minerSPMF.runSequentialPatternMining(data, Arrays.asList(columnsArr), algorithm, supportAsFloat);
File outputReadable = MineUsingSPMF.runSequentialPatternMining(data, Arrays.asList(columnsArr), algorithm, supportAsFloat);
savePatterns(request.getSession(), currentInput.getFile(), outputReadable, "sequential patterns", columns, algorithm, support);
File occFile = storePatternSetOccurrences(outputReadable.getName(),request);
savePatternsWithMetadata(outputReadable, occFile, currentInput.getFile());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment