|
15 | 15 | "source": [ |
16 | 16 | "# Tutorial: Train a classification model with automated machine learning\n", |
17 | 17 | "\n", |
18 | | - "In this tutorial, you'll learn how to generate a machine learning model using automated machine learning (automated ML). Azure Machine Learning can perform data preprocessing, algorithm selection and hyperparameter selection in an automated way for you. The final model can then be deployed following the workflow in the [Deploy a model](02.deploy-models.ipynb) tutorial.\n", |
| 18 | + "In this tutorial, you'll learn how to generate a machine learning model using automated machine learning (automated ML). Azure Machine Learning can perform algorithm selection and hyperparameter selection in an automated way for you. The final model can then be deployed following the workflow in the [Deploy a model](02.deploy-models.ipynb) tutorial.\n", |
19 | 19 | "\n", |
20 | 20 | "[flow diagram](./imgs/flow2.png)\n", |
21 | 21 | "\n", |
|
133 | 133 | "digits = datasets.load_digits()\n", |
134 | 134 | "\n", |
135 | 135 | "# Exclude the first 100 rows from training so that they can be used for test.\n", |
136 | | - "X_digits = digits.data[100:,:]\n", |
137 | | - "y_digits = digits.target[100:]" |
| 136 | + "X_train = digits.data[100:,:]\n", |
| 137 | + "y_train = digits.target[100:]" |
138 | 138 | ] |
139 | 139 | }, |
140 | 140 | { |
|
155 | 155 | "count = 0\n", |
156 | 156 | "sample_size = 30\n", |
157 | 157 | "plt.figure(figsize = (16, 6))\n", |
158 | | - "for i in np.random.permutation(X_digits.shape[0])[:sample_size]:\n", |
| 158 | + "for i in np.random.permutation(X_train.shape[0])[:sample_size]:\n", |
159 | 159 | " count = count + 1\n", |
160 | 160 | " plt.subplot(1, sample_size, count)\n", |
161 | 161 | " plt.axhline('')\n", |
162 | 162 | " plt.axvline('')\n", |
163 | | - " plt.text(x = 2, y = -2, s = y_digits[i], fontsize = 18)\n", |
164 | | - " plt.imshow(X_digits[i].reshape(8, 8), cmap = plt.cm.Greys)\n", |
| 163 | + " plt.text(x = 2, y = -2, s = y_train[i], fontsize = 18)\n", |
| 164 | + " plt.imshow(X_train[i].reshape(8, 8), cmap = plt.cm.Greys)\n", |
165 | 165 | "plt.show()" |
166 | 166 | ] |
167 | 167 | }, |
|
187 | 187 | "|**max_time_sec**|12,000|Time limit in seconds for each iteration|\n", |
188 | 188 | "|**iterations**|20|Number of iterations. In each iteration, the model trains with the data with a specific pipeline|\n", |
189 | 189 | "|**n_cross_validations**|3|Number of cross validation splits|\n", |
190 | | - "|**preprocess**|False| *True/False* Enables experiment to perform preprocessing on the input. Preprocessing handles *missing data*, and performs some common *feature extraction*|\n", |
191 | | - "|**exit_score**|0.995|*double* value indicating the target for *primary_metric*. Once the target is surpassed the run terminates|\n", |
| 190 | + "|**exit_score**|0.9985|*double* value indicating the target for *primary_metric*. Once the target is surpassed the run terminates|\n", |
192 | 191 | "|**blacklist_algos**|['kNN','LinearSVM']|*Array* of *strings* indicating algorithms to ignore.\n" |
193 | 192 | ] |
194 | 193 | }, |
|
210 | 209 | " max_time_sec = 12000,\n", |
211 | 210 | " iterations = 20,\n", |
212 | 211 | " n_cross_validations = 3,\n", |
213 | | - " preprocess = False,\n", |
214 | 212 | " exit_score = 0.9985,\n", |
215 | 213 | " blacklist_algos = ['kNN','LinearSVM'],\n", |
216 | | - " X = X_digits,\n", |
217 | | - " y = y_digits,\n", |
| 214 | + " X = X_train,\n", |
| 215 | + " y = y_train,\n", |
218 | 216 | " path=project_folder)" |
219 | 217 | ] |
220 | 218 | }, |
|
351 | 349 | "source": [ |
352 | 350 | "# find 30 random samples from test set\n", |
353 | 351 | "n = 30\n", |
354 | | - "sample_indices = np.random.permutation(X_digits.shape[0])[0:n]\n", |
355 | | - "test_samples = X_digits[sample_indices]\n", |
| 352 | + "X_test = digits.data[:100, :]\n", |
| 353 | + "y_test = digits.target[:100]\n", |
| 354 | + "sample_indices = np.random.permutation(X_test.shape[0])[0:n]\n", |
| 355 | + "test_samples = X_test[sample_indices]\n", |
356 | 356 | "\n", |
357 | 357 | "\n", |
358 | 358 | "# predict using the model\n", |
|
368 | 368 | " plt.axvline('')\n", |
369 | 369 | " \n", |
370 | 370 | " # use different color for misclassified sample\n", |
371 | | - " font_color = 'red' if y_digits[s] != result[i] else 'black'\n", |
372 | | - " clr_map = plt.cm.gray if y_digits[s] != result[i] else plt.cm.Greys\n", |
| 371 | + " font_color = 'red' if y_test[s] != result[i] else 'black'\n", |
| 372 | + " clr_map = plt.cm.gray if y_test[s] != result[i] else plt.cm.Greys\n", |
373 | 373 | " \n", |
374 | 374 | " plt.text(x = 2, y = -2, s = result[i], fontsize = 18, color = font_color)\n", |
375 | | - " plt.imshow(X_digits[s].reshape(8, 8), cmap = clr_map)\n", |
| 375 | + " plt.imshow(X_test[s].reshape(8, 8), cmap = clr_map)\n", |
376 | 376 | " \n", |
377 | 377 | " i = i + 1\n", |
378 | 378 | "plt.show()" |
|
393 | 393 | "> * Review training results\n", |
394 | 394 | "> * Register the best model\n", |
395 | 395 | "\n", |
396 | | - "Learn more about [how to configure settings for automatic training]() or [how to use automatic training on a remote resource]()." |
| 396 | + "Learn more about [how to configure settings for automatic training](https://aka.ms/aml-how-configure-auto) or [how to use automatic training on a remote resource](https://aka.ms/aml-how-to-auto-remote)." |
397 | 397 | ] |
398 | 398 | } |
399 | 399 | ], |
|
0 commit comments