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

label less fpof & pbad

parent 2fb4a208
Branches
No related tags found
No related merge requests found
......@@ -35,13 +35,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.26-SNAPSHOT</version>
</plugin>
-->
</plugins>
<resources>
<resource>
......@@ -52,14 +45,6 @@
</build>
<dependencies>
<!-- internal -->
<!--
<dependency>
<groupId>be.uantwerpen</groupId>
<artifactId>QCSP-pub</artifactId>
<version>1.0.0</version>
</dependency>
-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
......
......@@ -82,8 +82,8 @@ public class RunPBADEmbeddingOnly {
.filter((p) -> p.getType().equals("sequential patterns"))
.map((p) -> new File(Settings.FILE_FOLDER + p.getFilename()).getAbsolutePath())
.collect(Collectors.toList());
boolean onlyItemsets = item.getPatterns().size() > 0 && itemsetFilenames.size() == item.getPatterns().size();
boolean onlySequentialPatterns = item.getPatterns().size() > 0 && sequentialPatternFilenames.size() == item.getPatterns().size();
boolean onlyItemsets = !item.getPatterns().isEmpty() && itemsetFilenames.size() == item.getPatterns().size();
boolean onlySequentialPatterns = !item.getPatterns().isEmpty() && sequentialPatternFilenames.size() == item.getPatterns().size();
if(onlyItemsets) {
type = "itemset";
}
......
......@@ -574,7 +574,11 @@ public class PatternMiningController {
long elapsed = timer.elapsed();
//3.2 get evaluation metrics
Map<String,Double> results = computeAnomalyEvaluationMetrics(scoreFile, current_item.getFile(), "FPOF");
label = label.substring(0,label.length()-1) + String.format(Locale.ENGLISH, "; AUC=%.3f, AP=%.3f)", results.get("AUC"), results.get("AP"));
if(results.containsKey("AUC") && results.containsKey("AP"))
label = label.substring(0,label.length()-1) + String.format(Locale.ENGLISH, "; AUC=%.3f, AP=%.3f", results.get("AUC"), results.get("AP"));
else label = label.substring(0,label.length()-1) + "; Unkown precision missing labels";
//3.3 save project
AnomalyScores score = new AnomalyScores();
score.setAlgorithm("FPOF");
......@@ -585,7 +589,9 @@ public class PatternMiningController {
current_item.getScores().add(score);
current_item.getStackOperations().add("Anomaly detection " + label);
repository.save();
if(results.containsKey("AUC") && results.containsKey("AP"))
return String.format(Locale.ENGLISH, "Finished FPOF. Took %s. AUC=%.3f, AP=%.3f", Utils.milisToStringReadable(elapsed), results.get("AUC"), results.get("AP"));
else return String.format(Locale.ENGLISH, "Finished FPOF. Took %s. Unkown precision missing labels", Utils.milisToStringReadable(elapsed));
}
@RequestMapping(value="/rest/mining/anomaly-detection-pbad", method=RequestMethod.POST)
......@@ -624,7 +630,11 @@ public class PatternMiningController {
current_item.getScores().add(score);
current_item.getStackOperations().add("Anomaly detection " + label);
repository.save();
if(results.containsKey("AUC") && results.containsKey("AP")) {
return String.format("Finished PBAD. Took %s. AUC=%.3f, AP=%.3f", Utils.milisToStringReadable(elapsed), results.get("AUC"), results.get("AP"));
} else {
return String.format("Finished PBAD. Took %s. Unevluated missing labels", Utils.milisToStringReadable(elapsed));
}
}
private Map<String,Double> computeAnomalyEvaluationMetrics(File scoreFile, File itemFile, String method) throws IOException, InterruptedException {
......@@ -677,17 +687,16 @@ public class PatternMiningController {
//AP: 0.259
//<Finished took 1.04 seconds
Map<String,Double> evalMap = new HashMap<>();
try {
if(logStr.contains("AUC") && logStr.contains("AP")) {
Map<String,Double> evalMap = new HashMap<>(2);
//last line
Double auc = Double.valueOf(logStr.get(logStr.size()-3).split(":")[1]);
Double ap = Double.valueOf(logStr.get(logStr.size()-2).split(":")[1]);
//last line
evalMap.put("AUC", auc);
evalMap.put("AP",ap);
return evalMap;
}catch(Exception e) {
throw new RuntimeException(e);
}
return new HashMap<>();
}
}
......
......@@ -49,9 +49,9 @@ if __name__ == '__main__':
window_labels = df['Label'].values
ixl = np.where(window_labels != 0)[0]
# the roc score is a methode of evaluating reliability but it doesn't work if we didn't properly fill in the labels
auc = roc_auc_score(y_true=window_labels[ixl], y_score=scores[ixl]) if has_multiple_values(window_labels) else 0
if has_multiple_values(window_labels):
auc = roc_auc_score(y_true=window_labels[ixl], y_score=scores[ixl])
ap = average_precision_score(y_true=window_labels[ixl], y_score=scores[ixl])
print("AUC: {:.3f}".format(auc))
print("AP: {:.3f}".format(ap))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment