tf.contrib.metrics.streaming_pearson_correlation
Stay organized with collections
Save and categorize content based on your preferences.
Computes Pearson correlation coefficient between predictions
, labels
.
tf.contrib.metrics.streaming_pearson_correlation(
predictions, labels, weights=None, metrics_collections=None,
updates_collections=None, name=None
)
The streaming_pearson_correlation
function delegates to
streaming_covariance
the tracking of three [co]variances:
streaming_covariance(predictions, labels)
, i.e. covariance
streaming_covariance(predictions, predictions)
, i.e. variance
streaming_covariance(labels, labels)
, i.e. variance
The product-moment correlation ultimately returned is an idempotent operation
cov(predictions, labels) / sqrt(var(predictions) * var(labels))
. To
facilitate correlation computation across multiple batches, the function
groups the update_op
s of the underlying streaming_covariance and returns an
update_op
.
If weights
is not None, then it is used to compute a weighted correlation.
NOTE: these weights are treated as "frequency weights", as opposed to
"reliability weights". See discussion of the difference on
https://wikipedia.org/wiki/Weighted_arithmetic_mean#Weighted_sample_variance
Args |
predictions
|
A Tensor of arbitrary size.
|
labels
|
A Tensor of the same size as predictions.
|
weights
|
Optional Tensor indicating the frequency with which an example is
sampled. Rank must be 0, or the same rank as labels , and must be
broadcastable to labels (i.e., all dimensions must be either 1 , or the
same as the corresponding labels dimension).
|
metrics_collections
|
An optional list of collections that the metric value
variable should be added to.
|
updates_collections
|
An optional list of collections that the metric update
ops should be added to.
|
name
|
An optional variable_scope name.
|
Returns |
pearson_r
|
A Tensor representing the current Pearson product-moment
correlation coefficient, the value of
cov(predictions, labels) / sqrt(var(predictions) * var(labels)) .
|
update_op
|
An operation that updates the underlying variables appropriately.
|
Raises |
ValueError
|
If labels and predictions are of different sizes, or if
weights is the wrong size, or if either metrics_collections or
updates_collections are not a list or tuple .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.metrics.streaming_pearson_correlation\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/metrics/python/ops/metric_ops.py#L3277-L3361) |\n\nComputes Pearson correlation coefficient between `predictions`, `labels`. \n\n tf.contrib.metrics.streaming_pearson_correlation(\n predictions, labels, weights=None, metrics_collections=None,\n updates_collections=None, name=None\n )\n\nThe `streaming_pearson_correlation` function delegates to\n`streaming_covariance` the tracking of three \\[co\\]variances:\n\n- `streaming_covariance(predictions, labels)`, i.e. covariance\n- `streaming_covariance(predictions, predictions)`, i.e. variance\n- `streaming_covariance(labels, labels)`, i.e. variance\n\nThe product-moment correlation ultimately returned is an idempotent operation\n`cov(predictions, labels) / sqrt(var(predictions) * var(labels))`. To\nfacilitate correlation computation across multiple batches, the function\ngroups the `update_op`s of the underlying streaming_covariance and returns an\n`update_op`.\n\nIf `weights` is not None, then it is used to compute a weighted correlation.\nNOTE: these weights are treated as \"frequency weights\", as opposed to\n\"reliability weights\". See discussion of the difference on\n\u003chttps://wikipedia.org/wiki/Weighted_arithmetic_mean#Weighted_sample_variance\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `predictions` | A `Tensor` of arbitrary size. |\n| `labels` | A `Tensor` of the same size as predictions. |\n| `weights` | Optional `Tensor` indicating the frequency with which an example is sampled. Rank must be 0, or the same rank as `labels`, and must be broadcastable to `labels` (i.e., all dimensions must be either `1`, or the same as the corresponding `labels` dimension). |\n| `metrics_collections` | An optional list of collections that the metric value variable should be added to. |\n| `updates_collections` | An optional list of collections that the metric update ops should be added to. |\n| `name` | An optional variable_scope name. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `pearson_r` | A `Tensor` representing the current Pearson product-moment correlation coefficient, the value of `cov(predictions, labels) / sqrt(var(predictions) * var(labels))`. |\n| `update_op` | An operation that updates the underlying variables appropriately. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | If `labels` and `predictions` are of different sizes, or if `weights` is the wrong size, or if either `metrics_collections` or `updates_collections` are not a `list` or `tuple`. |\n\n\u003cbr /\u003e"]]