question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expected_cumulative_transactions will calculate actual transactions incorrectly

See original GitHub issue

While I am using plot_cumulative_transactions, I think I found a bug in utils.expected_cumulative_transactions.

Let’s say I want to build a beta_geo_fitter model, and freq=‘D’. First I will call utils.summary_data_from_transaction_data to summarize my transaction. That function will treat transactions which happened on the same day as one transaction when it calculates frequency.

Later on, when I call plot_cumulative_transactions, I see that it calls utils.expected_cumulative_transactions, but that function will treat multiple transactions happening on the same day as multiple transactions (see the line below).

act_transactions = (transactions_current.groupby(customer_id_col).size() - 1).sum()

As a result, the actual and expected lines I got from plot_cumulative_transactions look very different. I worked around this by calling df.drop_duplicates([customer_id_col, date_col]) on my transaction dataframe first before I call plot_cumulative_transactions.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
aprotopopovcommented, Jan 2, 2018

@CamDavidsonPilon raw transactions are needed to get actual values. That cannot be extracted from final summary matrix. Only if you calculate summary for each time period. P.S. I’m in process of writing tests for that function to get the same values as in BTYD walkthrough.

0reactions
CamDavidsonPiloncommented, Dec 29, 2017

The expected_cumulative_transactions is a bit strange: everywhere else we deal with a summary dataset, but here we ask for the raw transactions.

Anyways, the function is broken, but I have a fix like what @patng323 suggests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loss Given Default (LGD): Two Ways to Calculate, Plus an ...
A financial institution's total LGD is calculated after a review of all outstanding loans using cumulative losses and exposure. Key Takeaways. The loss...
Read more >
COMMON ERRORS IN KRONOS AND HOW TO FIX THEM
Entering hours in the wrong pay period​​ However, the dates will not roll forward to the next pay period until all other areas...
Read more >
Understanding Cash Flow Analysis | Ag Decision Maker
It is defined as the amount of money needed to facilitate business operations and transactions, and is calculated as current assets (cash or...
Read more >
EXAM REVIEW – CHAPTERS 1, 2, 3 - Harper College
Post transactions from the journal to the general ledger. • Prepare a trial balance; identify the types of errors a trial balance can...
Read more >
The Most Common Mistake People Make In Calculating ROI
But before anyone writes a check, you need to calculate the return on ... Cash transactions, meanwhile, show up on the cash flow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found