FeatureDistance
✖
FeatureDistance
gives the distance between example1 and example2 in the feature space defined by extractor.
represents an operator form of FeatureDistance that can be applied to a pair of examples.
Details and Options

- FeatureDistance can be used on many types of data, including numerical, textual, sounds, and images, as well as combinations of these.
- The extractor is typically a FeatureExtractorFunction object as generated by FeatureExtraction.
- FeatureDistance[extractor][ex1,ex2] is equivalent to FeatureDistance[ex1,ex2,extractor].
- The following options can be given:
-
DistanceFunction Automatic the distance to use in the feature space - The option DistanceFunction can be any distance or dissimilarity function or a function f defining a distance between two values.
- For numeric feature vectors, the default setting is DistanceFunctionEuclideanDistance.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Construct a dataset of dog images:

https://wolfram.com/xid/0n4lbm4u8j2-j1wja
Train an extractor function from this dataset:

https://wolfram.com/xid/0n4lbm4u8j2-tgbyra

Compute the distance in the feature space between two images using FeatureDistance:

https://wolfram.com/xid/0n4lbm4u8j2-vorwy8

Generate an operator form of FeatureDistance:

https://wolfram.com/xid/0n4lbm4u8j2-yn5hu5

This operator form can be used to compute distances:

https://wolfram.com/xid/0n4lbm4u8j2-k0bv8h

Compute the distance matrix of the dataset using this feature distance:

https://wolfram.com/xid/0n4lbm4u8j2-mbpe22

https://wolfram.com/xid/0n4lbm4u8j2-g3kjo7

Find the dog that maximizes its distance from the others in the feature space:

https://wolfram.com/xid/0n4lbm4u8j2-s9mh8g

Options (1)Common values & functionality for each option
DistanceFunction (1)
Train a feature extractor to compute term frequency-inverse document frequency vectors from texts:

https://wolfram.com/xid/0n4lbm4u8j2-z78xih

Construct a feature distance for this feature extractor:

https://wolfram.com/xid/0n4lbm4u8j2-0o3p11


https://wolfram.com/xid/0n4lbm4u8j2-ilk6s8

The distance function EuclideanDistance has been chosen. Use the option DistanceFunction to chose CosineDistance instead:

https://wolfram.com/xid/0n4lbm4u8j2-ojw8jn


https://wolfram.com/xid/0n4lbm4u8j2-xztmwj

Wolfram Research (2016), FeatureDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/FeatureDistance.html.
Text
Wolfram Research (2016), FeatureDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/FeatureDistance.html.
Wolfram Research (2016), FeatureDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/FeatureDistance.html.
CMS
Wolfram Language. 2016. "FeatureDistance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FeatureDistance.html.
Wolfram Language. 2016. "FeatureDistance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FeatureDistance.html.
APA
Wolfram Language. (2016). FeatureDistance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FeatureDistance.html
Wolfram Language. (2016). FeatureDistance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FeatureDistance.html
BibTeX
@misc{reference.wolfram_2025_featuredistance, author="Wolfram Research", title="{FeatureDistance}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/FeatureDistance.html}", note=[Accessed: 18-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_featuredistance, organization={Wolfram Research}, title={FeatureDistance}, year={2016}, url={https://reference.wolfram.com/language/ref/FeatureDistance.html}, note=[Accessed: 18-May-2025
]}