shunping commented on code in PR #34018: URL: https://github.com/apache/beam/pull/34018#discussion_r1962803698
########## sdks/python/apache_beam/ml/anomaly/aggregations.py: ########## @@ -0,0 +1,263 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import collections +import math +import statistics +from typing import Callable +from typing import Iterable + +from apache_beam.ml.anomaly.base import AggregationFn +from apache_beam.ml.anomaly.base import AnomalyPrediction +from apache_beam.ml.anomaly.specifiable import specifiable + + +class LabelAggregation(AggregationFn): + """Aggregates anomaly predictions based on their labels. + + This is an abstract base class for `AggregationFn`s that combine multiple + `AnomalyPrediction` objects into a single `AnomalyPrediction` based on + the labels of the input predictions. + + Args: + agg_func (Callable[[Iterable[int]], int]): A function that aggregates + a collection of anomaly labels (integers) into a single label. + include_history (bool): If True, include the input predictions in the + `agg_history` of the output. Defaults to False. Review Comment: I use that to store pre-aggregated predictions so that users can always go back to check what leads to the aggregated result. It is kind of a history to me, but I agree that it may be misleading in some other context. If you have a better term, I am more than happy to hear that. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
