Copyright | (c) Amy de Buitléir 2012-2018 |
---|---|
License | BSD-style |
Maintainer | amy@nualeargais.ie |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Tools for identifying patterns in data.
Synopsis
- adjustNum :: (Num a, Ord a, Eq a) => a -> a -> a -> a
- absDifference :: Num a => a -> a -> a
- adjustVector :: (Num a, Ord a, Eq a) => [a] -> a -> [a] -> [a]
- adjustVectorPreserveLength :: (Num a, Ord a, Eq a) => [a] -> a -> [a] -> [a]
- euclideanDistanceSquared :: Num a => [a] -> [a] -> a
- magnitudeSquared :: Num a => [a] -> a
- 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]
Numbers as patterns
adjustNum :: (Num a, Ord a, Eq a) => a -> a -> a -> a Source #
Adjusts a number to make it more similar to the target.
absDifference :: Num a => a -> a -> a Source #
Returns the absolute difference between two numbers.
Numeric vectors as patterns
Raw vectors
adjustVector :: (Num a, Ord a, Eq a) => [a] -> a -> [a] -> [a] Source #
adjusts each element of
adjustVector
target amount vectorvector
to move it closer to the corresponding element of
target
.
The amount of adjustment is controlled by the learning rate
amount
, which is a number between 0 and 1.
Larger values of amount
permit more adjustment.
If amount
=1, the result will be identical to the target
.
If amount
=0, the result will be the unmodified pattern
.
If target
is shorter than vector
, the result will be the same
length as target
.
If target
is longer than vector
, the result will be the same
length as vector
.
adjustVectorPreserveLength :: (Num a, Ord a, Eq a) => [a] -> a -> [a] -> [a] Source #
Same as
, except that the result will always be
the same length as adjustVector
vector
.
This means that if target
is shorter than vector
, the
"leftover" elements of vector
will be copied the result,
unmodified.
euclideanDistanceSquared :: Num a => [a] -> [a] -> a Source #
Calculates the square of the Euclidean distance between two vectors.
magnitudeSquared :: Num a => [a] -> a Source #
Returns the sum of the squares of the elements of a vector.
Normalised vectors
data NormalisedVector a Source #
A vector that has been normalised, i.e., the magnitude of the vector = 1.
Instances
Show a => Show (NormalisedVector a) Source # | |
Defined in Data.Datamining.Pattern showsPrec :: Int -> NormalisedVector a -> ShowS # show :: NormalisedVector a -> String # showList :: [NormalisedVector a] -> ShowS # |
normalise :: Floating a => [a] -> NormalisedVector a Source #
Normalises a vector
Scaled vectors
data ScaledVector a Source #
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 scaleAll
.scale
Instances
Show a => Show (ScaledVector a) Source # | |
Defined in Data.Datamining.Pattern showsPrec :: Int -> ScaledVector a -> ShowS # show :: ScaledVector a -> String # showList :: [ScaledVector a] -> ShowS # |
scale :: Fractional a => [(a, a)] -> [a] -> ScaledVector a Source #
Given a vector qs
of pairs of numbers, where each pair represents
the maximum and minimum value to be expected at each index in
xs
,
scales the vector scale
qs xsxs
element by element,
mapping the maximum value expected at that index to one, and the
minimum value to zero.
scaleAll :: (Fractional a, Ord a) => [[a]] -> [ScaledVector a] Source #
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.