1
$\begingroup$

So I'm doing a use case for a company interview and one of the questions is to calculate the CTR for a sorting algorithm.

My question would be: Should I remove the operations where there were no products shown (even though some of them there were clicks on products)?Example (should discard this columns?):

Number of impressions | Number of clicks
            0         |      1
            0         |      3
            0         |      0

CTR = #products clicked/#products shown

My other doubt is wether should I sum the clicks and the products shown and then divide one on other OR should I do the CTR for each operation:

Pseudo Python code (imagine that I have a dataframe with several operations as rows):

CTR = pd_df["no_clicks"].sum() / pd_df["no_impressions"].sum()

OR

pd_df["CTR"] = pd_df["no_clicks"] / pd_df["no_impressions"]
CTR = pd_df["CTR"].mean()
$\endgroup$
0
$\begingroup$

I have no knowledge at all about this kind of problem, but logically I would say:

Should I remove the operations where there were no products shown (even though some of them there were clicks on products)?Example (should discard this columns?):

Yes, because otherwise you could in theory end up with a rate higher than 1, this wouldn't make sense. However this raises the question of what exactly is represented: since some clicks can be counted when there is no product, it looks like the number of clicks is over-estimated in the data since the clicks are supposed to be on products.

Also note that it's the rows which would be removed in this case, not the columns.

My other doubt is wether should I sum the clicks and the products shown and then divide one on other OR should I do the CTR for each operation:

This issue means that either the data doesn't have the proper format to apply the definition (strictly speaking the data should have one row for every product shown, and the number of clicks should be either 0 or 1), or that the instructions for applying the CTR formula with this specific data are under-specified. I would say that the first option is closer to the original formula since it doesn't require to do a mean over individual rates.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.