google / lifetime_value Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Hello,
I am using the zero_inflated_lognormal_loss function as described in the regression notebook. I haven't changed anything in the book. I just changed the input data to be my own but the format is the same. This is the dnn summary I am getting:
However when I try to fit the model I receive the following exception from the loss function:
Epoch 1/400
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[15], line 1
----> 1 history = model.fit(
2 x=x_train,
3 y=y_train,
4 batch_size=1024,
5 epochs=EPOCHS,
6 verbose=2,
7 callbacks=callbacks,
8 validation_data=(x_eval, y_eval)).history
File [/opt/conda/lib/python3.11/site-packages/keras/src/utils/traceback_utils.py:122](http://localhost:10000/opt/conda/lib/python3.11/site-packages/keras/src/utils/traceback_utils.py#line=121), in filter_traceback.<locals>.error_handler(*args, **kwargs)
119 filtered_tb = _process_traceback_frames(e.__traceback__)
120 # To get the full stack trace, call:
121 # `keras.config.disable_traceback_filtering()`
--> 122 raise e.with_traceback(filtered_tb) from None
123 finally:
124 del filtered_tb
File [/opt/conda/lib/python3.11/site-packages/lifetime_value/zero_inflated_lognormal.py:63](http://localhost:10000/opt/conda/lib/python3.11/site-packages/lifetime_value/zero_inflated_lognormal.py#line=62), in zero_inflated_lognormal_loss(labels, logits)
60 positive = tf.cast(labels > 0, tf.float32)
62 logits = tf.convert_to_tensor(logits, dtype=tf.float32)
---> 63 logits.shape.assert_is_compatible_with(
64 tf.TensorShape(labels.shape[:-1].as_list() + [3]))
66 positive_logits = logits[..., :1]
67 classification_loss = tf.keras.losses.binary_crossentropy(
68 y_true=positive, y_pred=positive_logits, from_logits=True)
ValueError: Shapes (None, 3) and (3,) are incompatible
Any clue what am I doing wrong?
Thank you for making the code for the loss function, metrics and example notebooks open source.
From the last paragraph in section 3:
Another key advantage of the ZILN loss is that it provides a full prediction distribution. We obtain not only the probability of returning but also the value distribution of LTV for returning customers. In addition to mean LTV prediction, the uncertainty of LTV predictions can be assessed using quantiles of a lognormal distribution as in general quantile regression.
To me it is unclear both from checking the code examples and the paper, how the LTV prediction distributions are calculated, can you get them both for a singel predictions and a group of prediction for example?
Thank you!
the outdated package is not updated, pls fix
sklearn is being actively deprecated in favor of installing scikit-learn. This means that installing this library will cause failures if the dependencies are not changed to scikit-learn in the setup.py file.
Reference: https://pypi.org/project/sklearn/
Ref:
In the function to calculate ZILN loss,
The classification loss and regression loss is combined together, however, the scale of two loss is different meaning, the binary crossentropy loss is often much smaller than regression loss. Shouldn't we compensate for this difference in scale?
In addition, why do we take the negative of regression loss?
In lifetime_value/notebooks/kaggle_acquire_valued_shoppers_challenge/regression.ipynb
, the output units=3 and activation=relu in the last layer. While in the paper, section 3 mentioned that "three activation functions are sigmoid, identity, and softplus".
First of all, thank you for making the code for the loss function, metrics & example notebooks open source.
I am looking forward to trying this approach out. I have one question that I am a bit confused about.
The paper mentions that the model structure, in combination with the loss function used, allows for one model to capture both objectives: churn prediction and remaining lifetime value prediction.
First, it is capable of predicting the churn probability and LTV value simultane-
ously. It reduces the engineering complexity of building a two-stage model (Vanderveld et al., 2016)
— a binary classification model to predict repeat purchase propensity, followed by a regression model
to predict the LTV of returning customers predicted in stage 1.
Indeed, the loss function returns a composite of both churn & remaining value losses:
return classification_loss + regression_loss
However, the notebooks are split up in two, one for each separate objective.
Can one trained model indeed perform both tasks: the notebooks are split up to illustrate a comparison between the churn and remaining value tasks to two separate models?
Or are did I completely misinterpret the paper? In which it is meant that the type of model can perform both tasks, but you need two trained models: one fine-tuned for each task.
Thanks, and I am looking forward to trying this out. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.