You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_hint='First find the vertical level corresponding to -74 dropoff longitude. Then read off the horizontal values you are switching between. Use the white contour lines to orient yourself on what values you are near. You can round to the nearest integer rather than stressing about the exact cost to the nearest penny'
54
-
_solution='About \$15. The price decreases from slightly more than \$24 to slightly more than \$9.'
52
+
_hint='First find the vertical level corresponding to -74 dropoff longitude. Then read off the horizontal values you are switching between. Use the contour lines to orient yourself on what values you are near. You can round to the nearest integer rather than stressing about the exact cost to the nearest penny'
53
+
_solution='About 6. The price decreases from slightly less than 15 to slightly less than 9.'
55
54
defcheck(self, savings):
56
55
iftype(savings) ==str:
57
56
savings=Decimal(dollars.strip('$'))
58
-
assert ((savings>13) and (savings<17)), "Your answer should be about 15. Not {}".format(savings)
57
+
assert ((savings>4) and (savings<8)), "Your answer should be about 6. Not {}".format(savings)
59
58
59
+
# 4
60
60
classMakePDPWithAbsFeatures(CodingProblem):
61
-
_var='pdp_dist'
62
-
_hint='use the abs function when creating the abs_lat_change and abs_lon_change features. You don\'t need to change anything else.'
61
+
_var='disp'
62
+
_hint='Use the abs function when creating the abs_lat_change and abs_lon_change features. You don\'t need to change anything else.'
63
63
_solution= \
64
64
"""
65
-
The biggest difference is that the partial dependence plot became much smaller. The the lowest vertical value is about $15 below the highest vertical value in the top chart, whereas this difference is only about $3 in the chart you just created. In other words, once you control for absolute distance traveled, the pickup_longitude has only a very small impact on predictions.
65
+
The difference is that the partial dependence plot became smaller. Both plots have a lowest vertical value of 8.5. But, the highest vertical value in the top chart is around 10.7, and the highest vertical value in the bottom chart is below 9.1. In other words, once you control for absolute distance traveled, the pickup_longitude has a smaller impact on predictions.
_solution="No. This doesn't guarantee `feat_a` is more important. For example, `feat_a` could have a big effect in the cases where it varies, but could have a single value 99\% of the time. In that case, permuting `feat_a` wouldn't matter much, since most values would be unchanged."
80
99
100
+
# 6
81
101
classDesignDatasetUShapedPdp(CodingProblem):
82
-
_var='pdp_dist'
102
+
_var='disp'
83
103
_hint="Consider explicitly using terms that include mathematical expressions like `(X1 < -1)`"
84
104
_solution=CS(
85
105
"""
@@ -89,22 +109,26 @@ class DesignDatasetUShapedPdp(CodingProblem):
_hint="You need for X1 to affect the prediction in order to have it affect permutation importance. But the average effect needs to be 0 to satisfy the PDP requirement. Achieve this by creating an interaction, so the effect of X1 depends on the value of X2 and vice-versa."
109
133
_solution=CS(
110
134
"""
@@ -117,9 +141,10 @@ class DesignFlatPDPWithHighImportance(CodingProblem):
117
141
# Aside from these lines, use the code provided
118
142
""")
119
143
120
-
defcheck(self, importance, pdpResult):
144
+
defcheck(self, importance, disp):
121
145
X1_imp=importance.feature_importances_[0]
122
-
pdpRange=max(pdpResult.pdp) -min(pdpResult.pdp)
146
+
pdpResult=disp.pd_results[0]['average'][0]
147
+
pdpRange=max(pdpResult) -min(pdpResult)
123
148
assert (X1_imp>0.5), ("Tested that X1 has an importance > 0.5. "
124
149
"Actual importance was {}").format(X1_imp)
125
150
assert (pdpRange<0.5), ("Tested that the highest point on the Partial "
"Create a 2D plot for the features `pickup_longitude` and `dropoff_longitude`. Plot it appropriately?\n",
148
+
"Create a 2D plot for the features `pickup_longitude` and `dropoff_longitude`.\n",
150
149
"\n",
151
150
"What do you expect it to look like?"
152
151
]
@@ -157,6 +156,8 @@
157
156
"metadata": {},
158
157
"outputs": [],
159
158
"source": [
159
+
"fig, ax = plt.subplots(figsize=(8, 6))\n",
160
+
"\n",
160
161
"# Add your code here\n",
161
162
"____"
162
163
]
@@ -183,7 +184,7 @@
183
184
"metadata": {},
184
185
"source": [
185
186
"## Question 3\n",
186
-
"Consider a ride starting at longitude -73.92 and ending at longitude -74. Using the graph from the last question, estimate how much money the rider would have saved if they'd started the ride at longitude -73.98 instead?"
187
+
"Consider a ride starting at longitude -73.955 and ending at longitude -74. Using the graph from the last question, estimate how much money the rider would have saved if they'd started the ride at longitude -73.98 instead."
187
188
]
188
189
},
189
190
{
@@ -237,13 +238,10 @@
237
238
"source": [
238
239
"# This is the PDP for pickup_longitude without the absolute difference features. Included here to help compare it to the new PDP you create\n",
"A few items are worth pointing out as you interpret this plot\n",
117
-
"- The y axis is interpreted as **change in the prediction** from what it would be predicted at the baseline or leftmost value.\n",
118
-
"- A blue shaded area indicates level of confidence\n",
112
+
"The y axis is interpreted as **change in the prediction** from what it would be predicted at the baseline or leftmost value.\n",
119
113
"\n",
120
114
"From this particular graph, we see that scoring a goal substantially increases your chances of winning \"Man of The Match.\" But extra goals beyond that appear to have little impact on predictions.\n",
0 commit comments