All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.TKnudsen.ComplexDataObject.data.features.mixedData.MixedDataFeatureTools Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

There is a newer version: 0.2.13
Show newest version
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));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy