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

com.github.TKnudsen.ComplexDataObject.model.distanceMeasure.featureVector.EuclideanDistanceMeasure 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.model.distanceMeasure.featureVector;

import java.util.List;

import com.github.TKnudsen.ComplexDataObject.data.features.numericalData.NumericalFeature;
import com.github.TKnudsen.ComplexDataObject.data.features.numericalData.NumericalFeatureVector;

/**
 * 

* Title: EuclideanDistanceMeasure *

* *

* Description: Euclidean's Distance Measure for NumericalFeatureVectors *

* *

* Copyright: Copyright (c) 2012-2016 *

* * @author Juergen Bernard */ public class EuclideanDistanceMeasure implements INumericalFeatureVectorDistanceMeasure { /** * */ private static final long serialVersionUID = -2728016822703430883L; @Override public double getDistance(NumericalFeatureVector o1, NumericalFeatureVector o2) { List featuresO1 = o1.getVectorRepresentation(); List featuresO2 = o2.getVectorRepresentation(); double d = 0; for (int i = 0; i < Math.min(featuresO1.size(), featuresO2.size()); i++) d += Math.pow(featuresO1.get(i).doubleValue() - featuresO2.get(i).doubleValue(), 2); d = Math.sqrt(d); return d; } @Override public String getName() { return "EuclideanDistanceMeasure"; } @Override public String getDescription() { return "Euclidean's Distance Measure for NumericalFeatureVectors"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy