How To Setup Your Machine Learning Sandbox Environment
This post is about how to setup your Machine Learning sandbox environment. For my Machine Learning students , it is important their environment is setup before our first session.
I would like every Oracle professional to be cross trained in Machine Learning, to the extent they can confidently create and deploy both anomaly detection and poor performance prediction systems. Getting their environment setup, is critical for a good start!
But you don't have to be in one of my Machine Learning classes to benefit from this post. As a free OraPub member, you have access to all my conference presentations. You can download and literally copy/paste the associated Python demonstrations into this Sandbox environment. Some of my Machine Learning presentations include video demonstrations, Python code and Jupyter Notebooks.
So, here we go!
Anaconda? What Is That?
The Anaconda Distribution is the tool of choice for solo data scientists who want to use Python or R for scientific computing projects. It's free, includes documentation, includes most of the ML libraries, has useful ML links and more.
Installing Anaconda is the quickest sure-fire way to get Python for Machine Learning up and running with zero defects!
By installing Anaconda, Python is also installed along with most of the libraries we will need.
Here are the steps:
1. Download Anaconda
Go to, https://www.anaconda.com
Then following these steps:
- Click "download" (upper right)
- Click your OS icon, which is half way down the page. It will look something like this:
- Click the most recent version of Python to begin the download.
2. Install Anaconda
After the download, open/start the download file. Follow the prompts and BAMB! It's installed!
You do NOT need to launch/start Anaconda to use Python or the associated Machine Learning libraries. But to link to the associated Anaconda resources, then of course, you will need to launch it. It looks like this:
3. Confirm Anaconda Installation
Confim installation by opening a terminal and entering these two commands:
conda -V python -V
4. Update Anaconda
If you want, update your environment (Anaconda and the Python Machine Learning libraries) by opening a terminal and entering these two commands:
conda update conda conda update anaconda
The update interface is similar to updating a Linux environment with either yum or update.
5. Start Python
You can use Python directly from its command line or through a Notebook. In the next section, I will introduce Jupyter Notebooks, which is what I currently use in my Machine Learning classes.
From the command line, you start Python by opening a terminal and entering this command (shocking I know):
6. Jupyter Notebooks
Most of my Machine Learning work occurs in what is called a "notebook." Notebooks are a phenomenal learning environment.
Currently, the most popular notebook for Machine Learning with Python is Jupyter. There is a lot more that can be said about Notebooks... but that's for another time.
Anaconda already has Jupyter installed! So, let's get started!
Here are the steps to get your Machine Learning sandbox environment ready using Jupyter notebooks:
7. Download Our Sandbox Notebook
Download the jupyter notebook from, http://filebank.orapub.com/LVC/S0-ML-Main.ipynb and save it to your desktop.
8. Start Jupyter On Your Desktop
To run the notebook, we need to start Jupyter running on your desktop in the background. To start Jupyter, run the following command at the Terminal (Mac/Linux) or Command Prompt (Windows):
A browser window should quickly pop-up and you'll see something like this.
9. Open The Sandbox Notepad
In Jupyter, find the S0-ML-Main.ipynb notebook and click to open it. The notebook will open in a new browser tab.
10. Working With The Sandbox Notepad
In the notebook, locate and click the "hello new world" input cell/box. Now, press both the SHIFT and ENTER keys to evaluate this cell. In the notebook, you should see, hello new world.
Notice in the screenshot below, you can see the "hello new world" below the input cell.
In the notebook input cell, change "hello new world" to something else and then press both the SHIFT and ENTER keys to evaluate the line. You can also press the ">Run" button.
Here is an example:
Insert a new cell
- Click in the "hello new world" input cell again
- Up near the "File" tab, locate and click on the "+" (plus sign) or Click on "Insert" > "Insert Cell Below"
Enter into the new input cell the below two lines,
- To evaluate the cell, press both the SHIFT and ENTER keys or the ">Run" button. To evaluate the entire notebook, click "Cell" > "Run All"
- After evaluating the cell, here is an example of what you should see:
Comment and code lines
Click on one of the comment lines. On the button line, on the far right, notice the dropdown shows Markdown. Markdown is a text-based markup langage. There are many Markdown cheatsheets available for download or reference. Just do a Google search for, markdown cheatsheet.
For my Jupyter notebook work, I use only code and Markdown.
To save and/or exit the Notepad
- Save your work by clicking the floppy disk icon below the File tab.
- Exit by closing your browser tab or clicking "File" > "Close and Halt"
Work through the notebook
Work through the remaining parts of the notebook, evaluating along the way. The objective is to learn a little bit (a very small bit) about both Jupyter Notebooks and Python. In the final input cell, you will notice a long list of libraries. I discuss this in the next section.
11. Load The Machine Learning Libraries
In last cell/section of the Sandbox Notepad, you will see list of some of the Python ML libraries I use in my Machine Learning classes.
The last cell will look something like this, but without the Done. in the cell below.
Evaluate (sometimes called, run) the cell. If all goes well (and it should), then Done. will be printed.
Most of the libraries have already been loaded via Anaconda, but some may not have been. If they have not been loaded and you have an internet connection, the library should automatically be downloaded.
If there is an error, simply do some Google searching along with the error. I have never met anyone who was not able to get all these libraries loaded.
Once you have successfully completed the above, your basic Machine Learning sandbox environment will be setup. You are now ready to enter into the amazing world of Machine Learning!
Have fun! Lots of fun! Machine Learning a strange and fascinating world, allowing us to do analysis like never before.
Cross Training In Machine Learning?
If you are an Oracle Professional and interesting being cross trained in Machine Learning, take a look at the OraPub Training Page. As you might expect, I cross train IT and Oracle Professionals how to use Machine Learning in their environments for things like monitoring, analysis and alerting.
All the best in your Oracle tuning and Machine Learning work,
Start my FREE 18 lesson Machine Learning For Oracle Professionals E-Course here.
Craig Shallahamer is a long time Oracle DBA who specializes in predictive analytics, machine learning and Oracle performance tuning. Craig is a performance researcher and blogger, consultant, author of two books, an enthusiastic conference speaker a passionate teacher and an Oracle ACE Director. More about Craig Shallahamer...
If you have any questions or comments, feel free to email me directly at craig at orapub.com.
|Are Oracle Direct Path Reads Faster Than DB File Scattered Reads?||Altering Oracle Database Insert Commit Batch Size-Part1||Is It OK To Be An Oracle Database Tuning Heretic?|