Skip to content

Commit 57efe0a

Browse files
committed
fix: test_data referenced before assignment
1 parent b82f182 commit 57efe0a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

project-bikesharing/Predicting_bike_sharing_data.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,20 @@
128128
},
129129
"outputs": [],
130130
"source": [
131+
"# Save data for approximately the last 21 days \n",
132+
"test_data = data[-21*24:]\n",
133+
"\n",
134+
"# Now remove the test data from the data set \n",
135+
"data = data[:-21*24]\n",
136+
"\n",
131137
"quant_features = ['casual', 'registered', 'cnt', 'temp', 'hum', 'windspeed']\n",
132138
"# Store scalings in a dictionary so we can convert back later\n",
133139
"scaled_features = {}\n",
134140
"for each in quant_features:\n",
135141
" mean, std = data[each].mean(), data[each].std()\n",
136142
" scaled_features[each] = [mean, std]\n",
137143
" data.loc[:, each] = (data[each] - mean)/std\n",
138-
" test_data.loc[:, each] = (test_data[each] - mean)/std\n"
144+
" test_data.loc[:, each] = (test_data[each] - mean)/std"
139145
]
140146
},
141147
{
@@ -155,12 +161,6 @@
155161
},
156162
"outputs": [],
157163
"source": [
158-
"# Save data for approximately the last 21 days \n",
159-
"test_data = data[-21*24:]\n",
160-
"\n",
161-
"# Now remove the test data from the data set \n",
162-
"data = data[:-21*24]\n",
163-
"\n",
164164
"# Separate the data into features and targets\n",
165165
"target_fields = ['cnt', 'casual', 'registered']\n",
166166
"features, targets = data.drop(target_fields, axis=1), data[target_fields]\n",
@@ -459,4 +459,4 @@
459459
},
460460
"nbformat": 4,
461461
"nbformat_minor": 2
462-
}
462+
}

0 commit comments

Comments
 (0)