Skip to content

Commit 6c60497

Browse files
committed
Move ML-Plan model selection to new Maven module
1 parent 05c4bc2 commit 6c60497

File tree

6 files changed

+61
-52
lines changed

6 files changed

+61
-52
lines changed

ml2plan-model-selection/pom.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>de.fraunhofer.iem</groupId>
8+
<artifactId>swan</artifactId>
9+
<version>3.3.1</version>
10+
</parent>
11+
12+
<artifactId>ml2plan-model-selection</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>17</maven.compiler.source>
16+
<maven.compiler.target>17</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<repositories>
21+
<repository>
22+
<id>scijava-public</id>
23+
<url>https://maven.scijava.org/content/repositories/public/</url>
24+
</repository>
25+
</repositories>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>ai.libs</groupId>
30+
<artifactId>hasco-core</artifactId>
31+
<version>0.2.7</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>ai.libs</groupId>
35+
<artifactId>jaicore-algorithminspector</artifactId>
36+
<version>0.2.7</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>ai.libs</groupId>
40+
<artifactId>mlplan-meka</artifactId>
41+
<version>0.2.7</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.graphstream</groupId>
45+
<artifactId>gs-ui-javafx</artifactId>
46+
<version>2.0</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.github.mwever</groupId>
50+
<artifactId>gs-core</artifactId>
51+
<version>2.0.2-synchrofix</version>
52+
</dependency>
53+
54+
</dependencies>
55+
56+
</project>

swan-cmd/src/main/java/de/fraunhofer/iem/swan/model/toolkit/ML2Plan.java renamed to ml2plan-model-selection/src/main/java/de/fraunhofer/iem/ML2Plan.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.fraunhofer.iem.swan.model.toolkit;
1+
package de.fraunhofer.iem;
22

33
import ai.libs.jaicore.ml.classification.multilabel.dataset.IMekaInstances;
44
import ai.libs.jaicore.ml.classification.multilabel.dataset.MekaInstances;
@@ -8,10 +8,6 @@
88
import ai.libs.jaicore.ml.core.filter.SplitterUtil;
99
import ai.libs.mlplan.core.MLPlan;
1010
import ai.libs.mlplan.meka.ML2PlanMekaBuilder;
11-
import de.fraunhofer.iem.swan.cli.SwanOptions;
12-
import de.fraunhofer.iem.swan.features.MekaFeatureSet;
13-
import de.fraunhofer.iem.swan.io.dataset.SrmList;
14-
import de.fraunhofer.iem.swan.model.ModelEvaluator;
1511
import meka.core.MLUtils;
1612
import org.api4.java.ai.ml.classification.multilabel.evaluation.IMultiLabelClassification;
1713
import org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset;
@@ -32,34 +28,14 @@
3228
public class ML2Plan {
3329

3430
private static final Logger LOGGER = LoggerFactory.getLogger(ML2Plan.class);
35-
private MekaFeatureSet featureSet;
31+
/* private MekaFeatureSet featureSet;
3632
private SwanOptions swanOptions;
3733
3834
public ML2Plan(MekaFeatureSet features, SwanOptions options) {
3935
this.featureSet = features;
4036
swanOptions = options;
41-
}
42-
43-
/**
44-
* Trains and evaluates the model with the given training data and specified classification mode.
45-
*
46-
* @return Hashmap containing the name of the classifier and it's F-Measure
47-
*/
48-
public SrmList trainModel() {
49-
50-
switch (ModelEvaluator.Phase.valueOf(swanOptions.getPhase().toUpperCase())) {
51-
case VALIDATE:
37+
}*/
5238

53-
try {
54-
crossValidate(featureSet.getTrainInstances().get("meka"));
55-
} catch (Exception e) {
56-
throw new RuntimeException(e);
57-
}
58-
return null;
59-
case PREDICT:
60-
}
61-
return null;
62-
}
6339

6440
public void crossValidate(Instances instances) throws Exception {
6541

swan-cmd/pom.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,6 @@
105105
<artifactId>deeplearning4j-nlp</artifactId>
106106
<version>${dl4j-master.version}</version>
107107
</dependency>
108-
<dependency>
109-
<groupId>ai.libs</groupId>
110-
<artifactId>mlplan-meka</artifactId>
111-
<version>0.2.7</version>
112-
</dependency>
113-
<dependency>
114-
<groupId>org.graphstream</groupId>
115-
<artifactId>gs-ui-javafx</artifactId>
116-
<version>2.0</version>
117-
</dependency>
118-
<dependency>
119-
<groupId>ai.libs</groupId>
120-
<artifactId>hasco-core</artifactId>
121-
<version>0.2.7</version>
122-
</dependency>
123108
<dependency>
124109
<groupId>org.slf4j</groupId>
125110
<artifactId>slf4j-api</artifactId>

swan-cmd/src/main/java/de/fraunhofer/iem/swan/cli/CliRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class CliRunner implements Callable<Integer> {
3535
@CommandLine.Option(names = {"-f", "--feature"}, arity = "1..*", description = {"Select one or more feature sets: all, code, code-br, doc-auto or doc-manual"})
3636
private List<String> featureSet = Collections.singletonList("code");
3737

38-
@CommandLine.Option(names = {"-t", "--toolkit"}, description = {"ML toolkit: meka, weka, ml2plan"})
38+
@CommandLine.Option(names = {"-t", "--toolkit"}, description = {"ML toolkit: meka, weka"})
3939
private String toolkit = "meka";
4040

4141
@CommandLine.Option(names = {"-s", "--srm"}, description = {"SRM: all, source, sink, sanitizer, authentication"})

swan-cmd/src/main/java/de/fraunhofer/iem/swan/features/FeatureSetSelector.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public IFeatureSet select(Dataset dataset, SwanOptions options) {
1010

1111
switch (ModelEvaluator.Toolkit.valueOf(options.getToolkit().toUpperCase())) {
1212

13-
case ML2PLAN:
1413
case MEKA:
1514
MekaFeatureSet mekaFeatureSet = new MekaFeatureSet(dataset, options);
1615
mekaFeatureSet.createFeatures();

swan-cmd/src/main/java/de/fraunhofer/iem/swan/model/ModelEvaluator.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import de.fraunhofer.iem.swan.io.dataset.Dataset;
1010
import de.fraunhofer.iem.swan.io.dataset.SrmList;
1111
import de.fraunhofer.iem.swan.io.dataset.SrmListUtils;
12-
import de.fraunhofer.iem.swan.model.toolkit.ML2Plan;
1312
import de.fraunhofer.iem.swan.model.toolkit.Meka;
1413
import de.fraunhofer.iem.swan.model.toolkit.Weka;
1514
import org.slf4j.Logger;
@@ -30,8 +29,7 @@ public class ModelEvaluator {
3029

3130
public enum Toolkit {
3231
WEKA,
33-
MEKA,
34-
ML2PLAN
32+
MEKA
3533
}
3634

3735
public enum Phase {
@@ -70,11 +68,6 @@ public void trainModel() {
7068
Weka weka = new Weka((WekaFeatureSet) features, options, dataset.getTestMethods());
7169
processResults(weka.trainModel());
7270
break;
73-
case ML2PLAN:
74-
logger.info("Evaluating model with ML-PLAN");
75-
ML2Plan mlPlan = new ML2Plan((MekaFeatureSet) features, options);
76-
processResults(mlPlan.trainModel());
77-
break;
7871
}
7972
}
8073

0 commit comments

Comments
 (0)