Skip to content

Commit 60b2e5b

Browse files
author
JonStargaryen
committed
compatibility for weka 3.8.3
- resolves #5
1 parent dadf14d commit 60b2e5b

File tree

6 files changed

+31
-72
lines changed

6 files changed

+31
-72
lines changed

.idea/libraries/Maven__nz_ac_waikato_cms_weka_weka_stable_3_8_0.xml

-13
This file was deleted.

dist/gmlvq.zip

558 Bytes
Binary file not shown.

gmlvq.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</content>
1313
<orderEntry type="inheritedJdk" />
1414
<orderEntry type="sourceFolder" forTests="false" />
15-
<orderEntry type="library" name="Maven: nz.ac.waikato.cms.weka:weka-stable:3.8.0" level="project" />
15+
<orderEntry type="library" name="Maven: nz.ac.waikato.cms.weka:weka-stable:3.8.3" level="project" />
1616
<orderEntry type="library" name="Maven: nz.ac.waikato.cms.weka.thirdparty:java-cup-11b:2015.03.26" level="project" />
1717
<orderEntry type="library" name="Maven: nz.ac.waikato.cms.weka.thirdparty:java-cup-11b-runtime:2015.03.26" level="project" />
1818
<orderEntry type="library" name="Maven: nz.ac.waikato.cms.weka.thirdparty:bounce:0.18" level="project" />

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>de.bioforscher</groupId>
88
<artifactId>gmlvq</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<version>0.1.1</version>
1010
<name>generalized matrix learning vector quantization</name>
1111
<description>This artifact contains a GMLVQ implementation for WEKA.</description>
1212
<profiles>
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>nz.ac.waikato.cms.weka</groupId>
2424
<artifactId>weka-stable</artifactId>
25-
<version>3.8.0</version>
25+
<version>3.8.3</version>
2626
</dependency>
2727
<dependency>
2828
<groupId>org.jfree</groupId>

src/main/java/weka/classifiers/functions/GMLVQ.java

+23-56
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public interface CostFunctionsSettings {
173173
Option VISUALIZE_CLASSIFICATION_ACCURACY = new Option("visualize the classification accuracy", "VC", 0, "visualize the classification accuracy");
174174
Option VISUALIZE_WEIGHTED_ACCURACY = new Option("visualize the weighted accuracy", "VA", 0, "visualize the weighted accuracy");
175175
Option VISUALIZE_FMEASURE = new Option("visualize the f-measure", "VF", 0, "visualize the f measure");
176-
Option VISUALIZE_PRECISION_RECALL = new Option("visualize precision recall", "VP", 0, "visualize precicion precall ");
176+
Option VISUALIZE_PRECISION_RECALL = new Option("visualize precision recall", "VP", 0, "visualize precision recall");
177177
Option VISUALIZE_DEFAULT_COST = new Option("visualize GMLVQ default cost function", "VD", 0, "visualize the GMLVQ default cost function");
178178
}
179179

@@ -272,10 +272,6 @@ public double get_2_dataPointRatioPerRound() {
272272
return this.builder.getDataPointRatioPerRound();
273273
}
274274

275-
// public double get_2_learnRateChange() {
276-
// return this.builder.getLearnRateChange();
277-
// }
278-
279275
public int getNumberOfClasses() {
280276
return this.builder.getNumberOfClasses();
281277
}
@@ -306,11 +302,9 @@ public String[] getOptions() {
306302
commandLine.add("" + this.builder.getNumberOfEpochs());
307303
commandLine.add("-" + AlgorithmSettings.NUMBER_OF_PROTOTYPES_OPTION.name());
308304
commandLine.add("" + this.builder.getNumberOfPrototypesPerClass());
309-
// commandLine.add("-" + AlgorithmSettings.STOP_CRITERION_OPTION.name());
310-
// commandLine.add("" + this.builder.getStopCriterion());
311-
// if (this.builder.isVisualization()) {
312-
// commandLine.add("-" + AlgorithmSettings.VISUALIZATION_OPTION.name());
313-
// }
305+
if (this.builder.isVisualization()) {
306+
commandLine.add("-" + AlgorithmSettings.VISUALIZATION_OPTION.name());
307+
}
314308
commandLine.add("-" + AlgorithmSettings.DATA_POINTS_PER_ROUND_OPTION.name());
315309
commandLine.add("" + this.builder.getDataPointRatioPerRound());
316310
commandLine.add("-" + AlgorithmSettings.SIGMOID_SIGMA_INTERVAL_OPTION.name());
@@ -326,11 +320,6 @@ public String[] getOptions() {
326320
if (this.builder.isMatrixLearning()) {
327321
commandLine.add("-" + MethodSettings.MATRIX_LEARNING_OPTION.name());
328322
}
329-
// commandLine.add("-" + MethodSettings.LEARN_RATE_CHANGE_OPTION.name());
330-
// commandLine.add("" + this.builder.getLearnRateChange());
331-
// if (this.builder.isParallelExecution()) {
332-
// commandLine.add("-" + MethodSettings.PARALLEL_EXECUTION_OPTION.name());
333-
// }
334323

335324
// cost function settings
336325
commandLine.add("-" + CostFunctionsSettings.COST_FUNCTION_TO_OPTIMIZE_OPTION.name());
@@ -377,10 +366,6 @@ public String get_2_costFunctionWeights() {
377366
return this.builder.getCostFunctionWeights();
378367
}
379368

380-
// public double get_2_stopCriterion() {
381-
// return this.builder.getStopCriterion();
382-
// }
383-
384369
@Override
385370
public TechnicalInformation getTechnicalInformation() {
386371
// TODO add publication and stuff
@@ -433,10 +418,6 @@ public static boolean isRelevanceLearning(Matrix omegaMatrix) {
433418
return omegaMatrix.getColumnDimension() != 1 && omegaMatrix.getRowDimension() != 1;
434419
}
435420

436-
// public String _2_learnRateChangeTipText() {
437-
// return "the change of the learning rate";
438-
// }
439-
440421
@Override
441422
public Enumeration<Option> listOptions() {
442423

@@ -445,7 +426,6 @@ public Enumeration<Option> listOptions() {
445426
// algorithm settings
446427
options.addElement(AlgorithmSettings.NUMBER_OF_EPOCHS_OPTION);
447428
options.addElement(AlgorithmSettings.NUMBER_OF_PROTOTYPES_OPTION);
448-
// options.addElement(AlgorithmSettings.STOP_CRITERION_OPTION);
449429
options.addElement(AlgorithmSettings.VISUALIZATION_OPTION);
450430
options.addElement(AlgorithmSettings.DATA_POINTS_PER_ROUND_OPTION);
451431
options.addElement(AlgorithmSettings.SIGMOID_SIGMA_INTERVAL_OPTION);
@@ -523,10 +503,6 @@ public String _2_sigmoidSigmaIntervalTipText() {
523503
return "interval of the parameter of the sigmoid/Fermit function which is part of the cost function";
524504
}
525505

526-
// public String _2_stopCriterionTipText() {
527-
// return "stop criterion: if learning ratio is smaller than this value, the learning is stopped";
528-
// }
529-
530506
public String _1_visualizationTipText() {
531507
return "determines if the progress should be visualized";
532508
}
@@ -559,10 +535,6 @@ public void set_2_dataPointRatioPerRound(double dataPointRatioPerRound) {
559535
this.builder.dataPointRatioPerRound(dataPointRatioPerRound);
560536
}
561537

562-
// public void set_2_learnRateChange(double learnRateChange) {
563-
// this.builder.learnRateChange(learnRateChange);
564-
// }
565-
566538
public void set_2_matrixLearning(boolean matrixLearning) {
567539
this.builder.matrixLearning(matrixLearning);
568540

@@ -649,13 +621,6 @@ public void setOptions(String[] options) throws Exception {
649621
this.builder.numberOfPrototypesPerClass(AlgorithmSettings.DEFAULT_NUMBER_OF_PROTOTYPES_PER_CLASS);
650622
}
651623

652-
// String stopCriterionString = Utils.getOption(AlgorithmSettings.STOP_CRITERION_OPTION.name().charAt(0), options);
653-
// if (stopCriterionString.length() != 0) {
654-
// this.builder.stopCriterion(Double.parseDouble(stopCriterionString));
655-
// } else {
656-
// this.builder.stopCriterion(AlgorithmSettings.DEFAULT_STOP_CRITERION);
657-
// }
658-
659624
this.builder.visualization(Utils.getFlag(AlgorithmSettings.VISUALIZATION_OPTION.name().charAt(0), options));
660625

661626
String dataPointsPerRoundString = Utils
@@ -672,10 +637,6 @@ public void setOptions(String[] options) throws Exception {
672637
this.builder.sigmoidSigmaInterval(sigmoidSigmaIntervalString);
673638
} else {
674639
this.builder.sigmoidSigmaInterval(AlgorithmSettings.DEFAULT_SIGMOID_SIGMA_INTERVAL);
675-
// initialize with sigmoid sigma default values - not needed anymore
676-
// - probably
677-
// this.embeddedSpaceCalculator.setSigmoidSigmaInterval(AlgorithmSettings.DEFAULT_SIGMOID_SIGMA_INTERVAL_START,
678-
// AlgorithmSettings.DEFAULT_SIGMOID_SIGMA_INTERVAL_END);
679640
}
680641

681642
// method settings
@@ -704,14 +665,6 @@ public void setOptions(String[] options) throws Exception {
704665
this.builder.omegaDimension(MethodSettings.DEFAULT_OMEGA_DIMENSION);
705666
}
706667

707-
// String learnRateChangeString = Utils.getOption(MethodSettings.LEARN_RATE_CHANGE_OPTION.name().charAt(0),
708-
// options);
709-
// if (omegaDimensionString.length() != 0) {
710-
// this.builder.learnRateChange(Double.parseDouble(learnRateChangeString));
711-
// } else {
712-
// this.builder.learnRateChange(MethodSettings.DEFAULT_OMEGA_DIMENSION);
713-
// }
714-
715668
this.builder
716669
.parallelExecution(Utils.getFlag(MethodSettings.PARALLEL_EXECUTION_OPTION.name().charAt(0), options));
717670

@@ -734,6 +687,25 @@ public void setOptions(String[] options) throws Exception {
734687
this.builder.costFunctionBeta(CostFunctionCalculator.DEFAULT_BETA);
735688
}
736689

690+
String costFunctionWeightString = Utils
691+
.getOption(CostFunctionsSettings.COST_FUNCTION_WEIGHTS_OPTION.name().charAt(0), options);
692+
if(costFunctionWeightString.length() != 0) {
693+
this.builder.costFunctionWeights(costFunctionWeightString);
694+
} else {
695+
this.builder.costFunctionWeights(CostFunctionCalculator.DEFAULT_WEIGHTS);
696+
}
697+
698+
this.builder
699+
.visualizeDefaultCost(Utils.getFlag(CostFunctionsSettings.VISUALIZE_DEFAULT_COST.name(), options));
700+
this.builder
701+
.visualizeFMeasure(Utils.getFlag(CostFunctionsSettings.VISUALIZE_FMEASURE.name(), options));
702+
this.builder
703+
.visualizePrecisionRecall(Utils.getFlag(CostFunctionsSettings.VISUALIZE_PRECISION_RECALL.name(), options));
704+
this.builder
705+
.visualizeWeightedAccuracy(Utils.getFlag(CostFunctionsSettings.VISUALIZE_WEIGHTED_ACCURACY.name(), options));
706+
this.builder
707+
.visualizeClassificationAccuracy(Utils.getFlag(CostFunctionsSettings.VISUALIZE_CLASSIFICATION_ACCURACY.name(), options));
708+
737709
super.setOptions(options);
738710
}
739711

@@ -756,11 +728,6 @@ public void set_2_costFunctionWeights(String costFunctionWeightsString) {
756728
this.builder.costFunctionWeights(costFunctionWeightsString);
757729
}
758730

759-
// public void set_2_stopCriterion(double stopCriterion) {
760-
// this.builder.stopCriterion(stopCriterion);
761-
//
762-
// }
763-
764731
public void set_1_visualization(boolean visualization) {
765732
this.builder.visualization(visualization);
766733

src/main/java/weka/classifiers/functions/gmlvq/core/GMLVQCore.java

+5
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,11 @@ public Builder costFunctionBeta(double costFunctionBeta) {
891891
return this;
892892
}
893893

894+
public Builder costFunctionWeights(double[] costFunctionWeights) {
895+
this.costFunctionWeights = costFunctionWeights;
896+
return this;
897+
}
898+
894899
public Builder costFunctionWeights(String costFunctionWeightsString) {
895900
String[] split = costFunctionWeightsString.split(",");
896901
this.costFunctionWeights[0] = Double.parseDouble(split[0]);

0 commit comments

Comments
 (0)