Open rain-ml opened 2 years ago
Hi rain-ml, It looks like you may not have run one of the prior cells that creates the LTV_PARAMS dictionary:
LTV_PARAMS = {
'WINDOW_LENGTH': 0,
'WINDOW_STEP': 30,
'WINDOW_STEP_INITIAL': 90,
'LENGTH_FUTURE': 30,
'MAX_STDV_MONETARY': 500,
'MAX_STDV_QTY': 100,
'TOP_LTV_RATIO': 0.2
}
LTV_PARAMS
In other words, in the first line of your code, %%bigquery is expecting to import a dictionary which passes in variables that can then be used in the SQL code below it. This is why your output says:
--params is not a correctly formatted JSON string or a JSON serializable dictionary
Once you create the LTV_PARAMS dictionary and use it as part of %%bigquery, it should then allow you to reference the two variables @MAX_STDV_MONETARY @MAX_STDV_QTY which were set in LTV_PARAMS above:
DECLARE MAX_STDV_MONETARY INT64 DEFAULT @MAX_STDV_MONETARY;
DECLARE MAX_STDV_QTY INT64 DEFAULT @MAX_STDV_QTY;
If you don't like passing in LTV_PARAMS
, you can also remove it and replace it with values directly, such as:
%%bigquery --project $PROJECT_ID
DECLARE MAX_STDV_MONETARY INT64 DEFAULT 500;
DECLARE MAX_STDV_QTY INT64 DEFAULT 100;
CREATE OR REPLACE TABLE `ltv_ecommerce.20_aggred` AS
SELECT
customer_id,
order_day,
ROUND(day_value_after_returns, 2) AS value,
day_qty_after_returns as qty_articles,
day_num_returns AS num_returns,
CEIL(avg_time_to_return) AS time_to_return
FROM (
.....
Hope this helps
Hi polong-lin,
I did run the LTV_PARAMS cell before referencing it and that's how I got the original error.
In fact, If I didn't run the LTV_PARAMS cell, here's the error message:
NameError: Parameter expansion failed, undefined variable "LTV_PARAMS".
Anyways, I just hard code it for now like you suggested without using params. Thanks!
Hi all,
I'm running the LTV lookalike notebook: https://github.com/GoogleCloudPlatform/analytics-componentized-patterns/blob/master/retail/ltv/bqml/notebooks/bqml_automl_ltv_activate_lookalike.ipynb on a Vertex AI user-managed notebook, but I got the error as written in the title.
I got the error when running the first cell of the Aggregate per day per customer chapter, i.e. the cell starting with this code:
Does anyone know how to fix this?
Here is the full error message I got: