Tools for identifying patterns in data.
- class Pattern p where
- data NormalisedVector a
- normalise :: Floating a => [a] -> NormalisedVector a
- data ScaledVector a
- scale :: Fractional a => [(a, a)] -> [a] -> ScaledVector a
- scaleAll :: (Fractional a, Ord a) => [[a]] -> [ScaledVector a]
- adjustVector :: (Num a, Ord a, Eq a) => [a] -> a -> [a] -> [a]
- euclideanDistanceSquared :: Num a => [a] -> [a] -> a
- magnitudeSquared :: Num a => [a] -> a
A pattern to be learned or classified.
Compares two patterns and returns a non-negative number
representing how different the patterns are. A result of
indicates that the patterns are identical.
returns a modified copy of
makeSimilar target amount pattern
pattern that is more similar to
pattern is. The
magnitude of the adjustment is controlled by the
parameter, which should be a number between 0 and 1. Larger
amount permit greater adjustments. If
the result should be identical to the
the result should be the unmodified
Numeric vectors as patterns
A vector that has been normalised, i.e., the magnitude of the vector = 1.
A vector that has been scaled so that all elements in the vector
are between zero and one. To scale a set of vectors, use
. Alternatively, if you can identify a maximum and
minimum value for each element in a vector, you can scale
individual vectors using
Given a vector
qs of pairs of numbers, where each pair represents
the maximum and minimum value to be expected at each index in
scales the vector
scale qs xs
xs element by element,
mapping the maximum value expected at that index to one, and the
minimum value to zero.
Scales a set of vectors by determining the maximum and minimum values at each index in the vector, and mapping the maximum value to one, and the minimum value to zero.
If you wish to use raw numeric vectors as a pattern, use
no-warn-orphans and add the following to your code:
instance (Floating a, Fractional a, Ord a, Eq a) ⇒ Pattern [a] a where difference = euclideanDistanceSquared makeSimilar = adjustVector
adjustVector target amount vector
vector to move it
target. The amount of adjustment is controlled by the
r, which is a number between 0 and 1. Larger values
r permit more adjustment. If
r=1, the result will be
identical to the
amount=0, the result will be the
Calculates the square of the Euclidean distance between two vectors.