mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
Removed internal maneuver type "other" + bugfixes
This commit is contained in:
1 parent
0fb43b1c11
commit
ea367dd2f4
6 files changed
+18
-46
No files matched your search
+2
-4
@@ -3,10 +3,8 @@ package com.sap.sailing.windestimation.model.classifier.maneuver;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.windestimation.data.LabelledManeuverForEstimation;
|
||||
import com.sap.sailing.windestimation.data.ManeuverForEstimation;
|
||||
import com.sap.sailing.windestimation.data.ManeuverTypeForClassification;
|
||||
import com.sap.sailing.windestimation.model.classifier.LabelExtraction;
|
||||
import com.sap.sailing.windestimation.model.classifier.maneuver.ManeuverClassifierModelMetadata;
|
||||
import com.sap.sailing.windestimation.model.classifier.maneuver.ManeuverFeatures;
|
||||
import com.sap.sailing.windestimation.model.classifier.maneuver.ManeuverTypeForInternalClassification;
|
||||
|
||||
public class LabelledManeuverModelMetadata extends ManeuverClassifierModelMetadata
|
||||
implements LabelExtraction<ManeuverForEstimation> {
|
||||
@@ -14,7 +12,7 @@ public class LabelledManeuverModelMetadata extends ManeuverClassifierModelMetada
|
||||
private static final long serialVersionUID = -7074647974723150632L;
|
||||
|
||||
public LabelledManeuverModelMetadata(ManeuverFeatures maneuverFeatures, BoatClass boatClass,
|
||||
ManeuverTypeForInternalClassification... orderedSupportedTargetValues) {
|
||||
ManeuverTypeForClassification... orderedSupportedTargetValues) {
|
||||
super(maneuverFeatures, boatClass, orderedSupportedTargetValues);
|
||||
}
|
||||
|
||||
|
||||
-25
@@ -1,40 +1,15 @@
|
||||
package com.sap.sailing.windestimation.model.classifier.maneuver;
|
||||
|
||||
import com.sap.sailing.windestimation.data.ManeuverCategory;
|
||||
import com.sap.sailing.windestimation.data.ManeuverForEstimation;
|
||||
import com.sap.sailing.windestimation.data.ManeuverTypeForClassification;
|
||||
import com.sap.sailing.windestimation.model.classifier.ClassificationResultMapper;
|
||||
|
||||
public class ManeuverClassificationResultMapper implements
|
||||
ClassificationResultMapper<ManeuverForEstimation, ManeuverClassifierModelMetadata, ManeuverWithProbabilisticTypeClassification> {
|
||||
|
||||
private double[] mapManeuverTypesForInternalClassificationToManeuverTypesForClassification(
|
||||
double[] likelihoodPerManeuverType, ManeuverCategory maneuverCategory) {
|
||||
double[] newLikelihoods = new double[ManeuverTypeForClassification.values().length];
|
||||
switch (maneuverCategory) {
|
||||
case MARK_PASSING:
|
||||
case REGULAR:
|
||||
newLikelihoods[ManeuverTypeForClassification.TACK
|
||||
.ordinal()] = likelihoodPerManeuverType[ManeuverTypeForInternalClassification.TACK.ordinal()];
|
||||
newLikelihoods[ManeuverTypeForClassification.JIBE
|
||||
.ordinal()] = likelihoodPerManeuverType[ManeuverTypeForInternalClassification.JIBE.ordinal()];
|
||||
newLikelihoods[ManeuverTypeForClassification.BEAR_AWAY
|
||||
.ordinal()] = likelihoodPerManeuverType[ManeuverTypeForInternalClassification.OTHER.ordinal()];
|
||||
newLikelihoods[ManeuverTypeForClassification.HEAD_UP
|
||||
.ordinal()] = likelihoodPerManeuverType[ManeuverTypeForInternalClassification.OTHER.ordinal()];
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported maneuver category");
|
||||
}
|
||||
return newLikelihoods;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManeuverWithProbabilisticTypeClassification mapToClassificationResult(double[] likelihoods,
|
||||
ManeuverForEstimation maneuver, ManeuverClassifierModelMetadata modelMetadata) {
|
||||
likelihoods = modelMetadata.getLikelihoodsPerManeuverTypeOrdinal(likelihoods);
|
||||
likelihoods = mapManeuverTypesForInternalClassificationToManeuverTypesForClassification(likelihoods,
|
||||
maneuver.getManeuverCategory());
|
||||
ManeuverWithProbabilisticTypeClassification maneuverClassificationResult = new ManeuverWithProbabilisticTypeClassification(
|
||||
maneuver, likelihoods);
|
||||
return maneuverClassificationResult;
|
||||
|
||||
+8
-5
@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.windestimation.data.ManeuverForEstimation;
|
||||
import com.sap.sailing.windestimation.data.ManeuverTypeForClassification;
|
||||
import com.sap.sailing.windestimation.model.classifier.ClassifierModelFactory;
|
||||
import com.sap.sailing.windestimation.model.classifier.TrainableClassificationModel;
|
||||
import com.sap.sailing.windestimation.model.classifier.smile.NeuralNetworkClassifier;
|
||||
@@ -13,9 +14,9 @@ import com.sap.sailing.windestimation.model.classifier.smile.NeuralNetworkClassi
|
||||
public class ManeuverClassifierModelFactory
|
||||
implements ClassifierModelFactory<ManeuverForEstimation, ManeuverClassifierModelMetadata> {
|
||||
|
||||
public static final ManeuverTypeForInternalClassification[] orderedSupportedTargetValues = {
|
||||
ManeuverTypeForInternalClassification.TACK, ManeuverTypeForInternalClassification.JIBE,
|
||||
ManeuverTypeForInternalClassification.OTHER };
|
||||
public static final ManeuverTypeForClassification[] orderedSupportedTargetValues = {
|
||||
ManeuverTypeForClassification.TACK, ManeuverTypeForClassification.JIBE,
|
||||
ManeuverTypeForClassification.HEAD_UP, ManeuverTypeForClassification.BEAR_AWAY };
|
||||
|
||||
@Override
|
||||
public TrainableClassificationModel<ManeuverForEstimation, ManeuverClassifierModelMetadata> getNewModel(
|
||||
@@ -43,7 +44,8 @@ public class ManeuverClassifierModelFactory
|
||||
return suitableClassifiers;
|
||||
}
|
||||
|
||||
private static ManeuverClassifierModelMetadata createModelMetadata(ManeuverFeatures maneuverFeatures, BoatClass boatClass) {
|
||||
private static ManeuverClassifierModelMetadata createModelMetadata(ManeuverFeatures maneuverFeatures,
|
||||
BoatClass boatClass) {
|
||||
ManeuverClassifierModelMetadata modelMetadata = new ManeuverClassifierModelMetadata(maneuverFeatures, boatClass,
|
||||
orderedSupportedTargetValues);
|
||||
return modelMetadata;
|
||||
@@ -60,7 +62,8 @@ public class ManeuverClassifierModelFactory
|
||||
ManeuverClassifierModelMetadata modelMetadata = createModelMetadata(possibleFeatures, null);
|
||||
modelMetadataCandidates.add(modelMetadata);
|
||||
if (boatClass != null) {
|
||||
ManeuverClassifierModelMetadata modelMetadataWithBoatClass = createModelMetadata(possibleFeatures, boatClass);
|
||||
ManeuverClassifierModelMetadata modelMetadataWithBoatClass = createModelMetadata(possibleFeatures,
|
||||
boatClass);
|
||||
modelMetadataCandidates.add(modelMetadataWithBoatClass);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -4,6 +4,7 @@ import java.util.Arrays;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.windestimation.data.ManeuverForEstimation;
|
||||
import com.sap.sailing.windestimation.data.ManeuverTypeForClassification;
|
||||
import com.sap.sailing.windestimation.model.ContextSpecificModelMetadata;
|
||||
import com.sap.sailing.windestimation.model.store.ContextType;
|
||||
|
||||
@@ -16,16 +17,16 @@ public class ManeuverClassifierModelMetadata extends ContextSpecificModelMetadat
|
||||
private final int numberOfSupportedManeuverTypes;
|
||||
|
||||
public ManeuverClassifierModelMetadata(ManeuverFeatures maneuverFeatures, BoatClass boatClass,
|
||||
ManeuverTypeForInternalClassification... orderedSupportedTargetValues) {
|
||||
ManeuverTypeForClassification... orderedSupportedTargetValues) {
|
||||
super(ContextType.MANEUVER);
|
||||
this.maneuverFeatures = maneuverFeatures;
|
||||
this.boatClass = boatClass;
|
||||
this.indexToManeuverTypeOrdinalMapping = new int[ManeuverTypeForInternalClassification.values().length];
|
||||
this.indexToManeuverTypeOrdinalMapping = new int[ManeuverTypeForClassification.values().length];
|
||||
for (int i = 0; i < indexToManeuverTypeOrdinalMapping.length; i++) {
|
||||
indexToManeuverTypeOrdinalMapping[i] = -1;
|
||||
}
|
||||
int i = 0;
|
||||
for (ManeuverTypeForInternalClassification supportedManeuverType : orderedSupportedTargetValues) {
|
||||
for (ManeuverTypeForClassification supportedManeuverType : orderedSupportedTargetValues) {
|
||||
indexToManeuverTypeOrdinalMapping[supportedManeuverType.ordinal()] = i++;
|
||||
}
|
||||
numberOfSupportedManeuverTypes = i;
|
||||
@@ -45,7 +46,7 @@ public class ManeuverClassifierModelMetadata extends ContextSpecificModelMetadat
|
||||
}
|
||||
|
||||
public double[] getLikelihoodsPerManeuverTypeOrdinal(double[] likelihoodsFromModel) {
|
||||
double[] likelihoodsPerManeuverTypes = new double[ManeuverTypeForInternalClassification.values().length];
|
||||
double[] likelihoodsPerManeuverTypes = new double[ManeuverTypeForClassification.values().length];
|
||||
int mappedI = 0;
|
||||
for (int i = 0; i < likelihoodsPerManeuverTypes.length; i++) {
|
||||
int maneuverTypeMapping = indexToManeuverTypeOrdinalMapping[i];
|
||||
@@ -100,8 +101,8 @@ public class ManeuverClassifierModelMetadata extends ContextSpecificModelMetadat
|
||||
+ ", numberOfSupportedManeuverTypes=" + numberOfSupportedManeuverTypes + "]";
|
||||
}
|
||||
|
||||
public ManeuverTypeForInternalClassification getManeuverTypeByMappingIndex(int likelihoodIndex) {
|
||||
for (ManeuverTypeForInternalClassification maneuverType : ManeuverTypeForInternalClassification.values()) {
|
||||
public ManeuverTypeForClassification getManeuverTypeByMappingIndex(int likelihoodIndex) {
|
||||
for (ManeuverTypeForClassification maneuverType : ManeuverTypeForClassification.values()) {
|
||||
if (indexToManeuverTypeOrdinalMapping[maneuverType.ordinal()] == likelihoodIndex) {
|
||||
return maneuverType;
|
||||
}
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package com.sap.sailing.windestimation.model.classifier.maneuver;
|
||||
|
||||
public enum ManeuverTypeForInternalClassification {
|
||||
TACK, JIBE, OTHER
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.sap.sailing.windestimation.model.store;
|
||||
|
||||
public enum ContextType {
|
||||
MANEUVER("maneuver"), TWD_TRANSITION("twdTransition");
|
||||
MANEUVER("Maneuver"), TWD_TRANSITION("TwdTransition");
|
||||
|
||||
private final String contextName;
|
||||
|
||||
|
||||
Reference in new issue
Block a user