LABS
LABS
Objectives
After completing this lab, you will be able to:
Prerequisites
This lab requires:
Duration
This lab takes approximately 30 minutes. The lab will remain active for 180
minutes
2. Wait until you see the message Lab status: ready, then close the Start Lab
panel by choosing the X.
3. At the top of these instructions, choose AWS
This will open the AWS Management Console in a new browser tab. The
system will automatically log you in.
Tip: If a new browser tab does not open, there will typically be a banner or
icon at the top of your browser that indicates that your browser is
preventing the website from opening pop-up windows. Select the banner
or icon and then choose Allow pop ups.
o Jupyter.org
o Jupyter Notebook Tutorial
14.At the end of the row, choose Open JupyterLab to open the Jupyter
notebook instance.
15.In the JupyterLab GUI, open the folder for your desired language, then
open the PythonCheatSheeet.ipynb notebook file (which was
automatically uploaded to the JupyterLab IDE). The notebook will open in
a new tab in the editor.
The JupyterLab environment will look like the following image. You will
now examine at its components in detail.
The top includes the menu bar, which provides all the commands to
control the notebook and environment. It includes:
The left side of the screen (1) includes the navigation sidebar and the
main work area (2). The navigation sidebar contains the following tabs:
o – File browser
o Drag a tab to the center of a tab panel to move the tab to the panel.
o Subdivide a tab panel by dragging a tab to the left, right, top, or
bottom of the pane.
The work area has a single current activity. The tab for the current activity
is marked with a colored top border (blue by default).
The main work area has a toolbar, which changes depending on the type
of file that's open and in focus. The toolbar for a Jupyter notebook looks
like the following example:
3 – A dropdown menu for changing the cell type. The run behavior of a
cell is determined by the cell's type. Cells include the following types.
o Code cells: The cells that take input in the form of code.
o Markdown cells: Cells that contain additional information as text
that's in a language called Markdown. The output of this cell is text
that's formatted similar to an HTML page. You will look at this cell in
the next task step.
o Raw NBconvert cells: Raw cells that don't give you an output.
4 – The kernel name and its running status. Solid indicates that code is
being run.
The first cell in the notebook is a Markdown cell. A Markdown cell uses
Markdown, which is a markup language with plaintext-formatting syntax.
It's often used to format readme files to create rich text and additional
documentation in the Jupyter notebook. You will now examine the
Markdown cell.
For more information about how to structure Markdown, see the Jupyter
notebook Markdown documentation
17.Lastly, you have a code cell that you can use to run your code.
A notebook can run code in different languages, but it can only use one
kernel at a time. A code cell enables you to write code in a single block
with full-syntax highlighting. Each cell is run individually, and the order can
be found by using the number to the left of the cell In[<number>] . Similarly,
the output of that cell is given by Out[<number>] .
18.Run through this notebook one time, and then proceed to the next task.
Learn more To learn more about Jupyter notebooks, see the Jupyter notebook
documentation.
19.In your JupyterLab environment, switch the left navigation view to the
Amazon SageMaker Samples.
20.Locate the sample named linear_learner_mnist.ipynb . Choose the sample to
load it into the main work area.
21.To create a copy, in the file header, choose the Create a Copy button and
in the dialog box, choose Create a Copy again.
The data you will use throughout the guided labs is a dataset that contains
medical data about the vertebral column. To learn more about this dataset, see
the Vertebral Column Dataset at the UC Irvine Machine Learning Repository.
22.In your JupyterLab environment, choose File > New and then choose
Notebook.
23.In the Select kernel dialog window, choose conda_python3 and then choose
Select.
You should have a blank code cell in the main work area. You will change
this blank cell to a Markup cell and add some text.
24.On the keyboard, press M. The cell type in the dropdown menu should
change to Markdown. If not, use the dropdown menu to change the cell
type.
Next, you will give your notebook a title. Remember that a notebook can contain
both code and Markdown.
26.To exit the cell and render the Markup, press SHIFT + ENTER.
Next, you must download the data from the internet. You will use a URL,
but the file is a .zip file. You could download the .zip file and extract it.
However, because the file is small, you can download the file to a stream.
You will then extract the files so you can save it locally.
Start by adding a few imports.
27.On the keyboard, press ENTER and then type the following code into the
cell:
Next, add the code to download and extract the .zip file.
f_zip = 'http://archive.ics.uci.edu/ml/machine-learning-databases/00212/vertebral_column_data.zip'
r = requests.get(f_zip, stream=True)
Vertebral_zip = zipfile.ZipFile(io.BytesIO(r.content))
Vertebral_zip.extractall()
33.Run the code in the two cells by pressing SHIFT + ENTER. If you have
errors because of spelling errors, fix them now.
In the file viewer in the left navigation pane, you should see four new files:
- column_2C_weka.arff - column_2C.dat - column_3C_weka.arff -
column_3C.dat
34.Load the files into the main working window by clicking each file. Examine
the data in these files. What format is the data in? Does the data have
column headings?
35.You will now load the data from the two classes file. Switch back to your
notebook, select the empty cell, press ENTER, and enter the following
code:
data = arff.loadarff('column_2C_weka.arff')
df = pd.DataFrame(data[0])
df.head()
37.In the file browser in the left navigation, right-click the file that you want to
save, then choose Download.
38.Next, choose the location where you want to save your file on your local
computer.
39.If you want to continue working on the notebook, start the lab
environment again, create your notebook instance, and upload the
notebook you downloaded.
Conclusion
You now have successfully:
Lab complete
Congratulations! You have completed the lab.
40.To confirm that you want to end the lab, at the top of this page, choose
End Lab , and then choose Yes.
A panel should appear with this message: DELETE has been initiated... You may
close this message box now.
Objectives
After completing this lab, you will be able to:
Prerequisites
This lab requires:
Duration
This lab takes approximately 90 minutes. The lab will remain active for 180
minutes
2. Wait until you see the message Lab status: ready, then close the Start Lab
panel by choosing the X.
3. At the top of these instructions, choose AWS
This will open the AWS Management Console in a new browser tab. The
system will automatically log you in.
Tip: If a new browser tab does not open, there will typically be a banner or
icon at the top of your browser that indicates that your browser is
preventing the website from opening pop-up windows. Select the banner
or icon and then choose Allow pop ups.
To open JupyterLab:
8. In your JupyterLab environment, go to the file browser in the left pane and
locate the forecast-lab.ipynb file.
9. Open the en_us/forecast-lab.ipynb file by choosing it.
Conclusion
You now have successfully:
Lab complete
Congratulations! You have completed the lab.
11.To confirm that you want to end the lab, at the top of this page, choose
End Lab , and then choose Yes.
A panel should appear with this message: DELETE has been initiated... You may
close this message box now.
�2020 Amazon Web Services, Inc. and its affiliates. All rights reserved. This work may
not be reproduced or redistributed, in whole or in part, without prior written
permission from Amazon Web Services, Inc. Commercial copying, lending, or selling is
prohibited.
Guided Lab: Natural Language
Processing
Lab overview
Natural language processing (NLP) is a common use case for machine learning (ML).
In this lab, you will learn how to use Amazon Lex to create a chatbot that users can interact
with to create a dental appointment.
The high-level steps you will perform are:
Create and test a bot by using the Amazon Lex ScheduleAppointment blueprint
Create and test an AWS Lambda function to perform initiation, validation, and
fulfillment tasks
Configure the MakeAppointment intent to use your Lambda function as a code hook
Test the bot in the console and through a static webpage that is hosted on Amazon
Simple Storage Service (Amazon S3)
Objectives
After completing this lab, you will be able to:
Create and test a bot by using Amazon Lex
Create a Lambda function and configure it to work with Amazon Lex
Create a static webpage in Amazon S3 to host the bot
Interact with the bot in the webpage
Prerequisites
This lab requires:
Access to a notebook computer with Wi-Fi and Microsoft Windows, macOS, or Linux
(Ubuntu, SUSE, or Red Hat)
For Microsoft Windows users: Administrator access to the computer
An internet browser such as Chrome, Firefox, or IE9 (previous versions of Internet
Explorer are not supported)
Duration
This lab requires 60 minutes to complete. The lab will remain active for 180 minutes.
Scenario summary
The following diagram illustrates the environment that you will build in this lab:
88. In the Resource part of the policy, edit the value of the Amazon Resource Name
(ARN) by replacing example.com with the name of your bucket.
89. Choose Save changes. You will get a warning that the bucket has public access.
90. Choose the Properties tab.
91. Scroll down to the Static website hosting section.
92. At the bottom of the Static website hosting section, choose the URL.
Your webpage opens, and you can interact with your bot like you did in the AWS
Management Console.
Conclusion
You now have successfully created a bot with Amazon Lex and tested it in a webpage.
Lab complete
Congratulations! You have completed the lab.
93. To confirm that you want to end the lab, at the top of this page, choose End Lab , and
then choose Yes
A panel should appear with this message: DELETE has been initiated... You may close this
message box now.
94. To close the panel, choose the X in the top-right corner.
©2020 Amazon Web Services, Inc. and its affiliates. All rights reserved. This work may not
be reproduced or redistributed, in whole or in part, without prior written permission from
Amazon Web Services, Inc. Commercial copying, lending, or selling is prohibited.