I have the following dataset that is part of a bigger dataset but I isolated to make the calculation easier (the whole data has more than 200 rows but as a sample I selected the first 20 rows):
Length CTR
0 3 0.20
1 4 0.22
2 3 0.09
3 3 0.16
4 2 0.04
5 10 0.64
6 3 0.14
7 3 0.13
8 2 0.01
9 4 0.21
10 1 0.00
11 2 0.02
12 2 0.01
13 3 0.01
14 4 0.16
15 3 0.09
16 1 0.01
17 2 0.09
18 3 0.02
19 6 0.63
My idea here is to calculate the probability to have a CTR of 5%, 10%, 20% and so on given the number of length (1, 2, 3...). I did a few tests with crosstab but I'm not sure if that is the right way to go. I also did a regression analysis
#Clicks and installs
from sklearn.linear_model import LinearRegression
# Build linear regression model using installs
# Split data into predictors X and output Y
predictors = ['length']
X1 = df_num[predictors]
y1 = df_num['CTR']
# Initialise and fit model
lm = LinearRegression()
model = lm.fit(X1, y1)
print(f'alpha = {model.intercept_}')
print(f'betas = {model.coef_}')
new_X = [[3]]
print({"Clicks":model.predict(new_X)})
But that only shows me what is the predict CTR given a certain length number. So far I`ve made a heatmap with the correlation between all the variables that I had and those 02 were the ones that had the highest corr (0.72), if that information is any useful. Does anybody know what could be the solution here?
thank you