com.github.TKnudsen.ComplexDataObject.data.features.mixedData.MixedDataFeatureTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
package com.github.TKnudsen.ComplexDataObject.data.features.mixedData;
import java.util.List;
import com.github.TKnudsen.ComplexDataObject.data.features.FeatureType;
public class MixedDataFeatureTools {
public static FeatureType guessFeatureType(Object feature) throws IllegalArgumentException {
if (feature == null)
throw new IllegalArgumentException("MixedDataFeatureTools.guessFeatureType: object was null - unable to guess");
if (feature instanceof Number)
return FeatureType.DOUBLE;
else if (feature instanceof Boolean)
return FeatureType.BOOLEAN;
else if (feature instanceof String)
return FeatureType.STRING;
else if (feature instanceof Character)
return FeatureType.STRING;
throw new IllegalArgumentException("MixedDataFeatureTools.guessFeatureType: undefined object type");
}
public static void addClassAttribute(List featureVectors, List labels, String classAttribute) {
for (int i = 0; i < featureVectors.size(); i++)
featureVectors.get(i).add(classAttribute, labels.get(i));
}
public static void addNumericAttribute(List features, List labels, String attributeName) {
for (int i = 0; i < features.size(); i++)
features.get(i).add(attributeName, labels.get(i));
}
}