Aggregation

Index

API

Mill.AggregationType
Aggregation{T, U <: Tuple{Vararg{AggregationOperator{T}}}}

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

Construct with e.g. mean_aggregation([t::Type, ]d), max_aggregation([t::Type, ]d) for single operators and with e.g. pnormlse_aggregation([t::Type, ]d) for concatenations. With these calls all parameters inside operators are initialized randomly as Float32 arrays, unless type t is further specified. It is also possible to call the constructor directly, see Examples.

Intended to be used as a functor:

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

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

If Mill.bagcount is on, one more row is added to the result containing bag size after $x ↦ \log(x + 1)$ transformation.

Examples

julia> a = mean_aggregation(5)
Aggregation{Float32}:
 SegmentedMean(ψ = Float32[0.0, 0.0, 0.0, 0.0, 0.0])

julia> a = meanmax_aggregation(Int64, 4)
Aggregation{Int64}:
 SegmentedMean(ψ = [0, 0, 0, 0])
 SegmentedMax(ψ = [0, 0, 0, 0])

julia> Aggregation(SegmentedMean(4), SegmentedMax(4))
Aggregation{Float32}:
 SegmentedMean(ψ = Float32[0.0, 0.0, 0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0, 0.0, 0.0])

julia> mean_aggregation(5)(Float32[0 1 2; 3 4 5], bags([1:1, 2:3]))
3×2 Array{Float32,2}:
 0.0       1.5
 3.0       4.5
 0.693147  1.09861

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

Mill.SegmentedSumType
SegmentedSum{T, V <: AbstractVector{T}} <: AggregationOperator{T}

AggregationOperator 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.

Construction

The direct use of the operator is discouraged, use Aggregation wrapper instead. In other words, get this operator with sum_aggregation instead of calling the SegmentedSum constructor directly.

See also: AggregationOperator, Aggregation, sum_aggregation, SegmentedMax, SegmentedMean, SegmentedPNorm, SegmentedLSE.

Mill.SegmentedMaxType
SegmentedMax{T, V <: AbstractVector{T}} <: AggregationOperator{T}

AggregationOperator 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.

Construction

The direct use of the operator is discouraged, use Aggregation wrapper instead. In other words, get this operator with max_aggregation instead of calling the SegmentedMax constructor directly.

See also: AggregationOperator, Aggregation, max_aggregation, SegmentedMean, SegmentedSum, SegmentedPNorm, SegmentedLSE.

Mill.SegmentedMeanType
SegmentedMean{T, V <: AbstractVector{T}} <: AggregationOperator{T}

AggregationOperator 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.

Construction

The direct use of the operator is discouraged, use Aggregation wrapper instead. In other words, get this operator with mean_aggregation instead of calling the SegmentedMean constructor directly.

See also: AggregationOperator, Aggregation, mean_aggregation, SegmentedMax, SegmentedSum, SegmentedPNorm, SegmentedLSE.

Mill.SegmentedPNormType
SegmentedPNorm{T, V <: AbstractVector{T}} <: AggregationOperator{T}

AggregationOperator 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.

Construction

The direct use of the operator is discouraged, use Aggregation wrapper instead. In other words, get this operator with pnorm_aggregation instead of calling the SegmentedPNorm constructor directly.

See also: AggregationOperator, Aggregation, pnorm_aggregation, SegmentedMax, SegmentedMean, SegmentedSum, SegmentedLSE.

Mill.SegmentedLSEType
SegmentedLSE{T, V <: AbstractVector{T}} <: AggregationOperator{T}

AggregationOperator 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.

Construction

The direct use of the operator is discouraged, use Aggregation wrapper instead. In other words, get this operator with lse_aggregation instead of calling the SegmentedLSE constructor directly.

See also: AggregationOperator, Aggregation, lse_aggregation, SegmentedMax, SegmentedMean, SegmentedSum, SegmentedPNorm.

Mill.meanmax_aggregationFunction
meanmax_aggregation([t::Type, ]d::Int)

Construct Aggregation consisting of SegmentedMean and SegmentedMax operators.

Examples

julia> meanmax_aggregation(4)
Aggregation{Float32}:
 SegmentedMean(ψ = Float32[0.0, 0.0, 0.0, 0.0])
 SegmentedMax(ψ = Float32[0.0, 0.0, 0.0, 0.0])

julia> meanmax_aggregation(Int64, 2)
Aggregation{Int64}:
 SegmentedMean(ψ = [0, 0])
 SegmentedMax(ψ = [0, 0])

See also: Aggregation, AggregationOperator, SegmentedSum, SegmentedMax, SegmentedMean, SegmentedPNorm, SegmentedLSE.