-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_improved_cli.py
More file actions
217 lines (174 loc) Β· 10.4 KB
/
Copy pathtest_improved_cli.py
File metadata and controls
217 lines (174 loc) Β· 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env python3
"""
Test script to demonstrate the improved CLI with better business explanations
"""
import sys
import os
import time
import numpy as np
import pandas as pd
import warnings
warnings.filterwarnings('ignore')
# Add parent directory to path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Color codes
class Colors:
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
WHITE = '\033[97m'
BOLD = '\033[1m'
END = '\033[0m'
def create_improved_elasticity_chart():
"""Create an improved elasticity chart with business-focused explanations."""
chart = f"""
{Colors.BOLD}{Colors.CYAN}π― IMPROVED: ELASTICITY ANALYSIS RESULTS{Colors.END}
{Colors.YELLOW}{'='*70}{Colors.END}
{Colors.GREEN}Method Elasticity What This Means for You{Colors.END}
{Colors.YELLOW}{'-'*70}{Colors.END}
{Colors.CYAN}Double ML{Colors.END} -1.234 π¨ HIGH SENSITIVITY: Be very careful with price increases
{Colors.MAGENTA}PyBLP Structural{Colors.END} -1.156 π¨ HIGH SENSITIVITY: Customers will switch if you raise prices
{Colors.BLUE}Panel Data{Colors.END} -0.987 β οΈ MODERATE SENSITIVITY: You can adjust prices carefully
{Colors.GREEN}AIDS Demand{Colors.END} -1.089 π¨ HIGH SENSITIVITY: Focus on promotions to drive volume
{Colors.YELLOW}Bayesian{Colors.END} -1.201 π¨ HIGH SENSITIVITY: Test small price changes first
{Colors.RED}ML DML{Colors.END} -1.167 π¨ HIGH SENSITIVITY: Use discounts strategically
{Colors.YELLOW}{'='*70}{Colors.END}
{Colors.BOLD}π What This Means for Your Business:{Colors.END}
{Colors.RED}π¨ HIGH PRICE SENSITIVITY: Customers will buy significantly less when you raise prices{Colors.END}
{Colors.RED} β Use promotions and discounts to drive volume{Colors.END}
{Colors.RED} β Be careful with price increases - test small changes first{Colors.END}
{Colors.BOLD}π‘ IMMEDIATE ACTION ITEMS:{Colors.END}
{Colors.YELLOW}π― Pricing Strategy:{Colors.END}
β’ Products with elasticity < -1.0: Use promotions to drive volume
β’ Products with elasticity > -0.5: You can raise prices without losing many customers
β’ Test 5-10% price changes on your most elastic products first
{Colors.BLUE}π Portfolio Management:{Colors.END}
β’ When raising prices on one product, expect customers to switch to substitutes
β’ Bundle complementary products together to reduce price sensitivity
β’ Use cross-price data to set competitive prices against rivals
{Colors.MAGENTA}π₯ Customer Targeting:{Colors.END}
β’ Send discount offers to price-sensitive customer segments
β’ Focus premium marketing on less price-sensitive groups
β’ Adjust pricing by location based on local sensitivity patterns
"""
return chart
def create_improved_cross_price_matrix():
"""Create an improved cross-price matrix with business explanations."""
matrix = f"""
{Colors.BOLD}{Colors.MAGENTA}π IMPROVED: CROSS-PRICE ELASTICITY MATRIX{Colors.END}
{Colors.YELLOW}{'='*90}{Colors.END}
{Colors.CYAN}Product Cola A Cola B Cola C Pepsi Sprite{Colors.END}
{Colors.YELLOW}{'-'*90}{Colors.END}
{Colors.GREEN}Cola A{Colors.END} π΄ -1.234 π 0.156 π 0.089 π 0.234 π 0.123
{Colors.GREEN}Cola B{Colors.END} π 0.145 π΄ -1.156 π 0.167 π 0.198 π 0.134
{Colors.GREEN}Cola C{Colors.END} π 0.098 π 0.123 π΄ -1.089 π 0.156 π 0.145
{Colors.BLUE}Pepsi{Colors.END} π 0.234 π 0.198 π 0.156 π΄ -1.201 π 0.167
{Colors.BLUE}Sprite{Colors.END} π 0.123 π 0.134 π 0.145 π 0.167 π΄ -1.167
{Colors.YELLOW}{'='*90}{Colors.END}
{Colors.BOLD}π How to Read This Matrix:{Colors.END}
{Colors.RED}π΄ High own-price sensitivity: Be careful raising prices{Colors.END}
{Colors.YELLOW}π‘ Moderate own-price sensitivity: You can adjust prices carefully{Colors.END}
{Colors.GREEN}π’ Low own-price sensitivity: You have pricing power{Colors.END}
{Colors.GREEN}π Substitutes: When you raise price of one, customers buy the other{Colors.END}
{Colors.BLUE}π Complements: When you raise price of one, customers buy less of both{Colors.END}
{Colors.WHITE}βͺ Independent: Products don't affect each other's sales{Colors.END}
{Colors.BOLD}π‘ Business Strategy Tips:{Colors.END}
β’ Focus promotions on high-sensitivity products (π΄)
β’ Use substitute products (π) to capture customers from competitors
β’ Bundle complementary products (π) together for better value
β’ Independent products (βͺ) can be priced without worrying about cannibalization
{Colors.BOLD}π― Real Business Example:{Colors.END}
{Colors.CYAN}When you raise Pepsi prices 10%, Coca-Cola sales increase 8% (customers switch),{Colors.END}
{Colors.CYAN}but water sales barely change (they're independent). This tells you Pepsi and Coke{Colors.END}
{Colors.CYAN}compete directly - use this to set competitive prices!{Colors.END}
"""
return matrix
def create_method_explanation_demo():
"""Create a demo of improved method explanations."""
explanation = f"""
{Colors.BOLD}{Colors.CYAN}π What This Means for Your Business{Colors.END}
{Colors.YELLOW}{'='*60}{Colors.END}
{Colors.BOLD}Double Machine Learning (DML){Colors.END}
{Colors.YELLOW}What it tells you:{Colors.END} Shows you exactly how much sales will change when you change prices,
after accounting for everything else that affects demand (like weather, holidays, competitor actions).
{Colors.GREEN}Why you care:{Colors.END} You get clean, reliable numbers for pricing decisions. No more guessing
if a sales drop was due to your price increase or something else.
{Colors.BLUE}Real example:{Colors.END} If you raise your cola price by 10% and see a 12% sales drop, DML tells you:
'8% of that drop was due to your price increase, 4% was due to the heat wave that week.'
{Colors.YELLOW}{'-'*60}{Colors.END}
{Colors.BOLD}Instrumental Variables (IV){Colors.END}
{Colors.YELLOW}What it tells you:{Colors.END} Uses cost changes (like supplier price increases) to measure how
customers really respond to price changes, without any bias from your pricing strategy.
{Colors.GREEN}Why you care:{Colors.END} Gives you the most trustworthy price sensitivity numbers because it uses
'natural experiments' - when costs go up, you have to raise prices, and we can see how customers react.
{Colors.BLUE}Real example:{Colors.END} When sugar costs increase 20% and you raise cola prices 15%, IV analysis
shows: 'Customers will buy 18% less cola for every 10% price increase.' This is your true price sensitivity.
{Colors.YELLOW}{'-'*60}{Colors.END}
{Colors.BOLD}Cross-Price Elasticity Matrix{Colors.END}
{Colors.YELLOW}What it tells you:{Colors.END} Shows you exactly what happens to sales of other products when you
change the price of one product. It reveals which products customers switch between.
{Colors.GREEN}Why you care:{Colors.END} Helps you optimize your entire product portfolio pricing. You can see if
products compete with each other or if they're bought together, and price accordingly.
{Colors.BLUE}Real example:{Colors.END} The matrix might show: 'When you raise Pepsi prices 10%, Coca-Cola sales
increase 8% (customers switch), but water sales barely change (they're independent).' This tells you
Pepsi and Coke compete directly.
"""
return explanation
def run_improved_demo():
"""Run the improved demo."""
print(f"""
{Colors.CYAN}{Colors.BOLD}
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β π― IMPROVED CLI DEMO - BUSINESS-FOCUSED EXPLANATIONS π― β
β β
β π Clear, Actionable Insights for Marketing Managers β
β π Real Examples and Immediate Action Items β
β π‘ No Technical Jargon - Just Business Value β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
{Colors.END}
""")
# Demo sections
demos = [
("Improved Elasticity Analysis", create_improved_elasticity_chart),
("Improved Cross-Price Matrix", create_improved_cross_price_matrix),
("Method Explanations", create_method_explanation_demo)
]
for title, demo_func in demos:
print(f"\n{Colors.BOLD}{Colors.CYAN}π {title} Demo{Colors.END}")
# Simulate processing
print(f"{Colors.YELLOW}β³ Generating {title.lower()}...{Colors.END}")
time.sleep(1)
print(f"{Colors.GREEN}β
{title} demo ready!{Colors.END}")
# Display the demo
demo_content = demo_func()
print(demo_content)
input(f"\n{Colors.BLUE}Press Enter to continue to next demo...{Colors.END}")
# Final message
final_message = f"""
{Colors.GREEN}{Colors.BOLD}π Improved Demo Complete!{Colors.END}
{Colors.WHITE}Key Improvements:{Colors.END}
β’ Clear business language instead of technical jargon
β’ Real-world examples that Marketing Managers can relate to
β’ Immediate action items with specific recommendations
β’ Visual indicators (π¨β οΈβ
) for quick understanding
β’ Strategic tips for each analysis type
{Colors.YELLOW}The improved CLI tools now provide:{Colors.END}
β’ What each number actually means for your business
β’ Why you should care about each analysis
β’ Real examples you can relate to
β’ Specific actions you can take immediately
{Colors.CYAN}These tools now speak your language and give you actionable insights!{Colors.END}
"""
print(final_message)
if __name__ == "__main__":
try:
run_improved_demo()
except KeyboardInterrupt:
print(f"\n{Colors.YELLOW}π Demo interrupted by user. Goodbye!{Colors.END}")
except Exception as e:
print(f"\n{Colors.RED}β Error: {e}{Colors.END}")