├── README.md ├── .gitignore ├── LICENSE └── Tutorial - 1 Sagemaker SKlearn Custom Script.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # MLAWS-SagemakerProject -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Tutorial - 1 Sagemaker SKlearn Custom Script.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": { 7 | "tags": [] 8 | }, 9 | "source": [ 10 | "### Mobile Price Classification using SKLearn Custom Script in Sagemaker" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 1, 23 | "metadata": { 24 | "tags": [] 25 | }, 26 | "outputs": [ 27 | { 28 | "name": "stdout", 29 | "output_type": "stream", 30 | "text": [ 31 | "Using bucket mobbucketsagemaker\n" 32 | ] 33 | } 34 | ], 35 | "source": [ 36 | "import sagemaker\n", 37 | "from sklearn.model_selection import train_test_split\n", 38 | "import boto3\n", 39 | "import pandas as pd\n", 40 | "\n", 41 | "sm_boto3 = boto3.client(\"sagemaker\")\n", 42 | "sess = sagemaker.Session()\n", 43 | "region = sess.boto_session.region_name\n", 44 | "bucket = 'mobbucketsagemaker' # Mention the created S3 bucket name here\n", 45 | "print(\"Using bucket \" + bucket)" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 2, 51 | "metadata": { 52 | "tags": [] 53 | }, 54 | "outputs": [], 55 | "source": [ 56 | "df = pd.read_csv(\"mob_price_classification_train.csv\")" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 3, 62 | "metadata": { 63 | "tags": [] 64 | }, 65 | "outputs": [ 66 | { 67 | "data": { 68 | "text/html": [ 69 | "
\n", 70 | "\n", 83 | "\n", 84 | " \n", 85 | " \n", 86 | " \n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " \n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | " \n", 101 | " \n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | "
battery_powerblueclock_speeddual_simfcfour_gint_memorym_depmobile_wtn_cores...px_heightpx_widthramsc_hsc_wtalk_timethree_gtouch_screenwifiprice_range
084202.201070.61882...20756254997190011
1102110.5101530.71363...9051988263117371102
256310.5121410.91455...12631716260311291102
361512.5000100.81316...121617862769168111002
4182111.20131440.61412...12081212141182151101
\n", 233 | "

5 rows × 21 columns

\n", 234 | "
" 235 | ], 236 | "text/plain": [ 237 | " battery_power blue clock_speed dual_sim fc four_g int_memory m_dep \\\n", 238 | "0 842 0 2.2 0 1 0 7 0.6 \n", 239 | "1 1021 1 0.5 1 0 1 53 0.7 \n", 240 | "2 563 1 0.5 1 2 1 41 0.9 \n", 241 | "3 615 1 2.5 0 0 0 10 0.8 \n", 242 | "4 1821 1 1.2 0 13 1 44 0.6 \n", 243 | "\n", 244 | " mobile_wt n_cores ... px_height px_width ram sc_h sc_w talk_time \\\n", 245 | "0 188 2 ... 20 756 2549 9 7 19 \n", 246 | "1 136 3 ... 905 1988 2631 17 3 7 \n", 247 | "2 145 5 ... 1263 1716 2603 11 2 9 \n", 248 | "3 131 6 ... 1216 1786 2769 16 8 11 \n", 249 | "4 141 2 ... 1208 1212 1411 8 2 15 \n", 250 | "\n", 251 | " three_g touch_screen wifi price_range \n", 252 | "0 0 0 1 1 \n", 253 | "1 1 1 0 2 \n", 254 | "2 1 1 0 2 \n", 255 | "3 1 0 0 2 \n", 256 | "4 1 1 0 1 \n", 257 | "\n", 258 | "[5 rows x 21 columns]" 259 | ] 260 | }, 261 | "execution_count": 3, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "df.head()" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 4, 273 | "metadata": { 274 | "tags": [] 275 | }, 276 | "outputs": [ 277 | { 278 | "data": { 279 | "text/plain": [ 280 | "(2000, 21)" 281 | ] 282 | }, 283 | "execution_count": 4, 284 | "metadata": {}, 285 | "output_type": "execute_result" 286 | } 287 | ], 288 | "source": [ 289 | "df.shape" 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "execution_count": 5, 295 | "metadata": { 296 | "tags": [] 297 | }, 298 | "outputs": [ 299 | { 300 | "data": { 301 | "text/plain": [ 302 | "price_range\n", 303 | "1 0.25\n", 304 | "2 0.25\n", 305 | "3 0.25\n", 306 | "0 0.25\n", 307 | "Name: proportion, dtype: float64" 308 | ] 309 | }, 310 | "execution_count": 5, 311 | "metadata": {}, 312 | "output_type": "execute_result" 313 | } 314 | ], 315 | "source": [ 316 | "# ['Low_Risk','High_Risk'],[0,1]\n", 317 | "df['price_range'].value_counts(normalize=True)" 318 | ] 319 | }, 320 | { 321 | "cell_type": "code", 322 | "execution_count": 6, 323 | "metadata": { 324 | "tags": [] 325 | }, 326 | "outputs": [ 327 | { 328 | "data": { 329 | "text/plain": [ 330 | "Index(['battery_power', 'blue', 'clock_speed', 'dual_sim', 'fc', 'four_g',\n", 331 | " 'int_memory', 'm_dep', 'mobile_wt', 'n_cores', 'pc', 'px_height',\n", 332 | " 'px_width', 'ram', 'sc_h', 'sc_w', 'talk_time', 'three_g',\n", 333 | " 'touch_screen', 'wifi', 'price_range'],\n", 334 | " dtype='object')" 335 | ] 336 | }, 337 | "execution_count": 6, 338 | "metadata": {}, 339 | "output_type": "execute_result" 340 | } 341 | ], 342 | "source": [ 343 | "df.columns" 344 | ] 345 | }, 346 | { 347 | "cell_type": "code", 348 | "execution_count": 7, 349 | "metadata": { 350 | "tags": [] 351 | }, 352 | "outputs": [ 353 | { 354 | "data": { 355 | "text/plain": [ 356 | "(2000, 21)" 357 | ] 358 | }, 359 | "execution_count": 7, 360 | "metadata": {}, 361 | "output_type": "execute_result" 362 | } 363 | ], 364 | "source": [ 365 | "df.shape" 366 | ] 367 | }, 368 | { 369 | "cell_type": "code", 370 | "execution_count": 8, 371 | "metadata": { 372 | "tags": [] 373 | }, 374 | "outputs": [ 375 | { 376 | "data": { 377 | "text/plain": [ 378 | "battery_power 0.0\n", 379 | "blue 0.0\n", 380 | "clock_speed 0.0\n", 381 | "dual_sim 0.0\n", 382 | "fc 0.0\n", 383 | "four_g 0.0\n", 384 | "int_memory 0.0\n", 385 | "m_dep 0.0\n", 386 | "mobile_wt 0.0\n", 387 | "n_cores 0.0\n", 388 | "pc 0.0\n", 389 | "px_height 0.0\n", 390 | "px_width 0.0\n", 391 | "ram 0.0\n", 392 | "sc_h 0.0\n", 393 | "sc_w 0.0\n", 394 | "talk_time 0.0\n", 395 | "three_g 0.0\n", 396 | "touch_screen 0.0\n", 397 | "wifi 0.0\n", 398 | "price_range 0.0\n", 399 | "dtype: float64" 400 | ] 401 | }, 402 | "execution_count": 8, 403 | "metadata": {}, 404 | "output_type": "execute_result" 405 | } 406 | ], 407 | "source": [ 408 | "# Find the Percentage of Values are missing\n", 409 | "df.isnull().mean() * 100" 410 | ] 411 | }, 412 | { 413 | "cell_type": "code", 414 | "execution_count": 9, 415 | "metadata": { 416 | "tags": [] 417 | }, 418 | "outputs": [ 419 | { 420 | "data": { 421 | "text/plain": [ 422 | "['battery_power',\n", 423 | " 'blue',\n", 424 | " 'clock_speed',\n", 425 | " 'dual_sim',\n", 426 | " 'fc',\n", 427 | " 'four_g',\n", 428 | " 'int_memory',\n", 429 | " 'm_dep',\n", 430 | " 'mobile_wt',\n", 431 | " 'n_cores',\n", 432 | " 'pc',\n", 433 | " 'px_height',\n", 434 | " 'px_width',\n", 435 | " 'ram',\n", 436 | " 'sc_h',\n", 437 | " 'sc_w',\n", 438 | " 'talk_time',\n", 439 | " 'three_g',\n", 440 | " 'touch_screen',\n", 441 | " 'wifi',\n", 442 | " 'price_range']" 443 | ] 444 | }, 445 | "execution_count": 9, 446 | "metadata": {}, 447 | "output_type": "execute_result" 448 | } 449 | ], 450 | "source": [ 451 | "features = list(df.columns)\n", 452 | "features" 453 | ] 454 | }, 455 | { 456 | "cell_type": "code", 457 | "execution_count": 10, 458 | "metadata": { 459 | "tags": [] 460 | }, 461 | "outputs": [ 462 | { 463 | "data": { 464 | "text/plain": [ 465 | "'price_range'" 466 | ] 467 | }, 468 | "execution_count": 10, 469 | "metadata": {}, 470 | "output_type": "execute_result" 471 | } 472 | ], 473 | "source": [ 474 | "label = features.pop(-1)\n", 475 | "label" 476 | ] 477 | }, 478 | { 479 | "cell_type": "code", 480 | "execution_count": 11, 481 | "metadata": { 482 | "tags": [] 483 | }, 484 | "outputs": [], 485 | "source": [ 486 | "x = df[features]\n", 487 | "y = df[label]" 488 | ] 489 | }, 490 | { 491 | "cell_type": "code", 492 | "execution_count": 12, 493 | "metadata": { 494 | "tags": [] 495 | }, 496 | "outputs": [ 497 | { 498 | "data": { 499 | "text/html": [ 500 | "
\n", 501 | "\n", 514 | "\n", 515 | " \n", 516 | " \n", 517 | " \n", 518 | " \n", 519 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | " \n", 531 | " \n", 532 | " \n", 533 | " \n", 534 | " \n", 535 | " \n", 536 | " \n", 537 | " \n", 538 | " \n", 539 | " \n", 540 | " \n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | " \n", 547 | " \n", 548 | " \n", 549 | " \n", 550 | " \n", 551 | " \n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | " \n", 605 | " \n", 606 | " \n", 607 | " \n", 608 | " \n", 609 | " \n", 610 | " \n", 611 | " \n", 612 | " \n", 613 | " \n", 614 | " \n", 615 | " \n", 616 | " \n", 617 | " \n", 618 | " \n", 619 | " \n", 620 | " \n", 621 | " \n", 622 | " \n", 623 | " \n", 624 | " \n", 625 | " \n", 626 | " \n", 627 | " \n", 628 | " \n", 629 | " \n", 630 | " \n", 631 | " \n", 632 | " \n", 633 | " \n", 634 | " \n", 635 | " \n", 636 | " \n", 637 | " \n", 638 | " \n", 639 | " \n", 640 | " \n", 641 | " \n", 642 | " \n", 643 | " \n", 644 | " \n", 645 | " \n", 646 | " \n", 647 | " \n", 648 | " \n", 649 | " \n", 650 | " \n", 651 | " \n", 652 | " \n", 653 | " \n", 654 | " \n", 655 | " \n", 656 | " \n", 657 | "
battery_powerblueclock_speeddual_simfcfour_gint_memorym_depmobile_wtn_corespcpx_heightpx_widthramsc_hsc_wtalk_timethree_gtouch_screenwifi
084202.201070.6188222075625499719001
1102110.5101530.713636905198826311737110
256310.5121410.9145561263171626031129110
361512.5000100.81316912161786276916811100
4182111.20131440.61412141208121214118215110
\n", 658 | "
" 659 | ], 660 | "text/plain": [ 661 | " battery_power blue clock_speed dual_sim fc four_g int_memory m_dep \\\n", 662 | "0 842 0 2.2 0 1 0 7 0.6 \n", 663 | "1 1021 1 0.5 1 0 1 53 0.7 \n", 664 | "2 563 1 0.5 1 2 1 41 0.9 \n", 665 | "3 615 1 2.5 0 0 0 10 0.8 \n", 666 | "4 1821 1 1.2 0 13 1 44 0.6 \n", 667 | "\n", 668 | " mobile_wt n_cores pc px_height px_width ram sc_h sc_w talk_time \\\n", 669 | "0 188 2 2 20 756 2549 9 7 19 \n", 670 | "1 136 3 6 905 1988 2631 17 3 7 \n", 671 | "2 145 5 6 1263 1716 2603 11 2 9 \n", 672 | "3 131 6 9 1216 1786 2769 16 8 11 \n", 673 | "4 141 2 14 1208 1212 1411 8 2 15 \n", 674 | "\n", 675 | " three_g touch_screen wifi \n", 676 | "0 0 0 1 \n", 677 | "1 1 1 0 \n", 678 | "2 1 1 0 \n", 679 | "3 1 0 0 \n", 680 | "4 1 1 0 " 681 | ] 682 | }, 683 | "execution_count": 12, 684 | "metadata": {}, 685 | "output_type": "execute_result" 686 | } 687 | ], 688 | "source": [ 689 | "x.head()" 690 | ] 691 | }, 692 | { 693 | "cell_type": "code", 694 | "execution_count": 13, 695 | "metadata": { 696 | "tags": [] 697 | }, 698 | "outputs": [ 699 | { 700 | "data": { 701 | "text/plain": [ 702 | "0 1\n", 703 | "1 2\n", 704 | "2 2\n", 705 | "3 2\n", 706 | "4 1\n", 707 | "Name: price_range, dtype: int64" 708 | ] 709 | }, 710 | "execution_count": 13, 711 | "metadata": {}, 712 | "output_type": "execute_result" 713 | } 714 | ], 715 | "source": [ 716 | "# {0: 'Low_Risk',1: 'High_Risk'}\n", 717 | "y.head()" 718 | ] 719 | }, 720 | { 721 | "cell_type": "code", 722 | "execution_count": 14, 723 | "metadata": { 724 | "tags": [] 725 | }, 726 | "outputs": [ 727 | { 728 | "data": { 729 | "text/plain": [ 730 | "(2000, 20)" 731 | ] 732 | }, 733 | "execution_count": 14, 734 | "metadata": {}, 735 | "output_type": "execute_result" 736 | } 737 | ], 738 | "source": [ 739 | "x.shape" 740 | ] 741 | }, 742 | { 743 | "cell_type": "code", 744 | "execution_count": 15, 745 | "metadata": { 746 | "tags": [] 747 | }, 748 | "outputs": [ 749 | { 750 | "data": { 751 | "text/plain": [ 752 | "price_range\n", 753 | "1 500\n", 754 | "2 500\n", 755 | "3 500\n", 756 | "0 500\n", 757 | "Name: count, dtype: int64" 758 | ] 759 | }, 760 | "execution_count": 15, 761 | "metadata": {}, 762 | "output_type": "execute_result" 763 | } 764 | ], 765 | "source": [ 766 | "y.value_counts()" 767 | ] 768 | }, 769 | { 770 | "cell_type": "code", 771 | "execution_count": 16, 772 | "metadata": { 773 | "tags": [] 774 | }, 775 | "outputs": [], 776 | "source": [ 777 | "X_train, X_test, y_train, y_test = train_test_split(x,y, test_size=0.15, random_state=0)" 778 | ] 779 | }, 780 | { 781 | "cell_type": "code", 782 | "execution_count": 17, 783 | "metadata": { 784 | "tags": [] 785 | }, 786 | "outputs": [ 787 | { 788 | "name": "stdout", 789 | "output_type": "stream", 790 | "text": [ 791 | "(1700, 20)\n", 792 | "(300, 20)\n", 793 | "(1700,)\n", 794 | "(300,)\n" 795 | ] 796 | } 797 | ], 798 | "source": [ 799 | "print(X_train.shape)\n", 800 | "print(X_test.shape)\n", 801 | "print(y_train.shape)\n", 802 | "print(y_test.shape)" 803 | ] 804 | }, 805 | { 806 | "cell_type": "code", 807 | "execution_count": 18, 808 | "metadata": { 809 | "tags": [] 810 | }, 811 | "outputs": [], 812 | "source": [ 813 | "trainX = pd.DataFrame(X_train)\n", 814 | "trainX[label] = y_train\n", 815 | "\n", 816 | "testX = pd.DataFrame(X_test)\n", 817 | "testX[label] = y_test" 818 | ] 819 | }, 820 | { 821 | "cell_type": "code", 822 | "execution_count": 19, 823 | "metadata": { 824 | "tags": [] 825 | }, 826 | "outputs": [ 827 | { 828 | "name": "stdout", 829 | "output_type": "stream", 830 | "text": [ 831 | "(1700, 21)\n", 832 | "(300, 21)\n" 833 | ] 834 | } 835 | ], 836 | "source": [ 837 | "print(trainX.shape)\n", 838 | "print(testX.shape)" 839 | ] 840 | }, 841 | { 842 | "cell_type": "code", 843 | "execution_count": 20, 844 | "metadata": { 845 | "tags": [] 846 | }, 847 | "outputs": [ 848 | { 849 | "data": { 850 | "text/html": [ 851 | "
\n", 852 | "\n", 865 | "\n", 866 | " \n", 867 | " \n", 868 | " \n", 869 | " \n", 870 | " \n", 871 | " \n", 872 | " \n", 873 | " \n", 874 | " \n", 875 | " \n", 876 | " \n", 877 | " \n", 878 | " \n", 879 | " \n", 880 | " \n", 881 | " \n", 882 | " \n", 883 | " \n", 884 | " \n", 885 | " \n", 886 | " \n", 887 | " \n", 888 | " \n", 889 | " \n", 890 | " \n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | " \n", 946 | " \n", 947 | " \n", 948 | " \n", 949 | " \n", 950 | " \n", 951 | " \n", 952 | " \n", 953 | " \n", 954 | " \n", 955 | " \n", 956 | " \n", 957 | " \n", 958 | " \n", 959 | " \n", 960 | " \n", 961 | " \n", 962 | " \n", 963 | " \n", 964 | " \n", 965 | " \n", 966 | " \n", 967 | " \n", 968 | " \n", 969 | " \n", 970 | " \n", 971 | " \n", 972 | " \n", 973 | " \n", 974 | " \n", 975 | " \n", 976 | " \n", 977 | " \n", 978 | " \n", 979 | " \n", 980 | " \n", 981 | " \n", 982 | " \n", 983 | " \n", 984 | " \n", 985 | " \n", 986 | " \n", 987 | " \n", 988 | " \n", 989 | " \n", 990 | " \n", 991 | " \n", 992 | " \n", 993 | " \n", 994 | " \n", 995 | " \n", 996 | " \n", 997 | " \n", 998 | " \n", 999 | " \n", 1000 | " \n", 1001 | " \n", 1002 | " \n", 1003 | " \n", 1004 | " \n", 1005 | " \n", 1006 | " \n", 1007 | " \n", 1008 | " \n", 1009 | " \n", 1010 | " \n", 1011 | " \n", 1012 | " \n", 1013 | " \n", 1014 | "
battery_powerblueclock_speeddual_simfcfour_gint_memorym_depmobile_wtn_cores...px_heightpx_widthramsc_hsc_wtalk_timethree_gtouch_screenwifiprice_range
1452145002.1010310.61145...1573163979411590111
1044121812.8130390.81507...112217461667100120001
1279160200.60120580.41701...125917463622172170113
674103402.6121450.31903...182129396915171000
120053002.4010320.3886...48101295917760100
\n", 1015 | "

5 rows × 21 columns

\n", 1016 | "
" 1017 | ], 1018 | "text/plain": [ 1019 | " battery_power blue clock_speed dual_sim fc four_g int_memory \\\n", 1020 | "1452 1450 0 2.1 0 1 0 31 \n", 1021 | "1044 1218 1 2.8 1 3 0 39 \n", 1022 | "1279 1602 0 0.6 0 12 0 58 \n", 1023 | "674 1034 0 2.6 1 2 1 45 \n", 1024 | "1200 530 0 2.4 0 1 0 32 \n", 1025 | "\n", 1026 | " m_dep mobile_wt n_cores ... px_height px_width ram sc_h sc_w \\\n", 1027 | "1452 0.6 114 5 ... 1573 1639 794 11 5 \n", 1028 | "1044 0.8 150 7 ... 1122 1746 1667 10 0 \n", 1029 | "1279 0.4 170 1 ... 1259 1746 3622 17 2 \n", 1030 | "674 0.3 190 3 ... 182 1293 969 15 1 \n", 1031 | "1200 0.3 88 6 ... 48 1012 959 17 7 \n", 1032 | "\n", 1033 | " talk_time three_g touch_screen wifi price_range \n", 1034 | "1452 9 0 1 1 1 \n", 1035 | "1044 12 0 0 0 1 \n", 1036 | "1279 17 0 1 1 3 \n", 1037 | "674 7 1 0 0 0 \n", 1038 | "1200 6 0 1 0 0 \n", 1039 | "\n", 1040 | "[5 rows x 21 columns]" 1041 | ] 1042 | }, 1043 | "execution_count": 20, 1044 | "metadata": {}, 1045 | "output_type": "execute_result" 1046 | } 1047 | ], 1048 | "source": [ 1049 | "trainX.head()" 1050 | ] 1051 | }, 1052 | { 1053 | "cell_type": "code", 1054 | "execution_count": 21, 1055 | "metadata": { 1056 | "tags": [] 1057 | }, 1058 | "outputs": [ 1059 | { 1060 | "data": { 1061 | "text/plain": [ 1062 | "battery_power 0\n", 1063 | "blue 0\n", 1064 | "clock_speed 0\n", 1065 | "dual_sim 0\n", 1066 | "fc 0\n", 1067 | "four_g 0\n", 1068 | "int_memory 0\n", 1069 | "m_dep 0\n", 1070 | "mobile_wt 0\n", 1071 | "n_cores 0\n", 1072 | "pc 0\n", 1073 | "px_height 0\n", 1074 | "px_width 0\n", 1075 | "ram 0\n", 1076 | "sc_h 0\n", 1077 | "sc_w 0\n", 1078 | "talk_time 0\n", 1079 | "three_g 0\n", 1080 | "touch_screen 0\n", 1081 | "wifi 0\n", 1082 | "price_range 0\n", 1083 | "dtype: int64" 1084 | ] 1085 | }, 1086 | "execution_count": 21, 1087 | "metadata": {}, 1088 | "output_type": "execute_result" 1089 | } 1090 | ], 1091 | "source": [ 1092 | "trainX.isnull().sum()" 1093 | ] 1094 | }, 1095 | { 1096 | "cell_type": "code", 1097 | "execution_count": 22, 1098 | "metadata": { 1099 | "tags": [] 1100 | }, 1101 | "outputs": [ 1102 | { 1103 | "data": { 1104 | "text/plain": [ 1105 | "battery_power 0\n", 1106 | "blue 0\n", 1107 | "clock_speed 0\n", 1108 | "dual_sim 0\n", 1109 | "fc 0\n", 1110 | "four_g 0\n", 1111 | "int_memory 0\n", 1112 | "m_dep 0\n", 1113 | "mobile_wt 0\n", 1114 | "n_cores 0\n", 1115 | "pc 0\n", 1116 | "px_height 0\n", 1117 | "px_width 0\n", 1118 | "ram 0\n", 1119 | "sc_h 0\n", 1120 | "sc_w 0\n", 1121 | "talk_time 0\n", 1122 | "three_g 0\n", 1123 | "touch_screen 0\n", 1124 | "wifi 0\n", 1125 | "price_range 0\n", 1126 | "dtype: int64" 1127 | ] 1128 | }, 1129 | "execution_count": 22, 1130 | "metadata": {}, 1131 | "output_type": "execute_result" 1132 | } 1133 | ], 1134 | "source": [ 1135 | "testX.isnull().sum()" 1136 | ] 1137 | }, 1138 | { 1139 | "cell_type": "code", 1140 | "execution_count": 23, 1141 | "metadata": { 1142 | "tags": [] 1143 | }, 1144 | "outputs": [], 1145 | "source": [ 1146 | "trainX.to_csv(\"train-V-1.csv\",index = False)\n", 1147 | "testX.to_csv(\"test-V-1.csv\", index = False)" 1148 | ] 1149 | }, 1150 | { 1151 | "cell_type": "code", 1152 | "execution_count": 24, 1153 | "metadata": {}, 1154 | "outputs": [ 1155 | { 1156 | "data": { 1157 | "text/plain": [ 1158 | "'mobbucketsagemaker'" 1159 | ] 1160 | }, 1161 | "execution_count": 24, 1162 | "metadata": {}, 1163 | "output_type": "execute_result" 1164 | } 1165 | ], 1166 | "source": [ 1167 | "bucket" 1168 | ] 1169 | }, 1170 | { 1171 | "cell_type": "code", 1172 | "execution_count": 25, 1173 | "metadata": { 1174 | "tags": [] 1175 | }, 1176 | "outputs": [ 1177 | { 1178 | "name": "stdout", 1179 | "output_type": "stream", 1180 | "text": [ 1181 | "s3://mobbucketsagemaker/sagemaker/mobile_price_classification/sklearncontainer/train-V-1.csv\n", 1182 | "s3://mobbucketsagemaker/sagemaker/mobile_price_classification/sklearncontainer/test-V-1.csv\n" 1183 | ] 1184 | } 1185 | ], 1186 | "source": [ 1187 | "# send data to S3. SageMaker will take training data from s3\n", 1188 | "sk_prefix = \"sagemaker/mobile_price_classification/sklearncontainer\"\n", 1189 | "trainpath = sess.upload_data(\n", 1190 | " path=\"train-V-1.csv\", bucket=bucket, key_prefix=sk_prefix\n", 1191 | ")\n", 1192 | "\n", 1193 | "testpath = sess.upload_data(\n", 1194 | " path=\"test-V-1.csv\", bucket=bucket, key_prefix=sk_prefix\n", 1195 | ")\n", 1196 | "print(trainpath)\n", 1197 | "print(testpath)" 1198 | ] 1199 | }, 1200 | { 1201 | "cell_type": "code", 1202 | "execution_count": 26, 1203 | "metadata": { 1204 | "tags": [] 1205 | }, 1206 | "outputs": [ 1207 | { 1208 | "name": "stdout", 1209 | "output_type": "stream", 1210 | "text": [ 1211 | "Writing script.py\n" 1212 | ] 1213 | } 1214 | ], 1215 | "source": [ 1216 | "%%writefile script.py\n", 1217 | "\n", 1218 | "from sklearn.ensemble import RandomForestClassifier\n", 1219 | "from sklearn.metrics import accuracy_score, classification_report, confusion_matrix, precision_score, recall_score, f1_score, roc_curve, auc\n", 1220 | "import sklearn\n", 1221 | "import joblib\n", 1222 | "import boto3\n", 1223 | "import pathlib\n", 1224 | "from io import StringIO \n", 1225 | "import argparse\n", 1226 | "import joblib\n", 1227 | "import os\n", 1228 | "import numpy as np\n", 1229 | "import pandas as pd\n", 1230 | " \n", 1231 | "def model_fn(model_dir):\n", 1232 | " clf = joblib.load(os.path.join(model_dir, \"model.joblib\"))\n", 1233 | " return clf\n", 1234 | " \n", 1235 | "if __name__ == \"__main__\":\n", 1236 | "\n", 1237 | " print(\"[INFO] Extracting arguments\")\n", 1238 | " parser = argparse.ArgumentParser()\n", 1239 | "\n", 1240 | " # hyperparameters sent by the client are passed as command-line arguments to the script.\n", 1241 | " parser.add_argument(\"--n_estimators\", type=int, default=100)\n", 1242 | " parser.add_argument(\"--random_state\", type=int, default=0)\n", 1243 | "\n", 1244 | " # Data, model, and output directories\n", 1245 | " parser.add_argument(\"--model-dir\", type=str, default=os.environ.get(\"SM_MODEL_DIR\"))\n", 1246 | " parser.add_argument(\"--train\", type=str, default=os.environ.get(\"SM_CHANNEL_TRAIN\"))\n", 1247 | " parser.add_argument(\"--test\", type=str, default=os.environ.get(\"SM_CHANNEL_TEST\"))\n", 1248 | " parser.add_argument(\"--train-file\", type=str, default=\"train-V-1.csv\")\n", 1249 | " parser.add_argument(\"--test-file\", type=str, default=\"test-V-1.csv\")\n", 1250 | "\n", 1251 | " args, _ = parser.parse_known_args()\n", 1252 | " \n", 1253 | " print(\"SKLearn Version: \", sklearn.__version__)\n", 1254 | " print(\"Joblib Version: \", joblib.__version__)\n", 1255 | "\n", 1256 | " print(\"[INFO] Reading data\")\n", 1257 | " print()\n", 1258 | " train_df = pd.read_csv(os.path.join(args.train, args.train_file))\n", 1259 | " test_df = pd.read_csv(os.path.join(args.test, args.test_file))\n", 1260 | " \n", 1261 | " features = list(train_df.columns)\n", 1262 | " label = features.pop(-1)\n", 1263 | " \n", 1264 | " print(\"Building training and testing datasets\")\n", 1265 | " print()\n", 1266 | " X_train = train_df[features]\n", 1267 | " X_test = test_df[features]\n", 1268 | " y_train = train_df[label]\n", 1269 | " y_test = test_df[label]\n", 1270 | "\n", 1271 | " print('Column order: ')\n", 1272 | " print(features)\n", 1273 | " print()\n", 1274 | " \n", 1275 | " print(\"Label column is: \",label)\n", 1276 | " print()\n", 1277 | " \n", 1278 | " print(\"Data Shape: \")\n", 1279 | " print()\n", 1280 | " print(\"---- SHAPE OF TRAINING DATA (85%) ----\")\n", 1281 | " print(X_train.shape)\n", 1282 | " print(y_train.shape)\n", 1283 | " print()\n", 1284 | " print(\"---- SHAPE OF TESTING DATA (15%) ----\")\n", 1285 | " print(X_test.shape)\n", 1286 | " print(y_test.shape)\n", 1287 | " print()\n", 1288 | " \n", 1289 | " \n", 1290 | " print(\"Training RandomForest Model.....\")\n", 1291 | " print()\n", 1292 | " model = RandomForestClassifier(n_estimators=args.n_estimators, random_state=args.random_state, verbose = 3,n_jobs=-1)\n", 1293 | " model.fit(X_train, y_train)\n", 1294 | " print()\n", 1295 | " \n", 1296 | "\n", 1297 | " model_path = os.path.join(args.model_dir, \"model.joblib\")\n", 1298 | " joblib.dump(model,model_path)\n", 1299 | " print(\"Model persisted at \" + model_path)\n", 1300 | " print()\n", 1301 | "\n", 1302 | " \n", 1303 | " y_pred_test = model.predict(X_test)\n", 1304 | " test_acc = accuracy_score(y_test,y_pred_test)\n", 1305 | " test_rep = classification_report(y_test,y_pred_test)\n", 1306 | "\n", 1307 | " print()\n", 1308 | " print(\"---- METRICS RESULTS FOR TESTING DATA ----\")\n", 1309 | " print()\n", 1310 | " print(\"Total Rows are: \", X_test.shape[0])\n", 1311 | " print('[TESTING] Model Accuracy is: ', test_acc)\n", 1312 | " print('[TESTING] Testing Report: ')\n", 1313 | " print(test_rep)" 1314 | ] 1315 | }, 1316 | { 1317 | "cell_type": "code", 1318 | "execution_count": 27, 1319 | "metadata": { 1320 | "tags": [] 1321 | }, 1322 | "outputs": [], 1323 | "source": [ 1324 | "from sagemaker.sklearn.estimator import SKLearn\n", 1325 | "\n", 1326 | "FRAMEWORK_VERSION = \"0.23-1\"\n", 1327 | "\n", 1328 | "sklearn_estimator = SKLearn(\n", 1329 | " entry_point=\"script.py\",\n", 1330 | " role=\"arn:aws:iam::566373416292:role/service-role/AmazonSageMaker-ExecutionRole-20230120T164209\",\n", 1331 | " instance_count=1,\n", 1332 | " instance_type=\"ml.m5.large\",\n", 1333 | " framework_version=FRAMEWORK_VERSION,\n", 1334 | " base_job_name=\"RF-custom-sklearn\",\n", 1335 | " hyperparameters={\n", 1336 | " \"n_estimators\": 100,\n", 1337 | " \"random_state\": 0,\n", 1338 | " },\n", 1339 | " use_spot_instances = True,\n", 1340 | " max_wait = 7200,\n", 1341 | " max_run = 3600\n", 1342 | ")" 1343 | ] 1344 | }, 1345 | { 1346 | "cell_type": "code", 1347 | "execution_count": 28, 1348 | "metadata": { 1349 | "scrolled": true, 1350 | "tags": [] 1351 | }, 1352 | "outputs": [ 1353 | { 1354 | "name": "stdout", 1355 | "output_type": "stream", 1356 | "text": [ 1357 | "Using provided s3_resource\n" 1358 | ] 1359 | }, 1360 | { 1361 | "name": "stderr", 1362 | "output_type": "stream", 1363 | "text": [ 1364 | "INFO:sagemaker:Creating training-job with name: RF-custom-sklearn-2023-06-23-17-51-03-767\n" 1365 | ] 1366 | }, 1367 | { 1368 | "name": "stdout", 1369 | "output_type": "stream", 1370 | "text": [ 1371 | "2023-06-23 17:51:11 Starting - Starting the training job...\n", 1372 | "2023-06-23 17:51:26 Starting - Preparing the instances for training......\n", 1373 | "2023-06-23 17:52:25 Downloading - Downloading input data...\n", 1374 | "2023-06-23 17:53:31 Training - Training image download completed. Training in progress..2023-06-23 17:53:34,866 sagemaker-containers INFO Imported framework sagemaker_sklearn_container.training\n", 1375 | "2023-06-23 17:53:34,870 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\n", 1376 | "2023-06-23 17:53:34,920 sagemaker_sklearn_container.training INFO Invoking user training script.\n", 1377 | "2023-06-23 17:53:35,093 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\n", 1378 | "2023-06-23 17:53:35,107 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\n", 1379 | "2023-06-23 17:53:35,120 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\n", 1380 | "2023-06-23 17:53:35,129 sagemaker-training-toolkit INFO Invoking user script\n", 1381 | "Training Env:\n", 1382 | "{\n", 1383 | " \"additional_framework_parameters\": {},\n", 1384 | " \"channel_input_dirs\": {\n", 1385 | " \"test\": \"/opt/ml/input/data/test\",\n", 1386 | " \"train\": \"/opt/ml/input/data/train\"\n", 1387 | " },\n", 1388 | " \"current_host\": \"algo-1\",\n", 1389 | " \"framework_module\": \"sagemaker_sklearn_container.training:main\",\n", 1390 | " \"hosts\": [\n", 1391 | " \"algo-1\"\n", 1392 | " ],\n", 1393 | " \"hyperparameters\": {\n", 1394 | " \"n_estimators\": 100,\n", 1395 | " \"random_state\": 0\n", 1396 | " },\n", 1397 | " \"input_config_dir\": \"/opt/ml/input/config\",\n", 1398 | " \"input_data_config\": {\n", 1399 | " \"test\": {\n", 1400 | " \"TrainingInputMode\": \"File\",\n", 1401 | " \"S3DistributionType\": \"FullyReplicated\",\n", 1402 | " \"RecordWrapperType\": \"None\"\n", 1403 | " },\n", 1404 | " \"train\": {\n", 1405 | " \"TrainingInputMode\": \"File\",\n", 1406 | " \"S3DistributionType\": \"FullyReplicated\",\n", 1407 | " \"RecordWrapperType\": \"None\"\n", 1408 | " }\n", 1409 | " },\n", 1410 | " \"input_dir\": \"/opt/ml/input\",\n", 1411 | " \"is_master\": true,\n", 1412 | " \"job_name\": \"RF-custom-sklearn-2023-06-23-17-51-03-767\",\n", 1413 | " \"log_level\": 20,\n", 1414 | " \"master_hostname\": \"algo-1\",\n", 1415 | " \"model_dir\": \"/opt/ml/model\",\n", 1416 | " \"module_dir\": \"s3://sagemaker-us-east-1-566373416292/RF-custom-sklearn-2023-06-23-17-51-03-767/source/sourcedir.tar.gz\",\n", 1417 | " \"module_name\": \"script\",\n", 1418 | " \"network_interface_name\": \"eth0\",\n", 1419 | " \"num_cpus\": 2,\n", 1420 | " \"num_gpus\": 0,\n", 1421 | " \"output_data_dir\": \"/opt/ml/output/data\",\n", 1422 | " \"output_dir\": \"/opt/ml/output\",\n", 1423 | " \"output_intermediate_dir\": \"/opt/ml/output/intermediate\",\n", 1424 | " \"resource_config\": {\n", 1425 | " \"current_host\": \"algo-1\",\n", 1426 | " \"current_instance_type\": \"ml.m5.large\",\n", 1427 | " \"current_group_name\": \"homogeneousCluster\",\n", 1428 | " \"hosts\": [\n", 1429 | " \"algo-1\"\n", 1430 | " ],\n", 1431 | " \"instance_groups\": [\n", 1432 | " {\n", 1433 | " \"instance_group_name\": \"homogeneousCluster\",\n", 1434 | " \"instance_type\": \"ml.m5.large\",\n", 1435 | " \"hosts\": [\n", 1436 | " \"algo-1\"\n", 1437 | " ]\n", 1438 | " }\n", 1439 | " ],\n", 1440 | " \"network_interface_name\": \"eth0\"\n", 1441 | " },\n", 1442 | " \"user_entry_point\": \"script.py\"\n", 1443 | "}\n", 1444 | "Environment variables:\n", 1445 | "SM_HOSTS=[\"algo-1\"]\n", 1446 | "SM_NETWORK_INTERFACE_NAME=eth0\n", 1447 | "SM_HPS={\"n_estimators\":100,\"random_state\":0}\n", 1448 | "SM_USER_ENTRY_POINT=script.py\n", 1449 | "SM_FRAMEWORK_PARAMS={}\n", 1450 | "SM_RESOURCE_CONFIG={\"current_group_name\":\"homogeneousCluster\",\"current_host\":\"algo-1\",\"current_instance_type\":\"ml.m5.large\",\"hosts\":[\"algo-1\"],\"instance_groups\":[{\"hosts\":[\"algo-1\"],\"instance_group_name\":\"homogeneousCluster\",\"instance_type\":\"ml.m5.large\"}],\"network_interface_name\":\"eth0\"}\n", 1451 | "SM_INPUT_DATA_CONFIG={\"test\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"},\"train\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"}}\n", 1452 | "SM_OUTPUT_DATA_DIR=/opt/ml/output/data\n", 1453 | "SM_CHANNELS=[\"test\",\"train\"]\n", 1454 | "SM_CURRENT_HOST=algo-1\n", 1455 | "SM_MODULE_NAME=script\n", 1456 | "SM_LOG_LEVEL=20\n", 1457 | "SM_FRAMEWORK_MODULE=sagemaker_sklearn_container.training:main\n", 1458 | "SM_INPUT_DIR=/opt/ml/input\n", 1459 | "SM_INPUT_CONFIG_DIR=/opt/ml/input/config\n", 1460 | "SM_OUTPUT_DIR=/opt/ml/output\n", 1461 | "SM_NUM_CPUS=2\n", 1462 | "SM_NUM_GPUS=0\n", 1463 | "SM_MODEL_DIR=/opt/ml/model\n", 1464 | "SM_MODULE_DIR=s3://sagemaker-us-east-1-566373416292/RF-custom-sklearn-2023-06-23-17-51-03-767/source/sourcedir.tar.gz\n", 1465 | "SM_TRAINING_ENV={\"additional_framework_parameters\":{},\"channel_input_dirs\":{\"test\":\"/opt/ml/input/data/test\",\"train\":\"/opt/ml/input/data/train\"},\"current_host\":\"algo-1\",\"framework_module\":\"sagemaker_sklearn_container.training:main\",\"hosts\":[\"algo-1\"],\"hyperparameters\":{\"n_estimators\":100,\"random_state\":0},\"input_config_dir\":\"/opt/ml/input/config\",\"input_data_config\":{\"test\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"},\"train\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"}},\"input_dir\":\"/opt/ml/input\",\"is_master\":true,\"job_name\":\"RF-custom-sklearn-2023-06-23-17-51-03-767\",\"log_level\":20,\"master_hostname\":\"algo-1\",\"model_dir\":\"/opt/ml/model\",\"module_dir\":\"s3://sagemaker-us-east-1-566373416292/RF-custom-sklearn-2023-06-23-17-51-03-767/source/sourcedir.tar.gz\",\"module_name\":\"script\",\"network_interface_name\":\"eth0\",\"num_cpus\":2,\"num_gpus\":0,\"output_data_dir\":\"/opt/ml/output/data\",\"output_dir\":\"/opt/ml/output\",\"output_intermediate_dir\":\"/opt/ml/output/intermediate\",\"resource_config\":{\"current_group_name\":\"homogeneousCluster\",\"current_host\":\"algo-1\",\"current_instance_type\":\"ml.m5.large\",\"hosts\":[\"algo-1\"],\"instance_groups\":[{\"hosts\":[\"algo-1\"],\"instance_group_name\":\"homogeneousCluster\",\"instance_type\":\"ml.m5.large\"}],\"network_interface_name\":\"eth0\"},\"user_entry_point\":\"script.py\"}\n", 1466 | "SM_USER_ARGS=[\"--n_estimators\",\"100\",\"--random_state\",\"0\"]\n", 1467 | "SM_OUTPUT_INTERMEDIATE_DIR=/opt/ml/output/intermediate\n", 1468 | "SM_CHANNEL_TEST=/opt/ml/input/data/test\n", 1469 | "SM_CHANNEL_TRAIN=/opt/ml/input/data/train\n", 1470 | "SM_HP_N_ESTIMATORS=100\n", 1471 | "SM_HP_RANDOM_STATE=0\n", 1472 | "PYTHONPATH=/opt/ml/code:/miniconda3/bin:/miniconda3/lib/python37.zip:/miniconda3/lib/python3.7:/miniconda3/lib/python3.7/lib-dynload:/miniconda3/lib/python3.7/site-packages\n", 1473 | "Invoking script with the following command:\n", 1474 | "/miniconda3/bin/python script.py --n_estimators 100 --random_state 0\n", 1475 | "[INFO] Extracting arguments\n", 1476 | "SKLearn Version: 0.23.2\n", 1477 | "Joblib Version: 1.2.0\n", 1478 | "[INFO] Reading data\n", 1479 | "Building training and testing datasets\n", 1480 | "Column order: \n", 1481 | "['battery_power', 'blue', 'clock_speed', 'dual_sim', 'fc', 'four_g', 'int_memory', 'm_dep', 'mobile_wt', 'n_cores', 'pc', 'px_height', 'px_width', 'ram', 'sc_h', 'sc_w', 'talk_time', 'three_g', 'touch_screen', 'wifi']\n", 1482 | "Label column is: price_range\n", 1483 | "Data Shape: \n", 1484 | "---- SHAPE OF TRAINING DATA (85%) ----\n", 1485 | "(1700, 20)\n", 1486 | "(1700,)\n", 1487 | "---- SHAPE OF TESTING DATA (15%) ----\n", 1488 | "(300, 20)\n", 1489 | "(300,)\n", 1490 | "Training RandomForest Model.....\n", 1491 | "[Parallel(n_jobs=-1)]: Using backend ThreadingBackend with 2 concurrent workers.\n", 1492 | "building tree 1 of 100building tree 2 of 100\n", 1493 | "building tree 3 of 100\n", 1494 | "building tree 4 of 100\n", 1495 | "building tree 5 of 100building tree 6 of 100\n", 1496 | "building tree 7 of 100\n", 1497 | "building tree 8 of 100\n", 1498 | "building tree 9 of 100\n", 1499 | "building tree 10 of 100\n", 1500 | "building tree 11 of 100\n", 1501 | "building tree 12 of 100\n", 1502 | "building tree 13 of 100building tree 14 of 100\n", 1503 | "building tree 15 of 100\n", 1504 | "building tree 16 of 100\n", 1505 | "building tree 17 of 100building tree 18 of 100\n", 1506 | "building tree 19 of 100\n", 1507 | "building tree 20 of 100\n", 1508 | "building tree 21 of 100\n", 1509 | "building tree 22 of 100\n", 1510 | "building tree 23 of 100\n", 1511 | "building tree 24 of 100\n", 1512 | "building tree 25 of 100\n", 1513 | "building tree 26 of 100\n", 1514 | "building tree 27 of 100\n", 1515 | "building tree 28 of 100\n", 1516 | "building tree 29 of 100\n", 1517 | "[Parallel(n_jobs=-1)]: Done 28 tasks | elapsed: 0.1s\n", 1518 | "building tree 30 of 100\n", 1519 | "building tree 31 of 100\n", 1520 | "building tree 32 of 100\n", 1521 | "building tree 33 of 100\n", 1522 | "building tree 34 of 100\n", 1523 | "building tree 35 of 100building tree 36 of 100\n", 1524 | "building tree 37 of 100\n", 1525 | "building tree 38 of 100\n", 1526 | "building tree 39 of 100\n", 1527 | "building tree 40 of 100\n", 1528 | "building tree 41 of 100building tree 42 of 100\n", 1529 | "building tree 43 of 100\n", 1530 | "building tree 44 of 100\n", 1531 | "building tree 45 of 100\n", 1532 | "building tree 46 of 100\n", 1533 | "building tree 47 of 100\n", 1534 | "building tree 48 of 100\n", 1535 | "building tree 49 of 100\n", 1536 | "building tree 50 of 100\n", 1537 | "building tree 51 of 100\n", 1538 | "building tree 52 of 100\n", 1539 | "building tree 53 of 100building tree 54 of 100\n", 1540 | "building tree 55 of 100\n", 1541 | "building tree 56 of 100\n", 1542 | "building tree 57 of 100\n", 1543 | "building tree 58 of 100\n", 1544 | "building tree 59 of 100\n", 1545 | "building tree 60 of 100\n", 1546 | "building tree 61 of 100building tree 62 of 100\n", 1547 | "building tree 63 of 100\n", 1548 | "building tree 64 of 100\n", 1549 | "building tree 65 of 100\n", 1550 | "building tree 66 of 100\n", 1551 | "building tree 67 of 100\n", 1552 | "building tree 68 of 100\n", 1553 | "building tree 69 of 100\n", 1554 | "building tree 70 of 100\n", 1555 | "building tree 71 of 100\n", 1556 | "building tree 72 of 100\n", 1557 | "building tree 73 of 100\n", 1558 | "building tree 74 of 100\n", 1559 | "building tree 75 of 100\n", 1560 | "building tree 76 of 100\n", 1561 | "building tree 77 of 100\n", 1562 | "building tree 78 of 100\n", 1563 | "building tree 79 of 100\n", 1564 | "building tree 80 of 100\n", 1565 | "building tree 81 of 100\n", 1566 | "building tree 82 of 100\n", 1567 | "building tree 83 of 100\n", 1568 | "building tree 84 of 100\n", 1569 | "building tree 85 of 100\n", 1570 | "building tree 86 of 100\n", 1571 | "building tree 87 of 100\n", 1572 | "building tree 88 of 100\n", 1573 | "building tree 89 of 100\n", 1574 | "building tree 90 of 100\n", 1575 | "building tree 91 of 100\n", 1576 | "building tree 92 of 100\n", 1577 | "building tree 93 of 100\n", 1578 | "building tree 94 of 100\n", 1579 | "building tree 95 of 100\n", 1580 | "building tree 96 of 100\n", 1581 | "building tree 97 of 100\n", 1582 | "building tree 98 of 100\n", 1583 | "building tree 99 of 100\n", 1584 | "building tree 100 of 100\n", 1585 | "[Parallel(n_jobs=-1)]: Done 100 out of 100 | elapsed: 0.3s finished\n", 1586 | "Model persisted at /opt/ml/model/model.joblib\n", 1587 | "[Parallel(n_jobs=2)]: Using backend ThreadingBackend with 2 concurrent workers.\n", 1588 | "[Parallel(n_jobs=2)]: Done 28 tasks | elapsed: 0.0s\n", 1589 | "[Parallel(n_jobs=2)]: Done 100 out of 100 | elapsed: 0.0s finished\n", 1590 | "---- METRICS RESULTS FOR TESTING DATA ----\n", 1591 | "Total Rows are: 300\n", 1592 | "[TESTING] Model Accuracy is: 0.8833333333333333\n", 1593 | "[TESTING] Testing Report: \n", 1594 | " precision recall f1-score support\n", 1595 | " 0 0.95 1.00 0.97 69\n", 1596 | " 1 0.85 0.80 0.83 66\n", 1597 | " 2 0.80 0.77 0.79 74\n", 1598 | " 3 0.91 0.95 0.93 91\n", 1599 | " accuracy 0.88 300\n", 1600 | " macro avg 0.88 0.88 0.88 300\n", 1601 | "weighted avg 0.88 0.88 0.88 300\n", 1602 | "2023-06-23 17:53:36,788 sagemaker-containers INFO Reporting training SUCCESS\n", 1603 | "\n", 1604 | "2023-06-23 17:53:42 Uploading - Uploading generated training model\n", 1605 | "2023-06-23 17:54:51 Completed - Training job completed\n", 1606 | "Training seconds: 146\n", 1607 | "Billable seconds: 108\n", 1608 | "Managed Spot Training savings: 26.0%\n" 1609 | ] 1610 | } 1611 | ], 1612 | "source": [ 1613 | "# launch training job, with asynchronous call\n", 1614 | "sklearn_estimator.fit({\"train\": trainpath, \"test\": testpath}, wait=True)\n", 1615 | "# sklearn_estimator.fit({\"train\": datapath}, wait=True)" 1616 | ] 1617 | }, 1618 | { 1619 | "cell_type": "code", 1620 | "execution_count": 29, 1621 | "metadata": { 1622 | "tags": [] 1623 | }, 1624 | "outputs": [ 1625 | { 1626 | "name": "stdout", 1627 | "output_type": "stream", 1628 | "text": [ 1629 | "\n", 1630 | "2023-06-23 17:54:51 Starting - Preparing the instances for training\n", 1631 | "2023-06-23 17:54:51 Downloading - Downloading input data\n", 1632 | "2023-06-23 17:54:51 Training - Training image download completed. Training in progress.\n", 1633 | "2023-06-23 17:54:51 Uploading - Uploading generated training model\n", 1634 | "2023-06-23 17:54:51 Completed - Training job completed\n", 1635 | "Model artifact persisted at s3://sagemaker-us-east-1-566373416292/RF-custom-sklearn-2023-06-23-17-51-03-767/output/model.tar.gz\n" 1636 | ] 1637 | } 1638 | ], 1639 | "source": [ 1640 | "sklearn_estimator.latest_training_job.wait(logs=\"None\")\n", 1641 | "artifact = sm_boto3.describe_training_job(\n", 1642 | " TrainingJobName=sklearn_estimator.latest_training_job.name\n", 1643 | ")[\"ModelArtifacts\"][\"S3ModelArtifacts\"]\n", 1644 | "\n", 1645 | "print(\"Model artifact persisted at \" + artifact)" 1646 | ] 1647 | }, 1648 | { 1649 | "cell_type": "code", 1650 | "execution_count": 30, 1651 | "metadata": {}, 1652 | "outputs": [ 1653 | { 1654 | "data": { 1655 | "text/plain": [ 1656 | "'s3://sagemaker-us-east-1-566373416292/RF-custom-sklearn-2023-06-23-17-51-03-767/output/model.tar.gz'" 1657 | ] 1658 | }, 1659 | "execution_count": 30, 1660 | "metadata": {}, 1661 | "output_type": "execute_result" 1662 | } 1663 | ], 1664 | "source": [ 1665 | "artifact" 1666 | ] 1667 | }, 1668 | { 1669 | "cell_type": "code", 1670 | "execution_count": 31, 1671 | "metadata": { 1672 | "tags": [] 1673 | }, 1674 | "outputs": [], 1675 | "source": [ 1676 | "from sagemaker.sklearn.model import SKLearnModel\n", 1677 | "from time import gmtime, strftime\n", 1678 | "\n", 1679 | "model_name = \"Custom-sklearn-model-\" + strftime(\"%Y-%m-%d-%H-%M-%S\", gmtime())\n", 1680 | "model = SKLearnModel(\n", 1681 | " name = model_name,\n", 1682 | " model_data=artifact,\n", 1683 | " role=\"arn:aws:iam::566373416292:role/service-role/AmazonSageMaker-ExecutionRole-20230120T164209\",\n", 1684 | " entry_point=\"script.py\",\n", 1685 | " framework_version=FRAMEWORK_VERSION,\n", 1686 | ")" 1687 | ] 1688 | }, 1689 | { 1690 | "cell_type": "code", 1691 | "execution_count": 33, 1692 | "metadata": {}, 1693 | "outputs": [ 1694 | { 1695 | "data": { 1696 | "text/plain": [ 1697 | "'Custom-sklearn-model-2023-06-23-18-01-16'" 1698 | ] 1699 | }, 1700 | "execution_count": 33, 1701 | "metadata": {}, 1702 | "output_type": "execute_result" 1703 | } 1704 | ], 1705 | "source": [ 1706 | "model_name" 1707 | ] 1708 | }, 1709 | { 1710 | "cell_type": "code", 1711 | "execution_count": 34, 1712 | "metadata": { 1713 | "tags": [] 1714 | }, 1715 | "outputs": [ 1716 | { 1717 | "name": "stdout", 1718 | "output_type": "stream", 1719 | "text": [ 1720 | "EndpointName=Custom-sklearn-model-2023-06-23-18-02-06\n" 1721 | ] 1722 | }, 1723 | { 1724 | "name": "stderr", 1725 | "output_type": "stream", 1726 | "text": [ 1727 | "INFO:sagemaker:Creating model with name: Custom-sklearn-model-2023-06-23-18-01-16\n", 1728 | "INFO:sagemaker:Creating endpoint-config with name Custom-sklearn-model-2023-06-23-18-02-06\n", 1729 | "INFO:sagemaker:Creating endpoint with name Custom-sklearn-model-2023-06-23-18-02-06\n" 1730 | ] 1731 | } 1732 | ], 1733 | "source": [ 1734 | "##Endpoints deployment\n", 1735 | "endpoint_name = \"Custom-sklearn-model-\" + strftime(\"%Y-%m-%d-%H-%M-%S\", gmtime())\n", 1736 | "print(\"EndpointName={}\".format(endpoint_name))\n", 1737 | "\n", 1738 | "predictor = model.deploy(\n", 1739 | " initial_instance_count=1,\n", 1740 | " instance_type=\"ml.m4.xlarge\",\n", 1741 | " endpoint_name=endpoint_name,\n", 1742 | ")" 1743 | ] 1744 | }, 1745 | { 1746 | "cell_type": "code", 1747 | "execution_count": null, 1748 | "metadata": {}, 1749 | "outputs": [], 1750 | "source": [ 1751 | "endpoint_name" 1752 | ] 1753 | }, 1754 | { 1755 | "cell_type": "code", 1756 | "execution_count": null, 1757 | "metadata": { 1758 | "tags": [] 1759 | }, 1760 | "outputs": [], 1761 | "source": [ 1762 | "testX[features][0:2].values.tolist()" 1763 | ] 1764 | }, 1765 | { 1766 | "cell_type": "code", 1767 | "execution_count": null, 1768 | "metadata": { 1769 | "tags": [] 1770 | }, 1771 | "outputs": [], 1772 | "source": [ 1773 | "print(predictor.predict(testX[features][0:2].values.tolist()))" 1774 | ] 1775 | }, 1776 | { 1777 | "cell_type": "code", 1778 | "execution_count": null, 1779 | "metadata": { 1780 | "tags": [] 1781 | }, 1782 | "outputs": [], 1783 | "source": [ 1784 | "sm_boto3.delete_endpoint(EndpointName=endpoint_name)" 1785 | ] 1786 | }, 1787 | { 1788 | "cell_type": "code", 1789 | "execution_count": null, 1790 | "metadata": {}, 1791 | "outputs": [], 1792 | "source": [] 1793 | } 1794 | ], 1795 | "metadata": { 1796 | "availableInstances": [ 1797 | { 1798 | "_defaultOrder": 0, 1799 | "_isFastLaunch": true, 1800 | "category": "General purpose", 1801 | "gpuNum": 0, 1802 | "memoryGiB": 4, 1803 | "name": "ml.t3.medium", 1804 | "vcpuNum": 2 1805 | }, 1806 | { 1807 | "_defaultOrder": 1, 1808 | "_isFastLaunch": false, 1809 | "category": "General purpose", 1810 | "gpuNum": 0, 1811 | "memoryGiB": 8, 1812 | "name": "ml.t3.large", 1813 | "vcpuNum": 2 1814 | }, 1815 | { 1816 | "_defaultOrder": 2, 1817 | "_isFastLaunch": false, 1818 | "category": "General purpose", 1819 | "gpuNum": 0, 1820 | "memoryGiB": 16, 1821 | "name": "ml.t3.xlarge", 1822 | "vcpuNum": 4 1823 | }, 1824 | { 1825 | "_defaultOrder": 3, 1826 | "_isFastLaunch": false, 1827 | "category": "General purpose", 1828 | "gpuNum": 0, 1829 | "memoryGiB": 32, 1830 | "name": "ml.t3.2xlarge", 1831 | "vcpuNum": 8 1832 | }, 1833 | { 1834 | "_defaultOrder": 4, 1835 | "_isFastLaunch": true, 1836 | "category": "General purpose", 1837 | "gpuNum": 0, 1838 | "memoryGiB": 8, 1839 | "name": "ml.m5.large", 1840 | "vcpuNum": 2 1841 | }, 1842 | { 1843 | "_defaultOrder": 5, 1844 | "_isFastLaunch": false, 1845 | "category": "General purpose", 1846 | "gpuNum": 0, 1847 | "memoryGiB": 16, 1848 | "name": "ml.m5.xlarge", 1849 | "vcpuNum": 4 1850 | }, 1851 | { 1852 | "_defaultOrder": 6, 1853 | "_isFastLaunch": false, 1854 | "category": "General purpose", 1855 | "gpuNum": 0, 1856 | "memoryGiB": 32, 1857 | "name": "ml.m5.2xlarge", 1858 | "vcpuNum": 8 1859 | }, 1860 | { 1861 | "_defaultOrder": 7, 1862 | "_isFastLaunch": false, 1863 | "category": "General purpose", 1864 | "gpuNum": 0, 1865 | "memoryGiB": 64, 1866 | "name": "ml.m5.4xlarge", 1867 | "vcpuNum": 16 1868 | }, 1869 | { 1870 | "_defaultOrder": 8, 1871 | "_isFastLaunch": false, 1872 | "category": "General purpose", 1873 | "gpuNum": 0, 1874 | "memoryGiB": 128, 1875 | "name": "ml.m5.8xlarge", 1876 | "vcpuNum": 32 1877 | }, 1878 | { 1879 | "_defaultOrder": 9, 1880 | "_isFastLaunch": false, 1881 | "category": "General purpose", 1882 | "gpuNum": 0, 1883 | "memoryGiB": 192, 1884 | "name": "ml.m5.12xlarge", 1885 | "vcpuNum": 48 1886 | }, 1887 | { 1888 | "_defaultOrder": 10, 1889 | "_isFastLaunch": false, 1890 | "category": "General purpose", 1891 | "gpuNum": 0, 1892 | "memoryGiB": 256, 1893 | "name": "ml.m5.16xlarge", 1894 | "vcpuNum": 64 1895 | }, 1896 | { 1897 | "_defaultOrder": 11, 1898 | "_isFastLaunch": false, 1899 | "category": "General purpose", 1900 | "gpuNum": 0, 1901 | "memoryGiB": 384, 1902 | "name": "ml.m5.24xlarge", 1903 | "vcpuNum": 96 1904 | }, 1905 | { 1906 | "_defaultOrder": 12, 1907 | "_isFastLaunch": false, 1908 | "category": "General purpose", 1909 | "gpuNum": 0, 1910 | "memoryGiB": 8, 1911 | "name": "ml.m5d.large", 1912 | "vcpuNum": 2 1913 | }, 1914 | { 1915 | "_defaultOrder": 13, 1916 | "_isFastLaunch": false, 1917 | "category": "General purpose", 1918 | "gpuNum": 0, 1919 | "memoryGiB": 16, 1920 | "name": "ml.m5d.xlarge", 1921 | "vcpuNum": 4 1922 | }, 1923 | { 1924 | "_defaultOrder": 14, 1925 | "_isFastLaunch": false, 1926 | "category": "General purpose", 1927 | "gpuNum": 0, 1928 | "memoryGiB": 32, 1929 | "name": "ml.m5d.2xlarge", 1930 | "vcpuNum": 8 1931 | }, 1932 | { 1933 | "_defaultOrder": 15, 1934 | "_isFastLaunch": false, 1935 | "category": "General purpose", 1936 | "gpuNum": 0, 1937 | "memoryGiB": 64, 1938 | "name": "ml.m5d.4xlarge", 1939 | "vcpuNum": 16 1940 | }, 1941 | { 1942 | "_defaultOrder": 16, 1943 | "_isFastLaunch": false, 1944 | "category": "General purpose", 1945 | "gpuNum": 0, 1946 | "memoryGiB": 128, 1947 | "name": "ml.m5d.8xlarge", 1948 | "vcpuNum": 32 1949 | }, 1950 | { 1951 | "_defaultOrder": 17, 1952 | "_isFastLaunch": false, 1953 | "category": "General purpose", 1954 | "gpuNum": 0, 1955 | "memoryGiB": 192, 1956 | "name": "ml.m5d.12xlarge", 1957 | "vcpuNum": 48 1958 | }, 1959 | { 1960 | "_defaultOrder": 18, 1961 | "_isFastLaunch": false, 1962 | "category": "General purpose", 1963 | "gpuNum": 0, 1964 | "memoryGiB": 256, 1965 | "name": "ml.m5d.16xlarge", 1966 | "vcpuNum": 64 1967 | }, 1968 | { 1969 | "_defaultOrder": 19, 1970 | "_isFastLaunch": false, 1971 | "category": "General purpose", 1972 | "gpuNum": 0, 1973 | "memoryGiB": 384, 1974 | "name": "ml.m5d.24xlarge", 1975 | "vcpuNum": 96 1976 | }, 1977 | { 1978 | "_defaultOrder": 20, 1979 | "_isFastLaunch": true, 1980 | "category": "Compute optimized", 1981 | "gpuNum": 0, 1982 | "memoryGiB": 4, 1983 | "name": "ml.c5.large", 1984 | "vcpuNum": 2 1985 | }, 1986 | { 1987 | "_defaultOrder": 21, 1988 | "_isFastLaunch": false, 1989 | "category": "Compute optimized", 1990 | "gpuNum": 0, 1991 | "memoryGiB": 8, 1992 | "name": "ml.c5.xlarge", 1993 | "vcpuNum": 4 1994 | }, 1995 | { 1996 | "_defaultOrder": 22, 1997 | "_isFastLaunch": false, 1998 | "category": "Compute optimized", 1999 | "gpuNum": 0, 2000 | "memoryGiB": 16, 2001 | "name": "ml.c5.2xlarge", 2002 | "vcpuNum": 8 2003 | }, 2004 | { 2005 | "_defaultOrder": 23, 2006 | "_isFastLaunch": false, 2007 | "category": "Compute optimized", 2008 | "gpuNum": 0, 2009 | "memoryGiB": 32, 2010 | "name": "ml.c5.4xlarge", 2011 | "vcpuNum": 16 2012 | }, 2013 | { 2014 | "_defaultOrder": 24, 2015 | "_isFastLaunch": false, 2016 | "category": "Compute optimized", 2017 | "gpuNum": 0, 2018 | "memoryGiB": 72, 2019 | "name": "ml.c5.9xlarge", 2020 | "vcpuNum": 36 2021 | }, 2022 | { 2023 | "_defaultOrder": 25, 2024 | "_isFastLaunch": false, 2025 | "category": "Compute optimized", 2026 | "gpuNum": 0, 2027 | "memoryGiB": 96, 2028 | "name": "ml.c5.12xlarge", 2029 | "vcpuNum": 48 2030 | }, 2031 | { 2032 | "_defaultOrder": 26, 2033 | "_isFastLaunch": false, 2034 | "category": "Compute optimized", 2035 | "gpuNum": 0, 2036 | "memoryGiB": 144, 2037 | "name": "ml.c5.18xlarge", 2038 | "vcpuNum": 72 2039 | }, 2040 | { 2041 | "_defaultOrder": 27, 2042 | "_isFastLaunch": false, 2043 | "category": "Compute optimized", 2044 | "gpuNum": 0, 2045 | "memoryGiB": 192, 2046 | "name": "ml.c5.24xlarge", 2047 | "vcpuNum": 96 2048 | }, 2049 | { 2050 | "_defaultOrder": 28, 2051 | "_isFastLaunch": true, 2052 | "category": "Accelerated computing", 2053 | "gpuNum": 1, 2054 | "memoryGiB": 16, 2055 | "name": "ml.g4dn.xlarge", 2056 | "vcpuNum": 4 2057 | }, 2058 | { 2059 | "_defaultOrder": 29, 2060 | "_isFastLaunch": false, 2061 | "category": "Accelerated computing", 2062 | "gpuNum": 1, 2063 | "memoryGiB": 32, 2064 | "name": "ml.g4dn.2xlarge", 2065 | "vcpuNum": 8 2066 | }, 2067 | { 2068 | "_defaultOrder": 30, 2069 | "_isFastLaunch": false, 2070 | "category": "Accelerated computing", 2071 | "gpuNum": 1, 2072 | "memoryGiB": 64, 2073 | "name": "ml.g4dn.4xlarge", 2074 | "vcpuNum": 16 2075 | }, 2076 | { 2077 | "_defaultOrder": 31, 2078 | "_isFastLaunch": false, 2079 | "category": "Accelerated computing", 2080 | "gpuNum": 1, 2081 | "memoryGiB": 128, 2082 | "name": "ml.g4dn.8xlarge", 2083 | "vcpuNum": 32 2084 | }, 2085 | { 2086 | "_defaultOrder": 32, 2087 | "_isFastLaunch": false, 2088 | "category": "Accelerated computing", 2089 | "gpuNum": 4, 2090 | "memoryGiB": 192, 2091 | "name": "ml.g4dn.12xlarge", 2092 | "vcpuNum": 48 2093 | }, 2094 | { 2095 | "_defaultOrder": 33, 2096 | "_isFastLaunch": false, 2097 | "category": "Accelerated computing", 2098 | "gpuNum": 1, 2099 | "memoryGiB": 256, 2100 | "name": "ml.g4dn.16xlarge", 2101 | "vcpuNum": 64 2102 | }, 2103 | { 2104 | "_defaultOrder": 34, 2105 | "_isFastLaunch": false, 2106 | "category": "Accelerated computing", 2107 | "gpuNum": 1, 2108 | "memoryGiB": 61, 2109 | "name": "ml.p3.2xlarge", 2110 | "vcpuNum": 8 2111 | }, 2112 | { 2113 | "_defaultOrder": 35, 2114 | "_isFastLaunch": false, 2115 | "category": "Accelerated computing", 2116 | "gpuNum": 4, 2117 | "memoryGiB": 244, 2118 | "name": "ml.p3.8xlarge", 2119 | "vcpuNum": 32 2120 | }, 2121 | { 2122 | "_defaultOrder": 36, 2123 | "_isFastLaunch": false, 2124 | "category": "Accelerated computing", 2125 | "gpuNum": 8, 2126 | "memoryGiB": 488, 2127 | "name": "ml.p3.16xlarge", 2128 | "vcpuNum": 64 2129 | }, 2130 | { 2131 | "_defaultOrder": 37, 2132 | "_isFastLaunch": false, 2133 | "category": "Accelerated computing", 2134 | "gpuNum": 8, 2135 | "memoryGiB": 768, 2136 | "name": "ml.p3dn.24xlarge", 2137 | "vcpuNum": 96 2138 | }, 2139 | { 2140 | "_defaultOrder": 38, 2141 | "_isFastLaunch": false, 2142 | "category": "Memory Optimized", 2143 | "gpuNum": 0, 2144 | "memoryGiB": 16, 2145 | "name": "ml.r5.large", 2146 | "vcpuNum": 2 2147 | }, 2148 | { 2149 | "_defaultOrder": 39, 2150 | "_isFastLaunch": false, 2151 | "category": "Memory Optimized", 2152 | "gpuNum": 0, 2153 | "memoryGiB": 32, 2154 | "name": "ml.r5.xlarge", 2155 | "vcpuNum": 4 2156 | }, 2157 | { 2158 | "_defaultOrder": 40, 2159 | "_isFastLaunch": false, 2160 | "category": "Memory Optimized", 2161 | "gpuNum": 0, 2162 | "memoryGiB": 64, 2163 | "name": "ml.r5.2xlarge", 2164 | "vcpuNum": 8 2165 | }, 2166 | { 2167 | "_defaultOrder": 41, 2168 | "_isFastLaunch": false, 2169 | "category": "Memory Optimized", 2170 | "gpuNum": 0, 2171 | "memoryGiB": 128, 2172 | "name": "ml.r5.4xlarge", 2173 | "vcpuNum": 16 2174 | }, 2175 | { 2176 | "_defaultOrder": 42, 2177 | "_isFastLaunch": false, 2178 | "category": "Memory Optimized", 2179 | "gpuNum": 0, 2180 | "memoryGiB": 256, 2181 | "name": "ml.r5.8xlarge", 2182 | "vcpuNum": 32 2183 | }, 2184 | { 2185 | "_defaultOrder": 43, 2186 | "_isFastLaunch": false, 2187 | "category": "Memory Optimized", 2188 | "gpuNum": 0, 2189 | "memoryGiB": 384, 2190 | "name": "ml.r5.12xlarge", 2191 | "vcpuNum": 48 2192 | }, 2193 | { 2194 | "_defaultOrder": 44, 2195 | "_isFastLaunch": false, 2196 | "category": "Memory Optimized", 2197 | "gpuNum": 0, 2198 | "memoryGiB": 512, 2199 | "name": "ml.r5.16xlarge", 2200 | "vcpuNum": 64 2201 | }, 2202 | { 2203 | "_defaultOrder": 45, 2204 | "_isFastLaunch": false, 2205 | "category": "Memory Optimized", 2206 | "gpuNum": 0, 2207 | "memoryGiB": 768, 2208 | "name": "ml.r5.24xlarge", 2209 | "vcpuNum": 96 2210 | }, 2211 | { 2212 | "_defaultOrder": 46, 2213 | "_isFastLaunch": false, 2214 | "category": "Accelerated computing", 2215 | "gpuNum": 1, 2216 | "memoryGiB": 16, 2217 | "name": "ml.g5.xlarge", 2218 | "vcpuNum": 4 2219 | }, 2220 | { 2221 | "_defaultOrder": 47, 2222 | "_isFastLaunch": false, 2223 | "category": "Accelerated computing", 2224 | "gpuNum": 1, 2225 | "memoryGiB": 32, 2226 | "name": "ml.g5.2xlarge", 2227 | "vcpuNum": 8 2228 | }, 2229 | { 2230 | "_defaultOrder": 48, 2231 | "_isFastLaunch": false, 2232 | "category": "Accelerated computing", 2233 | "gpuNum": 1, 2234 | "memoryGiB": 64, 2235 | "name": "ml.g5.4xlarge", 2236 | "vcpuNum": 16 2237 | }, 2238 | { 2239 | "_defaultOrder": 49, 2240 | "_isFastLaunch": false, 2241 | "category": "Accelerated computing", 2242 | "gpuNum": 1, 2243 | "memoryGiB": 128, 2244 | "name": "ml.g5.8xlarge", 2245 | "vcpuNum": 32 2246 | }, 2247 | { 2248 | "_defaultOrder": 50, 2249 | "_isFastLaunch": false, 2250 | "category": "Accelerated computing", 2251 | "gpuNum": 1, 2252 | "memoryGiB": 256, 2253 | "name": "ml.g5.16xlarge", 2254 | "vcpuNum": 64 2255 | }, 2256 | { 2257 | "_defaultOrder": 51, 2258 | "_isFastLaunch": false, 2259 | "category": "Accelerated computing", 2260 | "gpuNum": 4, 2261 | "memoryGiB": 192, 2262 | "name": "ml.g5.12xlarge", 2263 | "vcpuNum": 48 2264 | }, 2265 | { 2266 | "_defaultOrder": 52, 2267 | "_isFastLaunch": false, 2268 | "category": "Accelerated computing", 2269 | "gpuNum": 4, 2270 | "memoryGiB": 384, 2271 | "name": "ml.g5.24xlarge", 2272 | "vcpuNum": 96 2273 | }, 2274 | { 2275 | "_defaultOrder": 53, 2276 | "_isFastLaunch": false, 2277 | "category": "Accelerated computing", 2278 | "gpuNum": 8, 2279 | "memoryGiB": 768, 2280 | "name": "ml.g5.48xlarge", 2281 | "vcpuNum": 192 2282 | } 2283 | ], 2284 | "instance_type": "ml.t3.medium", 2285 | "kernelspec": { 2286 | "display_name": "Python 3 (ipykernel)", 2287 | "language": "python", 2288 | "name": "python3" 2289 | }, 2290 | "language_info": { 2291 | "codemirror_mode": { 2292 | "name": "ipython", 2293 | "version": 3 2294 | }, 2295 | "file_extension": ".py", 2296 | "mimetype": "text/x-python", 2297 | "name": "python", 2298 | "nbconvert_exporter": "python", 2299 | "pygments_lexer": "ipython3", 2300 | "version": "3.8.16" 2301 | } 2302 | }, 2303 | "nbformat": 4, 2304 | "nbformat_minor": 4 2305 | } 2306 | --------------------------------------------------------------------------------