Aggregation
Index
Mill.AbstractAggregation
Mill.AggregationStack
Mill.BagCount
Mill.SegmentedLSE
Mill.SegmentedMax
Mill.SegmentedMean
Mill.SegmentedPNorm
Mill.SegmentedSum
Mill.SegmentedMeanMax
Mill.SegmentedPNormLSE
API
Mill.AbstractAggregation
— TypeAbstractAggregation
Supertype for any aggregation operator.
See also: AggregationStack
, SegmentedSum
, SegmentedMax
, SegmentedMean
, SegmentedPNorm
, SegmentedLSE
.
Mill.AggregationStack
— TypeAggregationStack{T <: Tuple{Vararg{AbstractAggregation}}} <: AbstractAggregation
A container that implements a concatenation of one or more AbstractAggregation
s.
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
.
Mill.SegmentedSum
— TypeSegmentedSum{V <: AbstractVector{<:Number}} <: AbstractAggregation
AbstractAggregation
implementing segmented sum aggregation:
$f(\{x_1, \ldots, x_k\}) = \sum_{i = 1}^{k} x_i$
Stores a vector of parameters ψ
that are filled into the resulting matrix in case an empty bag is encountered.
See also: AbstractAggregation
, AggregationStack
, SegmentedMax
, SegmentedMean
, SegmentedPNorm
, SegmentedLSE
.
Mill.SegmentedMax
— TypeSegmentedMax{V <: AbstractVector{<:Number}} <: AbstractAggregation
AbstractAggregation
implementing segmented max aggregation:
$f(\{x_1, \ldots, x_k\}) = \max_{i = 1, \ldots, k} x_i$
Stores a vector of parameters ψ
that are filled into the resulting matrix in case an empty bag is encountered.
See also: AbstractAggregation
, AggregationStack
, SegmentedMean
, SegmentedSum
, SegmentedPNorm
, SegmentedLSE
.
Mill.SegmentedMean
— TypeSegmentedMean{V <: AbstractVector{<:Number}}} <: AbstractAggregation
AbstractAggregation
implementing segmented mean aggregation:
$f(\{x_1, \ldots, x_k\}) = \frac{1}{k} \sum_{i = 1}^{k} x_i$
Stores a vector of parameters ψ
that are filled into the resulting matrix in case an empty bag is encountered.
See also: AbstractAggregation
, AggregationStack
, SegmentedMax
, SegmentedSum
, SegmentedPNorm
, SegmentedLSE
.
Mill.SegmentedPNorm
— TypeSegmentedPNorm{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
.
Mill.SegmentedLSE
— TypeSegmentedLSE{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
.
Mill.SegmentedMeanMax
— FunctionSegmentedMeanMax([t::Type, ]d::Int)
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
.
Mill.SegmentedPNormLSE
— FunctionSegmentedPNormLSE([t::Type, ]d::Int)
Construct AggregationStack
consisting of SegmentedPNorm
and SegmentedLSE
operators.
See also: AbstractAggregation
, AggregationStack
, SegmentedSum
, SegmentedMax
, SegmentedMean
, SegmentedPNorm
, SegmentedLSE
.
Mill.BagCount
— TypeBagCount{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
.