Skip to content

Commit

Permalink
Merge pull request #16 from tommyippoz/Developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
tommyippoz committed Oct 24, 2019
2 parents 4ef11d7 + 8e3bcd7 commit 0883b11
Show file tree
Hide file tree
Showing 32 changed files with 1,175 additions and 363 deletions.
153 changes: 62 additions & 91 deletions RELOAD/doc/uml/RELOAD_ClassDiagram_Algorithm.ucls

Large diffs are not rendered by default.

132 changes: 85 additions & 47 deletions RELOAD/src/ippoz/reload/algorithm/DetectionAlgorithm.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
package ippoz.reload.algorithm;

import ippoz.reload.algorithm.custom.DBSCANDetectionAlgorithm;
import ippoz.reload.algorithm.custom.HBOSDetectionAlgorithm;
import ippoz.reload.algorithm.custom.LDCOFDBSCANDetectionAlgorithm;
import ippoz.reload.algorithm.custom.LDCOFKMeansDetectionAlgorithm;
import ippoz.reload.algorithm.elki.ABODELKI;
import ippoz.reload.algorithm.elki.COFELKI;
import ippoz.reload.algorithm.elki.FastABODELKI;
Expand Down Expand Up @@ -34,6 +38,8 @@
import ippoz.reload.decisionfunction.AnomalyResult;
import ippoz.reload.decisionfunction.DecisionFunction;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -124,6 +130,10 @@ public static DetectionAlgorithm buildAlgorithm(AlgorithmType algType, DataSerie
return new HBOSDetectionAlgorithm(dataSeries, conf);
case DBSCAN:
return new DBSCANDetectionAlgorithm(dataSeries, conf);
case LDCOF_KMEANS:
return new LDCOFKMeansDetectionAlgorithm(dataSeries, conf);
case LDCOF_DBSCAN:
return new LDCOFDBSCANDetectionAlgorithm(dataSeries, conf);
case ELKI_SOS:
return new SOSELKI(dataSeries, conf);
case ELKI_ISOS:
Expand Down Expand Up @@ -157,44 +167,71 @@ public static DetectionAlgorithm buildAlgorithm(AlgorithmType algType, DataSerie
case SLIDING_ELKI_KNN:
return new KNNSlidingELKI(dataSeries, conf);
case SLIDING_WEKA_ISOLATIONFOREST:
return new IsolationForestSlidingWEKA(dataSeries, conf);
default:
break;
return new IsolationForestSlidingWEKA(dataSeries, conf);
}
return null;
}

public static AlgorithmFamily getFamily(AlgorithmType algType) {
public static List<AlgorithmFamily> getFamily(AlgorithmType algType) {
List<AlgorithmFamily> afl = new LinkedList<AlgorithmFamily>();
switch(algType){
case ELKI_SOS:
case ELKI_ISOS:
case HBOS:
case SLIDING_SPS:
return AlgorithmFamily.STATISTICAL;
afl.add(AlgorithmFamily.STATISTICAL);
default:
break;
}
switch(algType){
case ELKI_KMEANS:
case SLIDING_ELKI_CLUSTERING:
case DBSCAN:
return AlgorithmFamily.CLUSTERING;
case LDCOF_KMEANS:
case LDCOF_DBSCAN:
afl.add(AlgorithmFamily.CLUSTERING);
default:
break;
}
switch(algType){
case ELKI_ABOD:
case ELKI_FASTABOD:
case SLIDING_ELKI_ABOD:
return AlgorithmFamily.ANGLE;
afl.add(AlgorithmFamily.ANGLE);
default:
break;
}
switch(algType){
case ELKI_LOF:
case ELKI_COF:
case LDCOF_KMEANS:
case LDCOF_DBSCAN:
case SLIDING_ELKI_COF:
return AlgorithmFamily.DENSITY;
afl.add(AlgorithmFamily.DENSITY);
default:
break;
}
switch(algType){
case ELKI_KNN:
case ELKI_ODIN:
case SLIDING_ELKI_KNN:
return AlgorithmFamily.NEIGHBOUR;
case ELKI_FASTABOD:
case ELKI_LOF:
case ELKI_COF:
case ELKI_ISOS:
afl.add(AlgorithmFamily.NEIGHBOUR);
default:
break;
}
switch(algType){
case ELKI_SVM:
case WEKA_ISOLATIONFOREST:
case SLIDING_WEKA_ISOLATIONFOREST:
return AlgorithmFamily.CLASSIFICATION;
default:
break;
afl.add(AlgorithmFamily.CLASSIFICATION);
default:
break;
}
return null;
return afl;
}

public static KnowledgeType getKnowledgeType(AlgorithmType algType) {
Expand All @@ -203,36 +240,6 @@ public static KnowledgeType getKnowledgeType(AlgorithmType algType) {
else return KnowledgeType.SINGLE;
}

public static boolean isSeriesValidFor(AlgorithmType algType, DataSeries dataSeries) {
switch(algType){
case ELKI_ABOD:
case ELKI_COF:
case ELKI_FASTABOD:
case ELKI_KMEANS:
case ELKI_LOF:
case ELKI_ODIN:
case ELKI_SVM:
case ELKI_KNN:
case ELKI_SOS:
case ELKI_ISOS:
case HBOS:
case DBSCAN:
case SLIDING_ELKI_ABOD:
case SLIDING_ELKI_CLUSTERING:
case SLIDING_ELKI_COF:
case SLIDING_ELKI_KNN:
return true;
case SLIDING_SPS:
return true;
case SLIDING_WEKA_ISOLATIONFOREST:
case WEKA_ISOLATIONFOREST:
return dataSeries.size() > 1;
default:
break;
}
return false;
}

/**
* Builds a DetectionAlgorithm.
*
Expand Down Expand Up @@ -441,6 +448,9 @@ public static String explainParameters(AlgorithmType algType) {
case ELKI_KMEANS:
case SLIDING_ELKI_CLUSTERING:
return base + "(k) the number of clusters.";
case LDCOF_KMEANS:
return base + "(k) the number of clusters, <br>"
+ "(gamma) the LDCOF parameter to separate small/large clusters";
case ELKI_SVM:
return base + "(kernel) the type of kernel, <br>"
+ "(nu) an upper bound on the fraction of margin errors and a lower bound <br>"
Expand All @@ -458,6 +468,13 @@ public static String explainParameters(AlgorithmType algType) {
case SLIDING_WEKA_ISOLATIONFOREST:
return "Parameters: (ntrees) number of trees in the forest, <br>"
+ "(sample_size) instances to be sampled to train each tree.";
case DBSCAN:
return base + "(eps) defines the radius of neighborhood around a data point, <br>"
+ "(pts) is the minimum number of neighbors within 'eps' radius";
case LDCOF_DBSCAN:
return base + "(eps) defines the radius of neighborhood around a data point, <br>"
+ "(pts) is the minimum number of neighbors within 'eps' radius, <br>"
+ "(gamma) the LDCOF parameter to separate small/large clusters";
default:
return "Parameters are shown in the table.";
}
Expand All @@ -472,6 +489,12 @@ public static String explainAlgorithm(AlgorithmType algType) {
+ "The smaller the ABOF, the greater the anomality of the data point.";
case SLIDING_ELKI_ABOD:
return "Sliding version of ABOD.";
case ELKI_SOS:
return "Statistical algorithm. <br>"
+ "It takes as input either a feature matrix or a dissimilarity matrix and outputs for each data point an outlier probability. <br>"
+ "Intuitively, a data point is considered to be an outlier when the other data points have insufficient affinity with it.";
case ELKI_ISOS:
return "Fast version of SOS (Intrinsic SOS), calculating dissimilarity with the kNN of the data point.";
case ELKI_LOF:
return "Local Outlier Factor algorithm. <br>"
+ "LOF is based on a concept of a local density, where locality is given by kNN, <br>"
Expand Down Expand Up @@ -514,15 +537,30 @@ public static String explainAlgorithm(AlgorithmType algType) {
return "Creates a forest of Isolation Trees, which are evaluated as an ensemble.";
case SLIDING_WEKA_ISOLATIONFOREST:
return "Sliding version of Isolation Forest";
case DBSCAN:
return "DBSCAN is based on this intuitive notions of 'clusters' and 'radius'. <br>"
+ "The key idea is that for each point of a cluster, the neighborhood of a given radius has to contain at least a minimum number of points.";
case LDCOF_KMEANS:
case LDCOF_DBSCAN:
return "Local Density Cluster-Based Outlier Factor (LDCOF). <br>"
+ "The LDCOF score is defined as the distance to the nearest large cluster divided by the average distance of each element <br>"
+ "to the center of the large cluster. When small clusters are considered anomalous, the elements inside the small clusters <br>"
+ "are assigned to the nearest large cluster which becomes its local neighborhood. <br>"
+ "It can be istantiated with any clustering algorithm, in RELOAD with KMeans or DBSCAN.";
default:
return "Algorithms' details not available.";
}
}

public static AlgorithmType[] availableAlgorithms(){
return new AlgorithmType[]{AlgorithmType.HBOS, AlgorithmType.ELKI_KMEANS, AlgorithmType.DBSCAN, AlgorithmType.ELKI_ABOD, AlgorithmType.ELKI_SOS, AlgorithmType.ELKI_ISOS, AlgorithmType.ELKI_COF, AlgorithmType.ELKI_FASTABOD,
AlgorithmType.ELKI_LOF, AlgorithmType.ELKI_ODIN, AlgorithmType.ELKI_SVM, AlgorithmType.ELKI_KNN, AlgorithmType.WEKA_ISOLATIONFOREST,
AlgorithmType.SLIDING_SPS, AlgorithmType.SLIDING_ELKI_CLUSTERING, AlgorithmType.SLIDING_ELKI_COF, AlgorithmType.SLIDING_ELKI_KNN};
private static AlgorithmType[] temporaryAlgorithms(){
return new AlgorithmType[]{AlgorithmType.SLIDING_WEKA_ISOLATIONFOREST};
}

public static List<AlgorithmType> availableAlgorithms(){
List<AlgorithmType> types = new LinkedList<AlgorithmType>();
types.addAll(Arrays.asList(AlgorithmType.values()));
types.removeAll(Arrays.asList(temporaryAlgorithms()));
return types;
}

public abstract Map<String, String[]> getDefaultParameterValues();
Expand Down
Loading

0 comments on commit 0883b11

Please sign in to comment.