Aggregation

Index

API

Mill.AggregationStackType
AggregationStack{T <: Tuple{Vararg{AbstractAggregation}}} <: AbstractAggregation

A container that implements a concatenation of one or more AbstractAggregations.

Construct with e.g. AggregationStack(SegmentedMean([t::Type, ]d)) for single operators and with e.g. SegmentedPNormLSE([t::Type, ]d) for concatenations. With these calls all parameters inside operators are initialized randomly as Float32 arrays, unless type t is further specified. Another option is to vcat two operators together.

Nested stacks are flattened into a single-level structure upon construction, see examples.

Intended to be used as a functor:

(a::AggregationStack)(x, bags[, w])

where x is either AbstractMatrix or missing, bags is AbstractBags structure and optionally w is an AbstractVector of weights.

Examples

julia> a = AggregationStack(SegmentedMean(2), SegmentedMax(2))
AggregationStack:
 SegmentedMean(ψ = Float32[0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0])

julia> a(Float32[0 1 2; 3 4 5], bags([1:1, 2:3]))
4×2 Matrix{Float32}:
 0.0  1.5
 3.0  4.5
 0.0  2.0
 3.0  5.0

julia> a = AggregationStack(SegmentedMean(2), AggregationStack(SegmentedMax(2)))
AggregationStack:
 SegmentedMean(ψ = Float32[0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0])

julia> a = SegmentedMeanMax(Float32, 2)
AggregationStack:
 SegmentedMean(ψ = Float32[0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0])

julia> vcat(SegmentedMean(2), SegmentedMax(2))
AggregationStack:
 SegmentedMean(ψ = Float32[0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0])

See also: AbstractAggregation, SegmentedSum, SegmentedMax, SegmentedMean, SegmentedPNorm, SegmentedLSE.

source
Mill.SegmentedPNormType
SegmentedPNorm{V <: AbstractVector{<:AbstractFloat}} <: AbstractAggregation

AbstractAggregation implementing segmented p-norm aggregation:

$f(\{x_1, \ldots, x_k\}; p, c) = \left(\frac{1}{k} \sum_{i = 1}^{k} \vert x_i - c \vert ^ {p} \right)^{\frac{1}{p}}$

Stores a vector of parameters ψ that are filled into the resulting matrix in case an empty bag is encountered, and vectors of parameters p and c used during computation.

See also: AbstractAggregation, AggregationStack, SegmentedMax, SegmentedMean, SegmentedSum, SegmentedLSE.

source
Mill.SegmentedLSEType
SegmentedLSE{V <: AbstractVector{<:AbstractFloat}} <: AbstractAggregation

AbstractAggregation implementing segmented log-sum-exp (LSE) aggregation:

$f(\{x_1, \ldots, x_k\}; r) = \frac{1}{r}\log \left(\frac{1}{k} \sum_{i = 1}^{k} \exp({r\cdot x_i})\right)$

Stores a vector of parameters ψ that are filled into the resulting matrix in case an empty bag is encountered, and a vector of parameters r used during computation.

See also: AbstractAggregation, AggregationStack, SegmentedMax, SegmentedMean, SegmentedSum, SegmentedPNorm.

source
Mill.SegmentedMeanMaxFunction
SegmentedMeanMax([t::Type, ]d::Integer)

Construct AggregationStack consisting of SegmentedMean and SegmentedMax operators.

Examples

julia> SegmentedMeanMax(4)
AggregationStack:
 SegmentedMean(ψ = Float32[0.0, 0.0, 0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0, 0.0, 0.0])

julia> SegmentedMeanMax(Float64, 2)
AggregationStack:
 SegmentedMean(ψ = [0.0, 0.0])
 SegmentedMax(ψ = [0.0, 0.0])

See also: AbstractAggregation, AggregationStack, SegmentedSum, SegmentedMax, SegmentedMean, SegmentedPNorm, SegmentedLSE.

source
Mill.BagCountType
BagCount{T <: AbstractAggregation}

A wrapper type that when called applies the AbstractAggregation stored in it, and appends one more element containing bag size after $x ↦ \log(x + 1)$ transformation to the result.

Used as a functor:

(bc::BagCount)(x, bags[, w])

where x is either AbstractMatrix or missing, bags is AbstractBags structure and optionally w is an AbstractVector of weights.

Examples

julia> x = Float32[0 1 2; 3 4 5]
2×3 Matrix{Float32}:
 0.0  1.0  2.0
 3.0  4.0  5.0

julia> b = bags([1:1, 2:3])
AlignedBags{Int64}(UnitRange{Int64}[1:1, 2:3])

julia> a = vcat(SegmentedMean(2), SegmentedMax(2))
AggregationStack:
 SegmentedMean(ψ = Float32[0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0])

julia> a(x, b)
4×2 Matrix{Float32}:
 0.0  1.5
 3.0  4.5
 0.0  2.0
 3.0  5.0

julia> BagCount(a)(x, b)
5×2 Matrix{Float32}:
 0.0       1.5
 3.0       4.5
 0.0       2.0
 3.0       5.0
 0.693147  1.09861

See also: AbstractAggregation, AggregationStack, SegmentedSum, SegmentedMax, SegmentedMean, SegmentedPNorm, SegmentedLSE.

source