|
292 | 292 | "\n", |
293 | 293 | "The scripts are:\n", |
294 | 294 | "\n", |
295 | | - "* `train_local.sh`: Run this with the name of the image and it will run training on the local tree. You'll want to modify the directory `test_dir/input/data/...` to be set up with the correct channels and data for your algorithm. Also, you'll want to modify the file `input/config/hyperparameters.json` to have the hyperparameter settings that you want to test (as strings).\n", |
296 | | - "* `serve_local.sh`: Run this with the name of the image once you've trained the model and it should serve the model. It will run and wait for requests. Simply use the keyboard interrupt to stop it.\n", |
| 295 | + "* `train_local.sh`: Run this with the name of the image and it will run training on the local tree. For example, you can run `$ ./train_local.sh sagemaker-decision-trees`. It will generate a model under the `/test_dir/model` directory. You'll want to modify the directory `test_dir/input/data/...` to be set up with the correct channels and data for your algorithm. Also, you'll want to modify the file `input/config/hyperparameters.json` to have the hyperparameter settings that you want to test (as strings).\n", |
| 296 | + "* `serve_local.sh`: Run this with the name of the image once you've trained the model and it should serve the model. For example, you can run `$ ./serve_local.sh sagemaker-decision-trees`. It will run and wait for requests. Simply use the keyboard interrupt to stop it.\n", |
297 | 297 | "* `predict.sh`: Run this with the name of a payload file and (optionally) the HTTP content type you want. The content type will default to `text/csv`. For example, you can run `$ ./predict.sh payload.csv text/csv`.\n", |
298 | 298 | "\n", |
299 | 299 | "The directories as shipped are set up to test the decision trees sample algorithm presented here." |
|
459 | 459 | "outputs": [], |
460 | 460 | "source": [ |
461 | 461 | "shape=pd.read_csv(\"data/iris.csv\", header=None)\n", |
462 | | - "\n", |
| 462 | + "shape.sample(3)" |
| 463 | + ] |
| 464 | + }, |
| 465 | + { |
| 466 | + "cell_type": "code", |
| 467 | + "execution_count": null, |
| 468 | + "metadata": {}, |
| 469 | + "outputs": [], |
| 470 | + "source": [ |
| 471 | + "# drop the label column in the training set\n", |
| 472 | + "shape.drop(shape.columns[[0]],axis=1,inplace=True)\n", |
| 473 | + "shape.sample(3)" |
| 474 | + ] |
| 475 | + }, |
| 476 | + { |
| 477 | + "cell_type": "code", |
| 478 | + "execution_count": null, |
| 479 | + "metadata": {}, |
| 480 | + "outputs": [], |
| 481 | + "source": [ |
463 | 482 | "import itertools\n", |
464 | 483 | "\n", |
465 | 484 | "a = [50*i for i in range(3)]\n", |
|
533 | 552 | "\n", |
534 | 553 | "transformer = tree.transformer(instance_count=1,\n", |
535 | 554 | " instance_type='ml.m4.xlarge',\n", |
536 | | - " output_path=output_path)" |
| 555 | + " output_path=output_path,\n", |
| 556 | + " assemble_with='Line',\n", |
| 557 | + " accept='text/csv')" |
537 | 558 | ] |
538 | 559 | }, |
539 | 560 | { |
|
544 | 565 | "\n", |
545 | 566 | "* The __data_location__ which is the location of input data\n", |
546 | 567 | "* The __content_type__ which is the content type set when making HTTP request to container to get prediction\n", |
547 | | - "* The __split_type__ which is the delimiter used for splitting input data " |
| 568 | + "* The __split_type__ which is the delimiter used for splitting input data \n", |
| 569 | + "* The __input_filter__ which indicates the first column (ID) of the input will be dropped before making HTTP request to container" |
548 | 570 | ] |
549 | 571 | }, |
550 | 572 | { |
|
553 | 575 | "metadata": {}, |
554 | 576 | "outputs": [], |
555 | 577 | "source": [ |
556 | | - "transformer.transform(data_location, content_type='text/csv', split_type='Line')\n", |
| 578 | + "transformer.transform(data_location, content_type='text/csv', split_type='Line', input_filter='$[1:]')\n", |
557 | 579 | "transformer.wait()" |
558 | 580 | ] |
559 | 581 | }, |
|
0 commit comments