|
163 | 163 | "# List of price areas\n",
|
164 | 164 | "price_areas = [\"se1\", \"se2\", \"se3\", \"se4\"]\n",
|
165 | 165 | "\n",
|
| 166 | + "# Retrieving transformation functions\n", |
| 167 | + "min_max_scaler = fs.get_transformation_function(name=\"min_max_scaler\")\n", |
| 168 | + "label_encoder = fs.get_transformation_function(name='label_encoder')\n", |
| 169 | + "\n", |
166 | 170 | "# Mapping features to their respective transformation functions\n",
|
167 |
| - "mapping_transformers = {}\n", |
| 171 | + "transformation_functions = []\n", |
168 | 172 | "\n",
|
169 | 173 | "# Iterate through each price area and map features to their transformation functions\n",
|
170 | 174 | "for area in price_areas:\n",
|
171 |
| - " mapping_transformers[f\"price_{area}\"] = fs.get_transformation_function(name=\"min_max_scaler\")\n", |
172 |
| - " mapping_transformers[f\"mean_temp_per_day_{area}\"] = fs.get_transformation_function(name=\"min_max_scaler\")\n", |
173 |
| - " mapping_transformers[f\"mean_wind_speed_{area}\"] = fs.get_transformation_function(name=\"min_max_scaler\")\n", |
174 |
| - " mapping_transformers[f\"precipitaton_amount_{area}\"] = fs.get_transformation_function(name=\"min_max_scaler\")\n", |
175 |
| - " mapping_transformers[f\"total_sunshine_time_{area}\"] = fs.get_transformation_function(name=\"min_max_scaler\")\n", |
176 |
| - " mapping_transformers[f\"mean_cloud_perc_{area}\"] = fs.get_transformation_function(name=\"min_max_scaler\") \n", |
177 |
| - " mapping_transformers[f\"precipitaton_type_{area}\"] = fs.get_transformation_function(name='label_encoder')\n", |
| 175 | + " transformation_functions.append(min_max_scaler(f\"price_{area}\"))\n", |
| 176 | + " transformation_functions.append(min_max_scaler(f\"mean_temp_per_day_{area}\"))\n", |
| 177 | + " transformation_functions.append(min_max_scaler(f\"mean_wind_speed_{area}\"))\n", |
| 178 | + " transformation_functions.append(min_max_scaler(f\"precipitaton_amount_{area}\"))\n", |
| 179 | + " transformation_functions.append(min_max_scaler(f\"total_sunshine_time_{area}\"))\n", |
| 180 | + " transformation_functions.append(min_max_scaler(f\"mean_cloud_perc_{area}\"))\n", |
| 181 | + " transformation_functions.append(label_encoder(f\"precipitaton_type_{area}\"))\n", |
178 | 182 | "\n",
|
179 | 183 | "# Additional transformation for 'type_of_day'\n",
|
180 |
| - "mapping_transformers[\"type_of_day\"] = fs.get_transformation_function(name='label_encoder')" |
| 184 | + "transformation_functions.append(label_encoder(\"type_of_day\"))" |
181 | 185 | ]
|
182 | 186 | },
|
183 | 187 | {
|
|
215 | 219 | " name='electricity_feature_view',\n",
|
216 | 220 | " version=1,\n",
|
217 | 221 | " labels=[], # you will define our 'y' later manualy\n",
|
218 |
| - " transformation_functions=mapping_transformers,\n", |
| 222 | + " transformation_functions=transformation_functions,\n", |
219 | 223 | " query=selected_features,\n",
|
220 | 224 | ")"
|
221 | 225 | ]
|
|
304 | 308 | "outputs": [],
|
305 | 309 | "source": [
|
306 | 310 | "# Define 'y_train', 'y_val' and 'y_test'\n",
|
307 |
| - "y_train = X_train[[\"price_se1\", \"price_se2\", \"price_se3\", \"price_se4\"]]\n", |
308 |
| - "y_val = X_val[[\"price_se1\", \"price_se2\", \"price_se3\", \"price_se4\"]]\n", |
309 |
| - "y_test = X_test[[\"price_se1\", \"price_se2\", \"price_se3\", \"price_se4\"]]" |
| 311 | + "y_train = X_train[[\"min_max_scaler_price_se1_\", \"min_max_scaler_price_se2_\", \"min_max_scaler_price_se3_\", \"min_max_scaler_price_se4_\"]]\n", |
| 312 | + "y_val = X_val[[\"min_max_scaler_price_se1_\", \"min_max_scaler_price_se2_\", \"min_max_scaler_price_se3_\", \"min_max_scaler_price_se4_\"]]\n", |
| 313 | + "y_test = X_test[[\"min_max_scaler_price_se1_\", \"min_max_scaler_price_se2_\", \"min_max_scaler_price_se3_\", \"min_max_scaler_price_se4_\"]]" |
310 | 314 | ]
|
311 | 315 | },
|
312 | 316 | {
|
|
494 | 498 | " input_width=4, \n",
|
495 | 499 | " label_width=4, \n",
|
496 | 500 | " shift=1, \n",
|
497 |
| - " label_columns=[\"price_se1\", \"price_se2\", \"price_se3\", \"price_se4\"],\n", |
| 501 | + " label_columns=[\"min_max_scaler_price_se1_\", \"min_max_scaler_price_se2_\", \"min_max_scaler_price_se3_\", \"min_max_scaler_price_se4_\"],\n", |
498 | 502 | ")\n",
|
499 | 503 | "\n",
|
500 | 504 | "# Displaying the WindowGenerator instance\n",
|
|
710 | 714 | "source": [
|
711 | 715 | "# Plotting the time series data for the 'price_se4' column\n",
|
712 | 716 | "n_step_window.plot(\n",
|
713 |
| - " plot_col=\"price_se4\", \n", |
| 717 | + " plot_col=\"min_max_scaler_price_se4_\", \n", |
714 | 718 | " max_subplots=3, \n",
|
715 | 719 | " model=model.predict,\n",
|
716 | 720 | ")"
|
|
0 commit comments