Join the newly launched Discord
community for real-time discussions, peer support, and direct interaction with the Meridian team!
meridian.model.transformers.KpiTransformer
Stay organized with collections
Save and categorize content based on your preferences.
Contains forward and inverse KPI transformation methods.
Inherits From: TensorTransformer
meridian
.
model
.
transformers
.
KpiTransformer
(
kpi
:
meridian
.
backend
.
Tensor
,
population
:
meridian
.
backend
.
Tensor
)
This class stores coefficients to scale KPI, first by geo and then
by mean and standard deviation of KPI.
A tensor of dimension (n_geos, n_times)
containing the KPI data,
used to compute the mean and stddev.
A tensor of dimension (n_geos,)
containing the population of
each geo, used to to compute the population scale factors.
Methods
forward
View source
forward
(
tensor
:
meridian
.
backend
.
Tensor
)
->
meridian
.
backend
.
Tensor
Scales a given tensor using the stored coefficients.
inverse
View source
inverse
(
tensor
:
meridian
.
backend
.
Tensor
)
->
meridian
.
backend
.
Tensor
Scales back a given tensor using the stored coefficients.
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 2025-09-05 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 2025-09-05 UTC."],[[["\u003cp\u003eThis \u003ccode\u003eKpiTransformer\u003c/code\u003e class includes methods for forward and inverse KPI transformations, inheriting from \u003ccode\u003eTensorTransformer\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe class uses two tensors, \u003ccode\u003ekpi\u003c/code\u003e and \u003ccode\u003epopulation\u003c/code\u003e, to store and calculate scaling coefficients for KPI data across different geographies and time periods.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eforward\u003c/code\u003e method scales a tensor utilizing stored coefficients, while the \u003ccode\u003einverse\u003c/code\u003e method performs the reverse operation.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ekpi\u003c/code\u003e argument, having dimensions of \u003ccode\u003e(n_geos, n_times)\u003c/code\u003e, contains KPI data, while \u003ccode\u003epopulation\u003c/code\u003e holds geo population data in \u003ccode\u003e(n_geos,)\u003c/code\u003e dimensions.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/google/meridian/blob/v1.2.0/meridian/model/transformers.py#L178-L227) |\n\nContains forward and inverse KPI transformation methods.\n\nInherits From: [`TensorTransformer`](../../../meridian/model/transformers/TensorTransformer.md) \n\n meridian.model.transformers.KpiTransformer(\n kpi: ../../../meridian/backend/Tensor.md,\n population: ../../../meridian/backend/Tensor.md\n )\n\nThis class stores coefficients to scale KPI, first by geo and then\nby mean and standard deviation of KPI.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------|\n| `kpi` | A tensor of dimension `(n_geos, n_times)` containing the KPI data, used to compute the mean and stddev. |\n| `population` | A tensor of dimension `(n_geos,)` containing the population of each geo, used to to compute the population scale factors. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ||\n|---------------------------|---------------|\n| `population_scaled_mean` | \u003cbr /\u003e \u003cbr /\u003e |\n| `population_scaled_stdev` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n\n`forward`\n\n[View source](https://github.com/google/meridian/blob/v1.2.0/meridian/model/transformers.py#L213-L220) \n\n forward(\n tensor: ../../../meridian/backend/Tensor.md\n ) -\u003e ../../../meridian/backend/Tensor.md\n\nScales a given tensor using the stored coefficients.\n\n`inverse`\n\n[View source](https://github.com/google/meridian/blob/v1.2.0/meridian/model/transformers.py#L222-L227) \n\n inverse(\n tensor: ../../../meridian/backend/Tensor.md\n ) -\u003e ../../../meridian/backend/Tensor.md\n\nScales back a given tensor using the stored coefficients."]]