{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"redocly_category":"Products","product_name":"Machine Learning","type":"markdown"},"seo":{"title":"Cltv Prediction","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"cltv-prediction","__idx":0},"children":["Cltv Prediction"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The CLTV Prediction solution notebook forecasts customer lifetime value (CLTV) using an open source Python library ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/CamDavidsonPilon/lifetimes"},"children":["Lifetimes"]}," for implementing the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://en.wikipedia.org/wiki/Buy_Till_you_Die"},"children":["Buy Till You Die (BTYD)"]}," model."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/112066640.443827cec104e35bc89a87cb7fb1f8ad148fdae7ac73349fd4e927d7adef41b5.3cb60505.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["BTYD is implemented using:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://brucehardie.com/papers/018/fader_et_al_mksc_05.pdf"},"children":["BG/NBD"]}," (Beta-Geometric/Negative Binomial Distribution) model fits on transactional history curves describing the distribution of purchase frequencies and engagement drop-off following a prior purchase."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.brucehardie.com/notes/025/gamma_gamma.pdf"},"children":["Gamma-Gamma model"]}," is used to predict average spend per transaction."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"expected-input","__idx":1},"children":["Expected Input"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This notebook takes the same input format to RFM analysis notebook, a transaction table specified by  ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["input_table"]}]}," option, having  ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["user_column"]}]}," ,  ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tstamp_column"]}]}," , and  ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["amount_column"]}]}," columns, as follows:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"user"},"children":["user"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"tstamp"},"children":["tstamp"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"amount"},"children":["amount"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["3105285968"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2011-04-05"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["115"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1850985734"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2011-11-23"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1037"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["274382808"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2011-04-25"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["17"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["358273144"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2011-04-02"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["60"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data accepts various ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://en.wikipedia.org/wiki/ISO_8601"},"children":["ISO-8601 datetime format"]}," supported by ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dateutil.readthedocs.io/en/stable/parser.html"},"children":["dateutil"]}," as well as unix timestamp for the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tstamp"]}]}," column."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A CLTV notebook uses date-based frequency/recency for CLTV prediction. Timestamp information is processed at the resolution of 24 hours intervals. Hours, minutes, and seconds, are not used."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"expected-outcome","__idx":2},"children":["Expected Outcome"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In  ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["output_table:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Note that ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["frequency,"]}," ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["recency, and tenure"]}," are measured in days."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tenure"]}]}," represents the number of days since the customer initially issued a transaction."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["CLTVs (monetary values) for the next 1, 3, 6, 12, 24 months are exported."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Percentile rank takes value between 0 and 100."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The  ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["automl_alive_prob"]}]}," represents probability of customers alive now."]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"customerid"},"children":["customerid"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"frequency"},"children":["frequency"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"recency"},"children":["recency"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"tenure"},"children":["tenure"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"monetary_value"},"children":["monetary_value"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_1m"},"children":["automl_cltv_1m"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_1m_pctile"},"children":["automl_cltv_1m_pctile"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_3m"},"children":["automl_cltv_3m"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_3m_pctile"},"children":["automl_cltv_3m_pctile"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_6m"},"children":["automl_cltv_6m"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_6m_pctile"},"children":["automl_cltv_6m_pctile"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_12m"},"children":["automl_cltv_12m"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_12m_pctile"},"children":["automl_cltv_12m_pctile"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_24m"},"children":["automl_cltv_24m"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_cltv_24m_pctile"},"children":["automl_cltv_24m_pctile"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"automl_alive_prob"},"children":["automl_alive_prob"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12347"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["365"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["367"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["599.701667"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["9.753"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["82.832"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["28.97"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["82.832"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["57.086"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["82.832"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["110.856"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["82.832"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["209.203"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["82.832"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.998192"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12348"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["3"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["283"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["358"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["301.48"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["3.277"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["36.989"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["9.734"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["36.989"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["19.181"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["36.989"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["37.246"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["36.989"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["70.286"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["36.989"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.990166"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12352"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["260"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["296"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["368.256667"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["7.203"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["72.581"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["21.394"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["72.581"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["42.157"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["72.581"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["81.863"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["72.581"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["154.486"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["72.616"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.996345"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12356"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["303"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["325"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["269.905"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2.628"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["26.487"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["7.805"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["26.487"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["15.38"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["26.487"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["29.864"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["26.452"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["56.353"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["26.487"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.990548"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12358"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["149"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["150"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["683.2"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6.632"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["69.176"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["19.698"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["69.176"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["38.809"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["69.176"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["75.345"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["69.14"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["142.125"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["69.14"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.947"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12359"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["3"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["274"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["331"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1941.693333"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["19.746"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["95.09"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["58.652"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["95.09"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["115.574"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["95.09"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["224.424"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["95.09"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["423.502"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["95.054"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.991769"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12360"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["148"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["200"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["789.24"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["9.192"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80.86"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["27.301"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80.86"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["53.795"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80.86"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["104.452"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80.86"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["197.079"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80.86"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.984178"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["..."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["audience_name"]}]}," is specified as an input parameter, the following values will be created as new attributes of the specified parent segment where ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Xm"]}," represents months later."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["automl_cltv_Xm"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["automl_cltv_Xm_pctile"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["automl_cltv_segment"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["automl_alive_prob"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["automl_cltv_segment"]}]}," splits ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["automl_cltv_12m"]}]}," into five groups (very low/low/medium/high/very high) using quantiles, and then generates five CDP Segments."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-graph-outputs","__idx":3},"children":["Example Graph Outputs:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/112066641.2a1f1649e3d01a383b836d3c906c90ec5ec10a0de7eddc21e89289f7b17c43b4.3cb60505.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/112066642.3dd47bd3d02ea9eceab9c71758eb5b4c99c56c9b88635e9cdf8678b6386986ae.3cb60505.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"workflow-example","__idx":4},"children":["Workflow Example"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Find a sample workflow in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/treasure-boxes/blob/automl/machine-learning-box/automl/cltv.dig"},"children":["Treasure Boxes"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"+run_cltv:\n  ipynb>:\n    notebook: CLTV\n    input_table: ml_datasets.online_retail_txn\n    output_table: ml_results.online_retail_cltv_result\n    user_column: customerid\n    tstamp_column: invoicedate\n    amount_column: purchaseamount\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"parameters","__idx":5},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter Name"},"children":["Parameter Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Required"},"children":["Required"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Data Type"},"children":["Data Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Default Value"},"children":["Default Value"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Example value"},"children":["Example value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["input_table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Specify a TD table used for CLTV prediction like dbname.table_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["yes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string (dbname.table_name)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ml_dataset.td_txn"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["user_column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Specify a column name for user"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["user"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["user"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["tstamp_column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Specify a column name for timestamp"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["tstamp"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["time"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["amount_column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Specify a column name for transaction amount such as purchase amount. Numerical values expected for data in this column."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["amount"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["purchase_amount"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["output_table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Specify a TD table to export CLTV prediction result as dbname.table_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string (dbname.table_name)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ml_output.rfm"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["discount_rate"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The monthly adjusted discount rate in a range between 0.0 and 1.0. 0 means no adjustment."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["float"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.01"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.01"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["hide_table_contents"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Suppress showing table contents"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["boolean"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["false"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["false"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["audience_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Audience name to merge an attribute table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["master_segment_name"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["foreign_key"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Foreign key column name of a master segment used for Audience integration. user_column value is used if not set."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["td_canonical_id"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["segment_time_horizon"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Time horizon for CLTV segments in 1m/3m/6m/12m/24m"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["no"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["12m"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6m"]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["discount_rate"]}]}," parameter is based on the concept of ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://en.wikipedia.org/wiki/Discounted_cash_flow"},"children":["DCF (discounted cash flow)"]},", where you discount the future monetary value by a discount rate to get the present value of that cash flow, adjusting for cost of capital. You can set 0 to avoid cost of capital."]}]}]},"headings":[{"value":"Cltv Prediction","id":"cltv-prediction","depth":1},{"value":"Expected Input","id":"expected-input","depth":2},{"value":"Expected Outcome","id":"expected-outcome","depth":2},{"value":"Example Graph Outputs:","id":"example-graph-outputs","depth":3},{"value":"Workflow Example","id":"workflow-example","depth":2},{"value":"Parameters","id":"parameters","depth":2}],"frontmatter":{"seo":{"title":"Cltv Prediction"}},"lastModified":"2026-01-27T10:05:25.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/machine-learning/automl/notebook-solutions/cltv-prediction","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}