Join the newly launched Discord
community for real-time discussions, peer support, and direct interaction with the Meridian team!
meridian.data.load.XrDatasetDataLoader
Stay organized with collections
Save and categorize content based on your preferences.
Reads data from an xarray.Dataset
object.
Inherits From: InputDataLoader
meridian
.
data
.
load
.
XrDatasetDataLoader
(
dataset
:
xr
.
Dataset
,
kpi_type
:
str
,
name_mapping
:
(
Mapping
[
str
,
str
]
|
None
)
=
None
)
Example:
data_loader
=
XrDatasetDataLoader
(
pickle
.
loads
(
'data.pickle'
))
data
=
data_loader
.
load
()
An xarray.Dataset
object containing the input data.
A string denoting whether the KPI is of a 'revenue'
or 'non-revenue'
type. When the kpi_type
is 'non-revenue'
and revenue_per_kpi
exists, ROI calibration is used and the analysis is
run on revenue. When revenue_per_kpi
doesn't exist for the same kpi_type
, custom ROI calibration is used and the analysis is run on
KPI.
An optional dictionary whose keys are the current
coordinates or array names in the input
dataset and whose values are
the desired coordinates ( geo
, time
, media_time
, media_channel
and/or rf_channel
, control_variable
, non_media_channel
, organic_media_channel
, organic_rf_channel
) or array names ( kpi
, revenue_per_kpi
, media
, media_spend
and/or rf_spend
, controls
, population
, non_media_treatments
, organic_media
, organic_reach
, organic_frequency
). Mapping must be provided if the names in the input
dataset are different from the required ones, otherwise errors
are thrown.
An xr.Dataset
object containing the input data.
A string denoting whether the KPI is of a 'revenue'
or 'non-revenue'
type. When the kpi_type
is 'non-revenue'
and revenue_per_kpi
exists, ROI calibration is used and the analysis is run
on revenue. When revenue_per_kpi
doesn't exist for the same kpi_type
,
custom ROI calibration is used and the analysis is run on KPI.
Methods
load
View source
load
()
->
meridian
.
data
.
input_data
.
InputData
Returns an InputData
object containing the data from the dataset.
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\u003e\u003ccode\u003eXrDatasetDataLoader\u003c/code\u003e reads data from an \u003ccode\u003exarray.Dataset\u003c/code\u003e object, providing a structured way to load data for analysis.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ekpi_type\u003c/code\u003e argument specifies whether the Key Performance Indicator (KPI) is \u003ccode\u003e'revenue'\u003c/code\u003e or \u003ccode\u003e'non-revenue'\u003c/code\u003e, impacting how the data is processed and analyzed.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ename_mapping\u003c/code\u003e allows users to customize how the coordinates and array names in the input dataset are mapped to the required names used in analysis.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eload()\u003c/code\u003e method within \u003ccode\u003eXrDatasetDataLoader\u003c/code\u003e processes the data from the \u003ccode\u003exarray.Dataset\u003c/code\u003e and returns an \u003ccode\u003eInputData\u003c/code\u003e object, which is the structured data to be used within the system.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/google/meridian/blob/v1.2.0/meridian/data/load.py#L50-L319) |\n\nReads data from an `xarray.Dataset` object.\n\nInherits From: [`InputDataLoader`](../../../meridian/data/load/InputDataLoader.md) \n\n meridian.data.load.XrDatasetDataLoader(\n dataset: xr.Dataset,\n kpi_type: str,\n name_mapping: (Mapping[str, str] | None) = None\n )\n\nExample: \n\n data_loader = XrDatasetDataLoader(pickle.loads('data.pickle'))\n data = data_loader.load()\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dataset` | An `xarray.Dataset` object containing the input data. |\n| `kpi_type` | A string denoting whether the KPI is of a `'revenue'` or `'non-revenue'` type. When the `kpi_type` is `'non-revenue'` and `revenue_per_kpi` exists, ROI calibration is used and the analysis is run on revenue. When `revenue_per_kpi` doesn't exist for the same `kpi_type`, custom ROI calibration is used and the analysis is run on KPI. |\n| `name_mapping` | An optional dictionary whose keys are the current coordinates or array names in the `input` dataset and whose values are the desired coordinates (`geo`, `time`, `media_time`, `media_channel` and/or `rf_channel`, `control_variable`, `non_media_channel`, `organic_media_channel`, `organic_rf_channel`) or array names (`kpi`, `revenue_per_kpi`, `media`, `media_spend` and/or `rf_spend`, `controls`, `population`, `non_media_treatments`, `organic_media`, `organic_reach`, `organic_frequency`). Mapping must be provided if the names in the `input` dataset are different from the required ones, otherwise errors are thrown. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dataset` | An `xr.Dataset` object containing the input data. |\n| `kpi_type` | A string denoting whether the KPI is of a `'revenue'` or `'non-revenue'` type. When the `kpi_type` is `'non-revenue'` and `revenue_per_kpi` exists, ROI calibration is used and the analysis is run on revenue. When `revenue_per_kpi` doesn't exist for the same `kpi_type`, custom ROI calibration is used and the analysis is run on KPI. |\n\n\u003cbr /\u003e\n\nMethods\n\n`load`\n\n[View source](https://github.com/google/meridian/blob/v1.2.0/meridian/data/load.py#L291-L319) \n\n load() -\u003e ../../../meridian/data/input_data/InputData.md\n\nReturns an `InputData` object containing the data from the dataset."]]