UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
pdf
keyboard_arrow_up
School
University of California, Berkeley *
*We aren’t endorsed by this school
Course
113
Subject
Economics
Date
Feb 20, 2024
Type
Pages
19
Uploaded by MegaSeahorseMaster651
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
1/19
Lab Solution --- NOT FOR DISTRIBUTION!
Lab CX: Weighted Average
1 Setup
In [1]:
2
HMO Contracts
2.1
Business Decision
A private doctor contracts with health maintenance organizations (HMOs) that provide health
care benefits to employees of large firms. Each HMO pays the doctor a set amount per patient-
in-care per month, regardless of whether the patients actually visit the doctor for treatment.
Those patients that do visit the doctor for treatment pay the doctor a copay per visit, regardless
of the duration of the visit.
The doctor wants to know whether patients from one HMO are more likely to visit than those
from another HMO. Also, she wants to know whether patients from one HMO take more of her
time than those from another HMO. If so, the she might try to negotiate higher pay from the
HMO with patients who are more likely to visit and/or visit longer.
The doctor has the following patients-in-care and HMO contracts:
# Import some useful functions
from
numpy import
*
from
numpy.random import
*
from
datascience import
*
from
statsmodels.formula.api import
*
# Define some useful functions
def
correlation
(array_1, array_2):
return
corrcoef(array_1, array_2).item(
1
)
# Customize look of graphics
import
matplotlib.pyplot as
plt
plt.style.use(
'fivethirtyeight'
)
%
matplotlib inline
# Force display of all values from
IPython.core.interactiveshell import
InteractiveShell
InteractiveShell.ast_node_interactivity =
"all"
# Handle some obnoxious warning messages
import
warnings
warnings.filterwarnings(
"ignore"
)
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
2/19
There are 130 AARP patients-in-care. AARP pays the doctor $100 per patient-in-care per
month. AAPA patients pay the doctor $10 per visit.
There are 110 Aetna patients-in-care. Aetna pays the doctor $100 per patient-in-care per
month. Aetna patients pay the doctor $10 per visit.
There are 120 Blue Cross patients-in-care. Blue Cross pays the doctor $100 per patient-in-
care per month Blue Cross patients pay the doctor $10 per visit
2.2 Data
Retrieve the doctor visit dataset, show the number of observations and the first few
observations.
This dataset records visits for one month. Note that duration is recorded in units of minutes.
In [2]:
Set the pay per patient-in-care per month. Set the copay per visit. For each HMO, set the
number of patients-in-care.
Out[2]:
128
Out[2]:
Patient ID
HMO Plan
Duration
149494695
Aetna
15
114484827
Blue Cross
20
90038933
Blue Cross
15
65338581
Aetna
25
196045149
Aetna
20
66286542
Blue Cross
20
162667323
AARP
30
171010175
AARP
25
217152916
Aetna
15
129287489
Blue Cross
20
... (118 rows omitted)
data =
Table().read_table(
'doctor_visits.csv'
)
data.num_rows
data
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
3/19
In [3]:
2.3 Analysis
Calculate the mean visit duration (minutes).
In [4]:
For each HMO, calculate the number of visits.
Out[3]:
100
Out[3]:
10
Out[3]:
130
Out[3]:
110
Out[3]:
120
Out[3]:
100
Out[3]:
10
Out[3]:
array([130, 110, 120])
Out[4]:
21.25
pay =
100
copay =
10
n_AARP =
130
n_Aetna =
110
n_blue =
120
pay
copay
n_AARP
n_Aetna
n_blue
n =
make_array(
130
,
110
,
120
)
pay
copay
n
mean(data.column(
'Duration'
))
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
4/19
In [5]:
For each HMO, calculate the mean visit duration (minutes).
In [6]:
For each HMO, calculate the sum total visit duration (minutes).
ds = data.group('HMO Plan', sum).select('HMO Plan', 'Duration sum') ds
For each HMO, calculate the revenue rate ($ per hour earned for treating patients).
Hint: Remember to convert minutes to hours.
In [ ]:
Calculate the ratio of revenue rate for Blue Cross patients to revenue rate for Aetna patients.
Calculate the ratio of revenue rate for AARP patients to revenue rate for Blue Cross patients.
Out[5]:
HMO Plan
count
AARP
32
Aetna
48
Blue Cross
48
Out[6]:
HMO Plan
Duration mean
AARP
27.5
Aetna
20
Blue Cross
18.3333
dc =
data.group(
'HMO Plan'
)
dc
dm =
data.group(
'HMO Plan'
, mean).select(
'HMO Plan'
, 'Duration mean'
)
dm
sum_pay_aarp =
n_AARP *
pay
sum_copay_treat_aarp =
dc.column(
'count'
).item(
0
) *
copay
sum_duration_treat_aarp =
ds.column(
'Duration sum'
).item(
0
) /
60
rate_aarp =
(sum_pay_aarp +
sum_copay_treat_aarp) /
sum_duration_treat_aa
sum_pay_aetna =
n_Aetna +
pay
sum_copay_treat_aetna =
dc.column(
'count'
).item(
1
) *
copay
sum_duration_treat_aetna =
ds.column(
'Duration sum'
).item(
1
) /
60
rate_aetna =
(sum_pay_aetna +
sum_copay_treat_aetna) /
sum_duration_treat
sum_pay_blue =
n_blue +
pay
sum_copay_treat_blue =
dc.column(
'count'
).item(
2
) *
copay
sum_duration_treat_blue =
ds.column(
'Duration sum'
).item(
2
) /
60
rate_blue =
(sum_pay_blue +
sum_copay_treat_blue) /
sum_duration_treat_bl
rate_aarp
rate_aetna
rate_blue
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
5/19
In [8]:
2.4 Quiz
The dataset comprises ____
observations.
The dataset comprises ____
variables.
Patients that visited the doctor did so for ____
minutes, on average.
____
AARP patients visited the doctor.
____
Aetna patients visited the doctor.
____
Blue Cross patients visited the doctor.
AARP patients that visited the doctor did so for ____
minutes, on average.
Aetna Patients that visited the doctor did so for ____
minutes, on average.
Blue Cross patients that visited the doctor did so for ____
minutes, on average.
AARP patients that visited the doctor did so for a sum total of ____
minutes.
Aetna patients that visited the doctor did so for a sum total of of ____
minutes.
Blue Cross patients that visited the doctor did so for a sum total of ____
minutes.
The doctor earns $
____
per hour for treating AARP patients, on average.
The doctor earns $
____
per hour for treating Aetna patients, on average.
The doctor earns $
____
per hour for treating Blue Cross patients, on average.
The doctor earns ____
times as much per hour for treating Blue Cross patients as for
treating Aetna patients, on average.
The doctor earns ____
times as much per hour for treating AARP patients as for treating
Blue Cross patients, on average.
Assuming that the doctor will keep the same patients-in-care, she should try to re-negotiate
the pay from ____.
AARP because AARP patients have longer visit durations than those from other HMOs
do, on average.
AARP or Blue Cross because these HMOs each correspond to the lowest sum total
visit duration.
Aetna because there are fewer patients from Aetna than from other HMOs.
Aetna because Aetna patients produce less revenue per hour than those from other
HMOs do, on average.
-----------------------------------------------------------------------
----
NameError Traceback (most recent call l
ast)
Cell In[8], line 1
----> 1 rate_blue / rate_aetna
2
rate_aarp / rate_blue
4
rate
.
item(
2
) / rate
.
item(
1
)
NameError
: name 'rate_blue' is not defined
rate_blue /
rate_aetna
rate_aarp /
rate_blue
rate.item(
2
) /
rate.item(
1
)
rate.item(
0
) /
rate.item(
2
)
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
6/19
3
Restaurant Reviews continued
3.1
Business Decision
An independent marketing firm recently surveyed some of the city's restaurant patrons for their
overall ratings of several restaurants. It is not clear how well the surveyed patrons represent the
city's entire population of patrons. Restaurant #135085 competes with Restaurant #135076, and
their owners are considering launching marketing campaigns that would tout their favorable
customer ratings.
3.2 Data
The dataset comprises several ratings. Each observation corresponds to a customer's review of
a restaurant.
Retrieve the restaurant survey dataset, show the number of observations and the first few
observations
In [13]:
Out[13]:
1161
Out[13]:
userID
placeID
rating
food_rating
service_rating
latitude
longitude
smoker
drink_level
dress_
U1001
135045
1
1
1
22.14
-100.979
false
abstemious
U1001
135033
1
1
1
22.14
-100.979
false
abstemious
U1001
135025
2
2
2
22.14
-100.979
false
abstemious
U1001
135085
0
1
1
22.14
-100.979
false
abstemious
U1001
135039
1
1
1
22.14
-100.979
false
abstemious
U1001
132825
2
2
1
22.14
-100.979
false
abstemious
U1001
132830
1
1
1
22.14
-100.979
false
abstemious
U1001
135051
1
1
2
22.14
-100.979
false
abstemious
U1001
135040
1
1
1
22.14
-100.979
false
abstemious
U1002
135085
1
1
1
22.1501
-100.983
false
abstemious
... (1151 rows omitted)
data_all =
Table.read_table(
'restaurant_reviews.csv'
)
data_all.num_rows
data_all
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
7/19
Show all the possible rating levels.
In [14]:
Build and show a table comprising reviews for restaurant #135085.
Out[14]:
array([0, 1, 2])
unique(data_all.column(
'rating'
))
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
8/19
In [15]:
Out[15]:
36
data1 =
data_all.where(
'placeID'
, 135085
)
data1.num_rows
data1.show()
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
9/19
userID
placeID
rating
food_rating
service_rating
latitude
longitude
smoker
drink_level
dress_
U1001
135085
0
1
1
22.14
-100.979
false
abstemious
U1002
135085
1
1
1
22.1501
-100.983
false
abstemious
U1007
135085
1
2
0
22.1185
-100.938
false
casual
drinker
U1013
135085
1
2
0
22.1746
-100.994
false
abstemious
no
U1016
135085
2
2
0
22.1562
-100.977
false
casual
drinker
U1027
135085
1
1
1
22.1652
-100.987
true
social
drinker
no
U1029
135085
1
1
1
22.1518
-100.989
true
casual
drinker
U1032
135085
1
1
1
22.1692
-100.987
false
abstemious
U1033
135085
2
2
2
22.15
-100.983
false
social
drinker
no
U1036
135085
2
2
2
22.1606
-100.989
false
social
drinker
U1045
135085
2
2
2
22.1567
-100.984
false
casual
drinker
U1046
135085
1
2
1
22.1444
-100.933
false
social
drinker
no
U1049
135085
0
0
0
22.15
-100.983
false
casual
drinker
U1056
135085
2
2
2
22.169
-100.974
false
social
drinker
U1059
135085
2
2
2
18.9883
-99.097
false
abstemious
U1062
135085
0
0
0
22.1958
-101.006
false
casual
drinker
U1077
135085
2
2
2
22.1565
-100.986
false
social
drinker
U1081
135085
1
2
1
22.2077
-100.942
false
casual
drinker
U1084
135085
2
2
2
22.1725
-101.006
true
casual
drinker
U1086
135085
2
1
1
22.1573
-100.984
false
social
drinker
no
U1089
135085
1
1
1
22.1626
-100.993
true
casual
drinker
U1090
135085
2
2
2
22.1585
-100.984
false
social
drinker
no
U1092
135085
0
0
0
22.1254
-100.948
false
abstemious
U1098
135085
1
2
1
22.1826
-100.963
false
social
drinker
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
10/19
Build and show a table comprising reviews for restaurant #135076.
userID
placeID
rating
food_rating
service_rating
latitude
longitude
smoker
drink_level
dress_
U1104
135085
2
2
1
22.149
-100.978
true
social
drinker
no
U1106
135085
2
2
2
18.9271
-99.1736
false
casual
drinker
U1108
135085
1
2
1
22.1435
-100.988
false
abstemious
U1109
135085
2
2
2
22.3033
-101.055
false
abstemious
U1113
135085
1
2
1
22.1373
-100.914
false
casual
drinker
U1116
135085
2
2
2
22.1565
-100.986
false
social
drinker
U1120
135085
0
0
0
22.1219
-100.904
false
abstemious
U1122
135085
2
2
1
22.1696
-100.992
?
abstemious
U1132
135085
2
2
2
22.15
-100.983
false
casual
drinker
U1134
135085
2
1
2
22.1497
-100.999
false
casual
drinker
no
U1135
135085
0
0
0
22.1704
-100.95
false
casual
drinker
U1137
135085
2
1
2
22.1448
-100.945
false
social
drinker
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
11/19
In [17]:
3.3 Analysis
3.3.1
Restaurant #135085, budget
Calculate the number of customers for restaurant #135085.
Calculate the mean rating for restaurant #135085.
In [16]:
Out[17]:
13
userID
placeID
rating
food_rating
service_rating
latitude
longitude
smoker
drink_level
dress_
U1005
135076
2
2
1
22.1835
-100.96
false
abstemious
no
U1010
135076
1
2
2
22.1909
-100.999
false
social
drinker
no
U1013
135076
1
1
0
22.1746
-100.994
false
abstemious
no
U1014
135076
1
2
1
23.7516
-99.1701
false
abstemious
U1019
135076
0
0
0
22.1534
-100.975
false
casual
drinker
no
U1053
135076
1
1
1
22.1758
-100.987
false
casual
drinker
U1056
135076
2
2
2
22.169
-100.974
false
social
drinker
U1058
135076
2
2
2
22.2058
-100.986
false
abstemious
U1075
135076
2
2
0
22.1676
-100.96
false
casual
drinker
U1081
135076
1
2
2
22.2077
-100.942
false
casual
drinker
U1085
135076
2
2
2
22.1968
-100.936
false
abstemious
no
U1099
135076
1
1
0
22.1849
-100.971
true
social
drinker
U1125
135076
1
1
1
22.192
-100.957
false
casual
drinker
Out[16]:
1.3333333333333333
data2 =
data_all.where(
'placeID'
, 135076
)
data2.num_rows
data2.show()
n =
data1.num_rows
avg1 =
mean(data1.column(
'rating'
))
avg1
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
12/19
Calculate the number of low budget customers for restaurant #135085.
Calculate the number of medium budget customers for restaurant #135085.
Calculate the number of high budget customers for restaurant #135085.
Calculate the number of customers with known budget type for restaurant #135085.
In [18]:
Calculate the mean rating by low budget customers for restaurant #135085.
Calculate the mean rating by medium budget customers for restaurant #135085.
Calculate the mean rating by high budget customers for restaurant #135085.
In [19]:
Calculate the weighted average rating by budget type for restaurant #135085, assuming budget
types for the population are equally distributed.
In [21]:
Out[18]:
11
Out[18]:
21
Out[18]:
1
Out[18]:
33
Out[19]:
1.0909090909090908
Out[19]:
1.4285714285714286
Out[19]:
2.0
Out[21]:
1.5064935064935066
n_low =
data1.where(
'budget'
,
'low'
).num_rows
n_low
n_medium =
data1.where(
'budget'
, 'medium'
).num_rows
n_medium
n_high =
data1.where(
'budget'
, 'high'
).num_rows
n_high
n =
n_low +
n_medium +
n_high
n
mean_low =
mean(data1.where(
'budget'
, 'low'
).column(
'rating'
))
mean_low
mean_medium =
mean(data1.where(
'budget'
, 'medium'
).column(
'rating'
))
mean_medium
mean_high =
mean(data1.where(
'budget'
, 'high'
).column(
'rating'
))
mean_high
avg1_budget_equal =
(mean_low +
mean_medium +
mean_high) /
3
avg1_budget_equal
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
13/19
Calculate the weighted average rating by budget type for restaurant #135085, assuming budget
types for the population are distributed as they are for restaurant #135085.
In [24]:
Calculate the weighted average rating by budget type for restaurant #135085, assuming budget
types for the population are distributed as in all the data.
In [ ]:
3.3.2
Restaurant #135085, marital status
Calculate the number of single customers for restaurant #135085.
Calculate the number of widow customers for restaurant #135085.
Calculate the number of married customers for restaurant #135085.
Calculate the number of customers with known marital status for restaurant #135085.
In [ ]:
Calculate the mean rating by single customers for restaurant #135085.
Calculate the mean rating by widow customers for restaurant #135085.
Calculate the mean rating by married customers for restaurant #135085.
Cell In[24], line 1
avg1_budget_sample x (n_low * mean_low + n_medium * mean_medium + n
_high * mean_high) / (n_low + n_medium + n_high)
^
SyntaxError: invalid syntax
avg1_budget_sample x (n_low *
mean_low +
n_medium *
mean_medium +
n_high avg1_budget_sample
n_all_low =
data_all.where(
'budget'
, 'low'
).num_rows
n_all_medium =
data_all.where(
'budget'
, 'medium'
).num_rows
n_all_high =
data_all.where(
'budget'
, 'high'
).num_rows
avg1_budget_sample =
(n_all_low *
mean_low +
n_all_medium *
mean_medium +
avg1_budget_sample
n_single =
data1.where(
'marital_status'
,
'single'
).num_rows
n_single
n_widow =
data1.where(
'marital_status'
,
'window'
).num_rows
n_widow
n_married =
data1.where(
'marital_status'
,
'married'
).num_rows
n_married
n =
n_single +
n_widow +
n_married
n
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
14/19
In [ ]:
Calculate the weighted average rating by marital status for restaurant #135085, assuming
marital statuses for the population are equally distributed.
In [ ]:
Calculate the weighted average rating by marital status for restaurant #135085, assuming
marital statuses for the population are distributed as they are for restaurant #135085.
In [ ]:
Calculate the weighted average rating by marital status for restaurant #135085, assuming
marital statuses for the population are distributed as in all the data.
In [ ]:
3.3.3
Restaurant #135076, budget
Calculate the number of customers for restaurant #135076.
Calculate the mean rating for restaurant #135076.
In [ ]:
Calculate the number of low budget customers for restaurant #135076.
Calculate the number of medium budget customers for restaurant #135076.
Calculate the number of high budget customers for restaurant #135076.
Calculate the number of customers with known budget type for restaurant #135076.
mean_single =
mean(data1.where(
'marital_status'
, 'single'
).column(
'rating
mean_single
mean_widow =
mean(data1.where(
'marital_status'
, 'widow'
).column(
'rating'
mean_widow
mean_married =
mean(data1.where(
'marital_status'
, 'married'
).column(
'rati
mean_married
avg1_marital_equal =
(mean_single +
mean_widow +
mean_married) /
3
avg1_marital_equal
avg1_marital_sample =
avg1_marital_sample =
(n_single *
mean_single +
n_w
avg1_marital_sample
avg1_marital_sample
n_all_single =
data_all.where(
'marital_status'
, 'single'
).num_rows
n_all_widow =
data_all.where(
'marital_status'
, 'widow'
).num_rows
n_all_married =
data_all.where(
'marital_status'
, 'married'
).num_rows
avg1_marital_all =
(n_all_single *
mean_single +
n_all_widow *
mean_widow
avg1_marital_all
n =
data2.num_rows
avg2 =
mean(data2.column(
'rating'
))
avg2
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
15/19
In [ ]:
Calculate the mean rating by low budget customers for restaurant #135076.
Calculate the mean rating by medium budget customers for restaurant #135076.
Calculate the mean rating by high budget customers for restaurant #135076
In [25]:
Calculate the weighted average rating by budget type for restaurant #135076, assuming budget
types for the population are equally distributed
In [ ]:
Calculate the weighted average rating by budget type for restaurant #135076, assuming budget
types for the population are distributed as they are for restaurant #135076
In [ ]:
Calculate the weighted average rating by budget type for restaurant #135076, assuming budget
types for the population are distributed as in all data.
Out[25]:
1.25
Out[25]:
1.2857142857142858
Out[25]:
1.0
n_low =
data2.where(
'budget'
,
'low'
).num_rows
n_low
n_medium =
data2.where(
'budget'
,
'medium'
).num_rows
n_medium
n_high =
data2.where(
'budget'
,
'high'
).num_rows
n_high
n =
n_low +
n_medium +
n_high
n
mean_low =
mean(data2.where(
'budget'
,
'low'
).column(
'rating'
))
mean_low
mean_medium =
mean(data2.where(
'budget'
,
'medium'
).column(
'rating'
))
mean_medium
mean_high =
mean(data2.where(
'budget'
,
'high'
).column(
'rating'
))
mean_high
avg2_budget_equal =
(mean_low +
mean_medium +
mean_high) /
3
avg2_budget_equal
avg2_budget_sample =
(n_low *
mean_low +
n_medium *
mean_medium +
n_high avg2_budget_sample
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
16/19
In [ ]:
3.3.4
Restaurant #135076, marital status
Calculate the number of single customers for restaurant #135076.
Calculate the number of widow customers for restaurant #135076.
Calculate the number of married customers for restaurant #135076.
Calculate the number of customers with known marital status for restaurant #135076.
In [29]:
Calculate the mean rating by single customers for restaurant #135076.
Calculate the mean rating by widow customers for restaurant #135076.
Calculate the mean rating by married customers for restaurant #135076.
In [26]:
Out[29]:
11
Out[29]:
1
Out[29]:
1
Out[29]:
13
Out[26]:
1.3636363636363635
Out[26]:
1.0
Out[26]:
1.0
n_all_low =
data_all.where(
'budget'
, 'low'
).num_rows
n_all_medium =
data_all.where(
'budget'
, 'medium'
).num_rows
n_all_high =
data_all.where(
'budget'
, 'high'
).num_rows
avg2_budget_all =
(n_all_low *
mean_low +
n_all_medium *
mean_medium +
n_
avg1_budget_all
n_single =
data2.where(
'marital_status'
,
'single'
).num_rows
n_single
n_widow =
data2.where(
'marital_status'
,
'widow'
).num_rows
n_widow
n_married =
data2.where(
'marital_status'
,
'married'
).num_rows
n_married
n =
n_single +
n_widow +
n_married
n
mean_single =
mean(data2.where(
'marital_status'
, 'single'
).column(
'rating
mean_single
mean_widow =
mean(data2.where(
'marital_status'
, 'widow'
).column(
'rating'
mean_widow
mean_married =
mean(data2.where(
'marital_status'
, 'married'
).column(
'rati
mean_married
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
17/19
Calculate the weighted average rating by marital status for restaurant #135076, assuming
marital status for the population are equally distributed.
In [27]:
Calculate the weighted average rating by marital status for restaurant #135076, assuming
marital status for the population are distributed as they are for restaurant #135076.
In [31]:
Calculate the weighted average rating by marital status for restaurant #135076, assuming
marital status for the population are distributed as in all the data.
In [32]:
3.3.5 Comparison
Build a table to compare rating averages calculated various ways like this:
One column for calculation method name + one column for distribution assumption + two
columns for restaurant ratings
Seven rows for calculation methods
First row is mean
Second row is weighted average by budget type, assuming population distribution is
equal
Out[27]:
1.1212121212121211
Out[31]:
1.3076923076923077
-----------------------------------------------------------------------
----
AttributeError Traceback (most recent call l
ast)
Cell In[32], line 1
----> 1 n_all_single = data
.
all
.
where(
'marital_status'
, 'single'
)
.
num_r
ows
2
n_all_widow = data
.
all
.
where(
'marital_status'
, 'widow'
)
.
num_row
s
3
n_all_married = data
.
all
.
where(
'marital_status'
, 'high'
)
.
num_ro
ws
AttributeError
: 'Table' object has no attribute 'all'
avg2_marital_equal =
(mean_single +
mean_widow +
mean_married) /
3
avg2_marital_equal
avg2_marital_sample =
(n_single *
mean_single +
n_widow *
mean_widow +
n_
avg2_marital_sample
n_all_single =
data_all.where(
'marital_status'
, 'single'
).num_rows
n_all_widow =
data_all.where(
'marital_status'
, 'widow'
).num_rows
n_all_married =
data_all.where(
'marital_status'
, 'high'
).num_rows
avg2_budget_all =
(n_all_single *
mean_single +
n_all_widow *
mean_widow avg2_budget_all
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
18/19
Third row is weighted average by marital status, assuming population distribution is
equal
Fourth row is weighted average by budget type, assuming population distribution is as
in restaurant sample
Fifth row is weighted average by marital status, assuming population distribution is as
in restaurant sample
Sixth row is weighted average by budget type, assuming population distribution is as in
all the data
Seventh row is weighted average by marital status, assuming population distribution is
In [ ]:
3.4 Quiz
The dataset comprises ____
observations.
The dataset comprises ____
variables.
There are ____
possible rating levels.
The mean rating for restaurant #135085 is ____
.
The weighted average rating by budget type for restaurant #135085 is ____
, assuming
budget types for the population are equally distributed.
The weighted average rating by budget type for restaurant #135085 is ____
, assuming
budget types for the population are distributed as they are for restaurant #135085.
The weighted average rating by budget type for restaurant #135085 is ____
, assuming
budget types for the population are distributed as in all the data.
The weighted average rating by marital status for restaurant #135085 is ____
, assuming
marital statuses for the population are equally distributed.
The weighted average rating by marital status for restaurant #135085 is ____
, assuming
marital statuses for the population are distributed as they are for restaurant #135085.
The weighted average rating by marital status for restaurant #135085 is ____
, assuming
marital statuses for the population are distributed as in all the data.
There are ____
reviews for restaurant #135076.
The weighted average rating by budget type for restaurant #135076 is ____
, assuming
budget types for the population are equally distributed.
The weighted average rating by budget type for restaurant #135076 is ____
, assuming
budget types for the population are distributed as they are for restaurant #135076.
The weighted average rating by budget type for restaurant #135076 is ____
, assuming
budget types for the population are distributed as in all the data.
The weighted average rating by marital status for restaurant #135076 is ____
, assuming
marital statuses for the population are equally distributed.
The weighted average rating by marital status for restaurant #135076 is ____
, assuming
marital statuses for the population are distributed as they are for restaurant #135076.
The weighted average rating by marital status for restaurant #135076 is ____
, assuming
marital statuses for the population are distributed as in all the data.
Comparative analysis shows that mean or weighted average rating of restaurant #135085 is
higher than that of restaurant #135076 ____
out of 7 times.
Table().with_columns(
'Method'
, make_array(
'mean'
, 'weighted average by bu
'Distribution Assumption'
, make_array(
''
, 'equal'
, 'Restaurant #135085'
, make_array(avg1, avg1_budget_e
'Restaurant #135076'
, make_array(avg2, avg2_budget_e
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2/5/24, 6:32 PM
UGBA88 Lab CX assignment-Copy2 - Jupyter Notebook
https://ugba88.haas.berkeley.edu/user/darrinfan/notebooks/my-work/UGBA88 Lab CX assignment-Copy2.ipynb
19/19
Restaurant #135076 claims that its average rating is higher than restaurant #135085's. This
claim is ____.
true when weighted assuming distribution of marital statuses is as in the dataset of all
reviews
false when weighted assuming distribution of marital statuses is as in the dataset of all
reviews
true regardless of weight assumption
false regardless of weight assumption
The real proportion of low budget customers in the population of customers that do not
write reviews is ____.
about 10%
about 33%
about 50%
about the same as the proportion of low budget customers in the sample of restaurant
#135076's customers
unknown
Document revised September 1, 2023
Copyright (c) Huntsinger Associates, LLC
Related Documents
Recommended textbooks for you

Principles of Economics 2e
Economics
ISBN:9781947172364
Author:Steven A. Greenlaw; David Shapiro
Publisher:OpenStax

Managerial Economics: A Problem Solving Approach
Economics
ISBN:9781337106665
Author:Luke M. Froeb, Brian T. McCann, Michael R. Ward, Mike Shor
Publisher:Cengage Learning



Managerial Economics: Applications, Strategies an...
Economics
ISBN:9781305506381
Author:James R. McGuigan, R. Charles Moyer, Frederick H.deB. Harris
Publisher:Cengage Learning

Microeconomics: Principles & Policy
Economics
ISBN:9781337794992
Author:William J. Baumol, Alan S. Blinder, John L. Solow
Publisher:Cengage Learning
Recommended textbooks for you
- Principles of Economics 2eEconomicsISBN:9781947172364Author:Steven A. Greenlaw; David ShapiroPublisher:OpenStaxManagerial Economics: A Problem Solving ApproachEconomicsISBN:9781337106665Author:Luke M. Froeb, Brian T. McCann, Michael R. Ward, Mike ShorPublisher:Cengage Learning
- Managerial Economics: Applications, Strategies an...EconomicsISBN:9781305506381Author:James R. McGuigan, R. Charles Moyer, Frederick H.deB. HarrisPublisher:Cengage LearningMicroeconomics: Principles & PolicyEconomicsISBN:9781337794992Author:William J. Baumol, Alan S. Blinder, John L. SolowPublisher:Cengage Learning

Principles of Economics 2e
Economics
ISBN:9781947172364
Author:Steven A. Greenlaw; David Shapiro
Publisher:OpenStax

Managerial Economics: A Problem Solving Approach
Economics
ISBN:9781337106665
Author:Luke M. Froeb, Brian T. McCann, Michael R. Ward, Mike Shor
Publisher:Cengage Learning



Managerial Economics: Applications, Strategies an...
Economics
ISBN:9781305506381
Author:James R. McGuigan, R. Charles Moyer, Frederick H.deB. Harris
Publisher:Cengage Learning

Microeconomics: Principles & Policy
Economics
ISBN:9781337794992
Author:William J. Baumol, Alan S. Blinder, John L. Solow
Publisher:Cengage Learning