# tf_privacy.NoPrivacyAverageQuery

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/no_privacy_query.py#L32-L88) |

Implements DPQuery interface for an average query with no privacy.

Inherits From: [`SumAggregationDPQuery`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/SumAggregationDPQuery), [`DPQuery`](https://www.tensorflow.org/responsible_ai/privacy/api_docs/python/tf_privacy/DPQuery)

Accumulates vectors and normalizes by the total number of accumulated vectors.
Under some sampling schemes, such as Poisson subsampling, the number of
records in a sample is a private quantity, so we lose all privacy guarantees
by using the number of records directly to normalize.

Also allows weighted accumulation, unlike the base class DPQuery. In a private
implementation of weighted average, the weight would have to be itself
privatized.

## Methods

### `accumulate_preprocessed_record`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/dp_query.py#L292-L295)

    accumulate_preprocessed_record(
        sample_state, preprocessed_record
    )

Implements `tensorflow_privacy.DPQuery.accumulate_preprocessed_record`.

### `accumulate_record`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/no_privacy_query.py#L65-L81)

    accumulate_record(
        params, sample_state, record, weight=1
    )

Implements `tensorflow_privacy.DPQuery.accumulate_record`.

Optional `weight` argument allows weighted accumulation.

<br />

<br />

<br />

| Args ||
|---|---|
| `params` | The parameters for the sample. |
| `sample_state` | The current sample state. |
| `record` | The record to accumulate. |
| `weight` | Optional weight for the record. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The updated sample state. ||

<br />

### `derive_metrics`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/dp_query.py#L256-L268)

    derive_metrics(
        global_state
    )

Derives metric information from the current global state.

Any metrics returned should be derived only from privatized quantities.

<br />

<br />

<br />

| Args ||
|---|---|
| `global_state` | The global state from which to derive metrics. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `collections.OrderedDict` mapping string metric names to tensor values. ||

<br />

### `derive_sample_params`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/dp_query.py#L111-L126)

    derive_sample_params(
        global_state
    )

Given the global state, derives parameters to use for the next sample.

For example, if the mechanism needs to clip records to bound the norm,
the clipping norm should be part of the sample params. In a distributed
context, this is the part of the state that would be sent to the workers
so they can process records.

<br />

<br />

<br />

| Args ||
|---|---|
| `global_state` | The current global state. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| Parameters to use to process records in the next sample. ||

<br />

### `get_noised_result`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/no_privacy_query.py#L83-L88)

    get_noised_result(
        sample_state, global_state
    )

Implements `tensorflow_privacy.DPQuery.get_noised_result`.

### `initial_global_state`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/dp_query.py#L96-L109)

    initial_global_state()

Returns the initial global state for the DPQuery.

The global state contains any state information that changes across
repeated applications of the mechanism. The default implementation returns
just an empty tuple for implementing classes that do not have any persistent
state.

This object must be processable via tf.nest.map_structure.

<br />

<br />

<br />

| Returns ||
|---|---|
| The global state. ||

<br />

### `initial_sample_state`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/no_privacy_query.py#L45-L47)

    initial_sample_state(
        template
    )

Implements `tensorflow_privacy.DPQuery.initial_sample_state`.

### `merge_sample_states`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/dp_query.py#L297-L299)

    merge_sample_states(
        sample_state_1, sample_state_2
    )

Implements `tensorflow_privacy.DPQuery.merge_sample_states`.

### `preprocess_record`

[View source](https://github.com/tensorflow/privacy/blob/v0.9.0/privacy/privacy/dp_query/no_privacy_query.py#L49-L63)

    preprocess_record(
        params, record, weight=1
    )

Implements `tensorflow_privacy.DPQuery.preprocess_record`.

Optional `weight` argument allows weighted accumulation.

<br />

<br />

<br />

| Args ||
|---|---|
| `params` | The parameters for the sample. |
| `record` | The record to accumulate. |
| `weight` | Optional weight for the record. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The preprocessed record. ||

<br />