Machine learning is fast becoming an integral part of enterprise applications and a core competency for enterprises. A basic machine-learning workflow involves collecting, preparing, and curating data, followed by building, training, evaluating, and deploying models by using different machine-learning algorithms, which you can then use to make predictions.
This post focuses on the model development part of the workflow. A rich ecosystem of open source software and managed offerings are available, and I've picked some popular open source offerings to build an example workbench. Using this workbench, you can start coding and building models. I don't cover model development in depth, but I present one example to show how to use the workbench.
Python and R are commonly used languages for machine learning. I use Python 3 here because it supports a robust set of popular machine-learning frameworks, libraries, and packages, such as TensorFlow, scikit-learn, Matplotlib, SciPy, NumPy, Keras, and pandas.
Notebooks like Jupyter and Apache Zeppelin provide integrated environments that incorporate results, visualizations, and documentation inline with code, providing an excellent workbench for data scientists, machine-learning engineers, and other stakeholders to develop, visualize, and share their work.
I show the steps to set up a basic, cloud native, machine-learning workbench from scratch on Oracle Cloud Infrastructure by using Python 3, TensorFlow, and Jupyter Notebook. I use an Oracle Cloud Infrastructure bare metal instance running Oracle Linux. Let’s get started.
Follow the steps in the documentation to launch a bare metal instance in Oracle Cloud Infrastructure. I made the following choices:
Use SSH to connect to the instance:
$ ssh –i <path_to_your_private_key> opc@<public_IP_address_of_your_instance>
I used Oracle Linux and a bare metal shape, but you can make other choices. These steps should work for the most part, regardless of your choices, although some commands will change based on the OS, and you need to use the right libraries for your instance shape.
By default, Oracle Linux 7 comes with Python 2.7. You can continue to use that, but I'm going to show you how to use Python 3. To install Python 3, following these steps:
Install the EPEL repository:
[opc@ml-workbench ~]$ sudo yum install -y oracle-epel-release-el7 oracle-release-el7
Install Python 3.6:
[opc@ml-workbench ~]$ sudo yum install -y python36
Set up a Python virtual environment (venv), called mlenv here:
[opc@ml-workbench ~]$ python3.6 -m venv mlenv
Activate the virtual environment:
[opc@ml-workbench ~]$ source mlenv/bin/activate
Using pip3, you can install some of the commonly used Python libraries like scikit-learn, Keras, NumPy, Matplotlib, pandas, and SciPy.
Pick the correct TensorFlow package to use. Based on my choices, I can install TensorFlow by using the following command:
(mlenv) [opc@ml-workbench ~]$ pip3 install tensorflow
(mlenv) [ml-workbench ~]$ python3 -m pip install jupyter
Run a Jupyter notebook:
(mlenv) [opc@ ml-workbench ~]$ jupyter notebook --ip=0.0.0.0
You will see a warning such as No web browser found: could not locate runnable browser.
Open another terminal window, and use the following command with an available port number to access the notebook:
$ ssh –i <path_to_ your_private_key> opc@<public_IP_address_of_your_instance> -L 8000:localhost:8888
Open a web browser on your local machine and browse to http://localhost:8000.
When you are prompted for a token, use the token key listed in your previous terminal window to log in to the Jupyter notebook.
Click the New button to create a new Python 3 notebook. You can also upload existing IPython notebooks. Following is an example from a TensorFlow tutorial for a basic image classifier:
In this post, I set up a machine learning workbench with an Oracle Cloud Infrastructure bare metal instance running Oracle Linux. I used TensorFlow, a popular open source, machine-learning framework, and I described how to install and use Python 3 and Jupyter notebooks, which make it easy to build, train, and deploy models using Python. You can follow similar steps to install other languages, tools, and frameworks in the rapidly evolving machine-learning ecosystem. If you don’t have an Oracle Cloud account, you can sign up for a free account and get a $300 credit to start building.