# tff.aggregators.PrivateQuantileEstimationProcess

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

A [`tff.templates.EstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess) for estimating private quantiles.

Inherits From: [`EstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess), [`IterativeProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/IterativeProcess)

    tff.aggregators.PrivateQuantileEstimationProcess(
        quantile_estimator_query: tfp.QuantileEstimatorQuery,
        record_aggregation_factory: Optional[https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/UnweightedAggregationFactory] = None
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Tuning recommended aggregations for learning](https://www.tensorflow.org/federated/tutorials/tuning_recommended_aggregators) |

This iterative process uses a `tensorflow_privacy.QuantileEstimatorQuery` to
maintain an estimate of the target quantile that is updated after each round.
The `next` function has the following type signature:

(\<{state_type}@SERVER,{float32}@CLIENTS\> -\> {state_type}@SERVER)

Given a `state` of type `state_type`, the most recent estimate of the target
quantile can be retrieved using `report(state)`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `quantile_estimator_query` | A `tfp.QuantileEstimatorQuery` for estimating quantiles with differential privacy. |
| `record_aggregation_factory` | An optional [`tff.aggregators.UnweightedAggregationFactory`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/UnweightedAggregationFactory) to aggregate counts of values below the current estimate. If `None`, defaults to [`tff.aggregators.SumFactory`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/SumFactory). |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `initialize` | A no-arg [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that returns the initial state. |
| `next` | A [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that produces the next state. <br /> Its first argument should always be the current state (originally produced by [`tff.templates.IterativeProcess.initialize`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/IterativeProcess#initialize)), and the first (or only) returned value is the updated state. |
| `report` | A [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that computes the current estimate from `state`. <br /> Given a `state` controlled by this process, computes and returns the most recent estimate of the estimated value. |
| `state_type` | The [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) of the state of the process. |

<br />

## Methods

### `map`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    map(
        map_fn: https://www.tensorflow.org/federated/api_docs/python/tff/Computation
    )

Applies `map_fn` to the estimate function of the process.

This method will return a new instance of `EstimationProcess` with the same
`initailize` and `next` functions, and its `report` function replaced by
`map_fn(report(state))`.

<br />

<br />

<br />

| Args ||
|---|---|
| `map_fn` | A [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) to apply to the result of the `report` function of the process. Must accept the return type of `report`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An `EstimationProcess`. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `EstimateNotAssignableError` | If the return type of `report` is not assignable to the expected input type of `map_fn`. |

<br />

### `no_noise`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    no_noise(
        initial_estimate: float,
        target_quantile: float,
        learning_rate: float,
        multiplier: float = 1.0,
        increment: float = 0.0,
        secure_estimation: bool = False
    )

No-noise estimator for affine function of value at quantile.

Estimates value `C` at `q`'th quantile of input distribution and reports
`rC + i` for multiplier `r` and increment `i`. The quantile `C` is estimated
using the geometric method described in Andrew, Thakkar et al. 2021,
"Differentially Private Learning with Adaptive Clipping"
(<https://arxiv.org/abs/1905.03871>) without noise added.

Note that this estimator does not add noise, so it does not guarantee
differential privacy. It is useful for estimating quantiles in contexts
where rigorous privacy guarantees are not needed.

<br />

<br />

<br />

| Args ||
|---|---|
| `initial_estimate` | The initial estimate of `C`. |
| `target_quantile` | The quantile `q` to which `C` will be adapted. |
| `learning_rate` | The learning rate for the adaptive algorithm. |
| `multiplier` | The multiplier `r` of the affine transform. |
| `increment` | The increment `i` of the affine transform. |
| `secure_estimation` | Whether to perform the aggregation for estimation using [`tff.aggregators.SumFactory`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/SumFactory) (if `False`; default) or [`tff.aggregators.SecureSumFactory`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/SecureSumFactory) (if `True`). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An `EstimationProcess` whose `report` function returns `rC + i`. ||

<br />