Created
June 8, 2022 11:42
-
-
Save nsakki55/4827e1568d0db3b91836c6b9fe2a153e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "af0bc173", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from time import gmtime, strftime\n", | |
"\n", | |
"from sagemaker.sklearn.estimator import SKLearn\n", | |
"\n", | |
"job_name = \"custom-library-script-ctr-prediction-\" + strftime(\"%Y%m%d-%H-%M-%S\", gmtime())\n", | |
"\n", | |
"hyperparameters = {\"alpha\": 0.0002, \"eta0\": 3.0}\n", | |
"enable_local_mode_training=False\n", | |
"\n", | |
"if enable_local_mode_training:\n", | |
" train_instance_type = \"local\"\n", | |
" inputs = {\"train\": f\"file://{train_file}\", \"test\": f\"file://{test_file}\"}\n", | |
"else:\n", | |
" train_instance_type = \"ml.m5.large\"\n", | |
" inputs = {\"train\": s3_train_data, \"test\": s3_test_data}\n", | |
"\n", | |
"estimator_parameters = {\n", | |
" \"entry_point\": \"my_library_script_mode.py\",\n", | |
" \"source_dir\": \"custom_script\",\n", | |
" \"dependencies\": [\"my_custom_library\"],\n", | |
" \"framework_version\": \"0.23-1\",\n", | |
" \"py_version\": \"py3\",\n", | |
" \"instance_type\": train_instance_type,\n", | |
" \"instance_count\": 1,\n", | |
" \"hyperparameters\": hyperparameters,\n", | |
" \"output_path\": output_location,\n", | |
" \"role\": role,\n", | |
" \"base_job_name\": job_name,\n", | |
"}\n", | |
"\n", | |
"estimator = SKLearn(**estimator_parameters)\n", | |
"estimator.fit(inputs)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.8.6" | |
}, | |
"varInspector": { | |
"cols": { | |
"lenName": 16, | |
"lenType": 16, | |
"lenVar": 40 | |
}, | |
"kernels_config": { | |
"python": { | |
"delete_cmd_postfix": "", | |
"delete_cmd_prefix": "del ", | |
"library": "var_list.py", | |
"varRefreshCmd": "print(var_dic_list())" | |
}, | |
"r": { | |
"delete_cmd_postfix": ") ", | |
"delete_cmd_prefix": "rm(", | |
"library": "var_list.r", | |
"varRefreshCmd": "cat(var_dic_list()) " | |
} | |
}, | |
"types_to_exclude": [ | |
"module", | |
"function", | |
"builtin_function_or_method", | |
"instance", | |
"_Feature" | |
], | |
"window_display": false | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment