Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Last answered:

29 Dec 2023

Posted on:

29 Dec 2023

0

shouldn't brand5_cross_brand4 be the same as df_own_brand_4?

Looking at the code, why we need to create something confusing like df_brand5_cross_brand4_ while what it actually does is just to create df_own_brand_4?

Basically everything is the same up to finding the purchase probability.

Then, only when I need to calculate the cross brand elasticity, we use something like brand5_cross_brand4_elasticity = -beta5 * cross_price_range * pr_cross_brand

Isn't this more efficient and more understandable?


Ex from the course note:

# Calculating cross-brand price elasticity for brand 5 with respect to brand 4 for the Well-off segment.
df_brand5_cross_brand4_s3 = pd.DataFrame(index = np.arange(price_range.size))
df_brand5_cross_brand4_s3['Price_1'] = brand_choice_s3['Price_1'].mean()
df_brand5_cross_brand4_s3['Price_2'] = brand_choice_s3['Price_2'].mean()
df_brand5_cross_brand4_s3['Price_3'] = brand_choice_s3['Price_3'].mean()
df_brand5_cross_brand4_s3['Price_4'] = price_range
df_brand5_cross_brand4_s3['Price_5'] = brand_choice_s3['Price_5'].mean()

predict_brand5_cross_brand4_s3 = model_brand_choice_s3.predict_proba(df_brand5_cross_brand4_s3)
pr_cross_brand_5_s3 = predict_brand5_cross_brand4_s3[: ][: , 3]

# Update master data frame to include the newly obtained cross-brand price elasticities.
brand5_cross_brand4_price_elasticity_s3 = -beta5 * price_range * pr_cross_brand_5_s3
df_price_elasticities['Brand_5_Cross_Brand_4_S3'] = brand5_cross_brand4_price_elasticity_s3

My version:

df_own_brand_4 = pd.DataFrame(index=np.arange(price_range.size))
df_own_brand_4['Price_1'] = brand_choice['Price_1'].mean()
df_own_brand_4['Price_2'] = brand_choice['Price_2'].mean()
df_own_brand_4['Price_3'] = brand_choice['Price_3'].mean()
df_own_brand_4['Price_4'] = price_range
df_own_brand_4['Price_5'] = brand_choice['Price_5'].mean()

model_own_brand_4 = model_brand_choice.predict_proba(df_own_brand_4)
pr_own_brand_4 = model_own_brand_4[:][:,3]


brand_5_cross_brand_4_price_elasticity = -beta5 * price_range * pr_own_brand_4
df_price_elasticity['Brand_5_Cross_Brand_4'] = brand_5_cross_brand_4_price_elasticity


1 answers ( 0 marked as helpful)
Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

29 Dec 2023

0

Cont: 
Isn't it the same? Please explain to me if I missed anything.

Submit an answer