Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hands-On Lab using Oracle Machine Learning Services on Autonomous Database

Hands-On Lab using Oracle Machine Learning Services on Autonomous Database

In this Hands on Lab users experienced the use of Oracle Machine Learning Services on Oracle Autonomous Database.

OML Services extends OML functionality to support model deployment and model lifecycle management for both in-database OML models and third-party Open Neural Networks Exchange (ONNX) machine learning models via REST APIs.

The REST API for Oracle Machine Learning Services provides REST API endpoints hosted on Oracle Autonomous Database. These endpoints enable the storage of machine learning models along with its metadata, and the creation of scoring endpoints for the model.

These third-party classification or regression models can be built using tools that support the ONNX format, which includes packages like Scikit-learn and TensorFlow, among several others.

In addition, OML Services supports proprietary cognitive text capabilities, with capabilities for topic discovery, keywords, summary, sentiment, and feature extraction. The initial languages supported include English, Spanish, and French (based on a Wikipedia knowledgebase using embeddings).

OML Services cognitive image functionality, supported through the ONNX format third-party model deployment feature, supports scoring using images or tensors.

Marcos Arancibia

May 18, 2021
Tweet

More Decks by Marcos Arancibia

Other Decks in Technology

Transcript

  1. Oracle Machine Learning Office Hours Hands-on-Lab: OML Services OML Rest

    API for model deployment and management with Marcos Arancibia, Sherry LaMonica & Mark Hornick Product Management, Oracle Machine Learning oracle.com/machine-learning May 2021
  2. • Test drive the new Oracle Machine Learning Services available

    with Oracle Autonomous Database • Explore different aspects of Model Deployment with in-database machine learning models as well as models in ONNX format, through a REST API • Build models with OML AutoML UI and deploy them directly to OML Services • Learn about possible integrations with other Oracle Cloud Applications Goals Copyright © 2021, Oracle and/or its affiliates 2
  3. • The main objective of this 90-minute Hands-on-Lab Session is

    to get you familiar with OML Services, to become self-sufficient with the Live Labs environment, and show many of the OML Services capabilities • These labs focus on the OML Services REST APIs, but other OML components will be used to produce and register models. • This series of labs is not intended as an introduction to machine learning or details of specific algorithms • To learn more about Machine Learning concepts, check out our recorded OML Office Hours ML 101/102 sessions at https://asktom.oracle.com/pls/apex/asktom.search?oh=6801 Setting expectations Copyright © 2021, Oracle and/or its affiliates 3
  4. • Accessing your Live Labs instance • Introduction to OML

    Services • Lab overview • Work through the labs • Q&A throughout Agenda Copyright © 2021, Oracle and/or its affiliates 4
  5. • Marcos Arancibia – Instructor • Mark Hornick– Expert •

    Sherry LaMonica – Expert Hands-on lab experts Need lab help? Input your questions into the Chat to the Panelists Have questions? Input your questions into the Q&A Please let us know if you have any problems All Links will be distributed via the Chat window
  6. If you ran any Hands-on-Lab session earlier today with a

    Live Labs reservation that is still running (with status "Available"), you need to delete it before joining a new one. Copyright © 2021, Oracle and/or its affiliates 7 Go to LiveLabs "My Reservations" and login with your Oracle Account at: https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/my-reservations Click on the Trashcan icon to delete the Running reservation, and confirm you want to Delete it Note: If you try to run this LiveLabs while you have another one running (in Available state), you will get an error
  7. Browse to the address below (in Firefox or Google Chrome),

    and click on the "Reserve Workshop on LiveLabs" (Green Button): Copyright © 2021, Oracle and/or its affiliates 8 https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?wid=786
  8. If you do not have a free Oracle.com account, you

    will be required to create one now. It is fast and free. Copyright © 2021, Oracle and/or its affiliates 9
  9. Now that you have an Account, let's sign in! Copyright

    © 2021, Oracle and/or its affiliates 10 [email protected] PasswordJustGiven
  10. In the Main Window, let's Submit a Reservation request Copyright

    © 2021, Oracle and/or its affiliates 11 Make sure "Start Workshop Now" is ON Check the box and "Submit Reservation"
  11. If you click on "View Your Reservations", you can see

    the specific one for OML4Py Workshop. Keep refreshing the page to get an actual update. Copyright © 2021, Oracle and/or its affiliates 12 This is your timer. It will take approximately 20 minutes for the environment to be ready, however actual time may be shorter
  12. Oracle Machine Learning OML Services OML4SQL OML4Py OML4R OML Notebooks

    OML4Spark Oracle Data Miner OML AutoML UI Interfaces for 3 popular data science languages: SQL, R, and Python Collaborative notebook environment based on Apache Zeppelin with Autonomous Database SQL Developer extension to create, schedule, and deploy ML solutions through a drag-and-drop interface ML for the big data environment from R with scalable algorithms Code-free AutoML interface on Autonomous Database Model Deployment and Management, Cognitive Text Copyright © 2021, Oracle and/or its affiliates 14
  13. Oracle Machine Learning Key Attributes Automated Get better results faster

    with less effort – even non-expert users Scalable Handle big data volumes using parallel, distributed algorithms – no data movement Production-ready Deploy and update data science solutions faster with integrated ML platform Increase productivity, Achieve enterprise goals, Innovate more Copyright © 2021, Oracle and/or its affiliates 15
  14. Oracle Machine Learning Key Attributes Automated Get better results faster

    with less effort – even non-expert users Scalable Handle big data volumes using parallel, distributed algorithms – no data movement Production-ready Deploy and update data science solutions faster with integrated ML platform Increase productivity, Achieve enterprise goals, Innovate more Copyright © 2021, Oracle and/or its affiliates 16
  15. OML Services extends OML functionality to support model deployment and

    model lifecycle management for both in-database OML models and third-party Open Neural Networks Exchange (ONNX) machine learning models via REST APIs. The REST API for Oracle Machine Learning Services on Oracle Autonomous Database provides: • Endpoints that enable the storing machine learning models along with its metadata • Creation of scoring endpoints for the registered models. • Support for classification and regression of third-party models in ONNX format, including from packages like Scikit-learn and TensorFlow, among several others. • Proprietary cognitive text capabilities in English, French and Spanish for topic discovery, keywords, summary, sentiment, and feature extraction, based on a Wikipedia knowledge base using Embeddings. • Cognitive image functionality, supported through the ONNX format third-party model deployment feature, with the ability to score using images or tensors. Oracle Machine Learning Services overview Copyright © 2021, Oracle and/or its affiliates 17
  16. 18 Connectivity and use from Client Oracle Machine Learning Services

    architecture REST Client user/pass GET Token Token + Actions & Text/Objects GET POST DELETE Oracle Autonomous Database /omlusers PDB /omlmod OML Services Copyright © 2021, Oracle and/or its affiliates
  17. Components with built-in Oracle Machine Learning Admin • Token using

    ADB user and password Generic • Metadata for all Versions: Version 1 Metadata • Open API Specification Deployment • Create Model Endpoint • Score Model using Endpoint • Endpoints • Endpoint Details • Open API Specification for Endpoint • Endpoint Repository • Store Model • Update Model Namespace • Models list • Model Info • Model Metadata • Model Content • Model Cognitive Text • Get Most Relevant Topics • Get Most Relevant Keywords • Get Summaries • Get Sentiments • Get Semantic Similarities • Numeric Features • Get Endpoints Oracle Machine Learning Services - Methods GET POST DELETE GET POST DELETE GET POST GET POST Copyright © 2021, Oracle and/or its affiliates 19
  18. 21 Copyright © 2021, Oracle and/or its affiliates Lab high-level

    outline Lab 1: Installation and configuration of Postman client for REST API Lab 2: Getting the Token for Authorization of OML Services REST requests Lab 3: Registering and Scoring with Oracle Machine Learning models Lab 4: Registering and Scoring with ML models in ONNX format Lab 5: Registering and Scoring with Image Classification models in ONNX format Lab 6: Using OML Services Cognitive Text REST APIs
  19. Copyright © 2021, Oracle and/or its affiliates 22 Lab 1:

    Installation and configuration of Postman client for REST API Installing the Desktop client Application to test the REST API collections
  20. On your browser, go to https://www.postman.com/downloads/ , and click on

    the Orange Button to "Download the App" Copyright © 2021, Oracle and/or its affiliates 23 For Microsoft Windows For MacOS For Linux
  21. As an example, in the MacOS it will download a

    ZIP file. Extract the zip file with a double-click, and the Postman.app will be uncompressed Copyright © 2021, Oracle and/or its affiliates 24 Download it On Mac OS, double click to Extract the App. On Windows you can run the Installer ".exe" On Mac OS, you can Drag the "Postman.app" to the Applications folder
  22. Launch Postman on your Desktop Copyright © 2021, Oracle and/or

    its affiliates 25 For this Hands-on-Lab, we will NOT need to create an Account with Postman, so you can click on "Skip and go to the app" on either the MacOS or Windows version
  23. First step is to Import the Collections and Environment that

    will be distributed via a link: oracle.com/a/tech/docs/otn-batch1/oml-services-hol-postman-collections.zip Launch Postman on your Desktop Copyright © 2021, Oracle and/or its affiliates 26 After downloading the files: 1 - Unzip the 7 JSON files 2 - Click on the "Import Button"
  24. You can just drag and drop the Postman collection JSON

    files you unzipped into the Window Import the OML Services HOL Postman collections Copyright © 2021, Oracle and/or its affiliates 27 Drag the 7 files from your File Manager into the area indicated in Postman
  25. You can just drag and drop the Postman collection JSON

    files you unzipped into the Window Import the OML Services HOL Postman collections Copyright © 2021, Oracle and/or its affiliates 28 Confirm you have 6 Collections and 1 Environment file, and click "Import"
  26. Verify that you have the 6 collections on the Collections

    section Let's check that we have the collections imported Copyright © 2021, Oracle and/or its affiliates 29 Confirm you have 6 the Collections in the "Collections" Tab You can close this Yellow Notice too by clicking the "x"
  27. Contact us via "Chat to the Panelists" if your environment

    is not ready yet, of if you have problems Quick check on the environment readiness Copyright © 2021, Oracle and/or its affiliates 30 Have you received the email indicating that your LiveLab environment is ready to use?
  28. Check your Inbox for the e-mail from [email protected] Copyright ©

    2021, Oracle and/or its affiliates 31 Make sure it says that the environment is ready! You can click here to go to the My Reservations page, or just refresh the page you have open at: https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/my-reservations
  29. In the "My Reservations" window (refresh the page periodically), after

    around 20 minutes, the Status will change to Available. Click on "Launch Workshop" to open this window. Copyright © 2021, Oracle and/or its affiliates 32
  30. If your Live Labs Session was created in Montreal under

    the Tenancy c4u04, all you have to do is to enter your Database Name and put it in here: Now let's setup the Postman Environment to your specific Live Labs Copyright © 2021, Oracle and/or its affiliates 33 1. Click on the "Environments" Tab, then select the "OML Services LiveLabs" 2. All we need to do is to copy the "Database Name" assigned to you from the Workshop UI into the Current value of "database", then Save it.
  31. Click the pull-down menu to select your environment, otherwise you

    will get http errors. Back to the main Collection Tab, don't forget to select your Environment Copyright © 2021, Oracle and/or its affiliates 34 1. Click on the "Collections" Tab to go back to the main section for the Demo 2. Click on the pull-down menu next to the "No Environment" text, and select the "OML Services LiveLabs" environment settings
  32. In case you have a different Data Center or want

    to use your own Tenancy, here are the settings for all OML Services endpoints The main REST URL for Oracle Autonomous Database, where the OML Services endpoints exist, looks like the following: omlserver/omlmod/v1/ (for version 1) And to obtain a token to access OML Services you need to request a Token with a valid ADB user and password, from the OML request endpoint at: omlserver/omlusers/tenants/tenant/databases/database where: • omlserver = OML Services server for your Autonomous Database, for example, for Ashburn: https://adb.us-ashburn-1.oraclecloud.com • tenant = Oracle Cloud Tenancy OCID (not to be confused with the ADB OCID), in the form of: OCID1.TENANCY.OC1..AAAAAAAAFCUE47PQMRF4VIG…… • database = Oracle Autonomous Database PDB name (or database name), for example: ADW3900 If your Tenancy is not c4u04, or your Data Center is not Montreal Copyright © 2021, Oracle and/or its affiliates 35
  33. Copyright © 2021, Oracle and/or its affiliates 36 Lab 2:

    Getting the Token for Authorization of OML Services REST requests
  34. Initial call to get a Token and be able to

    access all other OML Services endpoints Request a Token To request a Token for accessing all other OML Services endpoints, you need a valid user and password for your Oracle Autonomous Database that has the proper grants as an OML Developer from the OML Administrator. For the following REST call, we will consider: omlserver/omlusers/tenants/tenant/databases/database = ADB_URL $ curl –I \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ –d '{"grant_type":"password", "username": "YourOMLuser", "password": "YourOMLpass"}'\ "ADB_URL/api/oauth2/v1/token" 1.1 OML Services – Request a Token POST Copyright © 2021, Oracle and/or its affiliates 37
  35. Initial call to get a Token and be able to

    access all other OML Services endpoints Request a Token To request a Token for accessing all other OML Services endpoints, you need a valid user and password for your Oracle Autonomous Database that has the proper grants as an OML Developer from the OML Administrator, usually created by the OMLADMIN 1.1 OML Services – Request a Token POST Copyright © 2021, Oracle and/or its affiliates 38
  36. Call to get the basic Metadata Description for the current

    OML Services Metadata Description To review the basic description of the metadata for the current REST end points for OML Services, you need to pass a valid Token. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.....==' 2.1 OML Services – Metadata Description GET This is the token Copyright © 2021, Oracle and/or its affiliates 39
  37. Call to get the basic Metadata Description for the current

    OML Services Metadata Description Get the basic description of the Metadata for the available End Points from the OML Services REST service 2.1 OML Services – Metadata Description GET Copyright © 2021, Oracle and/or its affiliates 40
  38. Call to get the Open API description for the current

    OML Services Open API description To review the Open API specification for the OML Services REST end points, you need to pass a valid Token. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/api' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.....==' 2.2 OML Services – Open API description GET This is the token Copyright © 2021, Oracle and/or its affiliates 41
  39. Call to get the Open API description for the current

    OML Services Open API description To review the Open API specification for the OML Services REST end points, you need to pass a valid Token into the following GET request: 2.2 OML Services – Metadata Description GET Copyright © 2021, Oracle and/or its affiliates 42
  40. Copyright © 2021, Oracle and/or its affiliates 43 Lab 3:

    Registering and Scoring with Oracle Machine Learning models
  41. Call to store a serialized OML model to the OML

    Services model repository Store OML model To store a serialized OML model object into the OML Services repository, you need to pass a valid Token, and in the body pass the name, version, modelType='OML', whether is going to be a shared model, the serialized OML model file (usually with a .mod extension), and optionally a namespace for organizing models into groups. The result is a unique model ID. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --form 'modelName=OML_Insurance_Affinity' \ --form 'modelType=OML' \ --form 'version=1.4' \ --form 'shared=true' \ --form 'modelData=@/Users/MyUser/MyModels/omlModel.mod' \ --form 'namespace=OML_MODELS' 3.3 OML Services – Repository - Store OML model POST Copyright © 2021, Oracle and/or its affiliates 44
  42. Download the file in the following link and unzip it

    in your computer oracle.com/a/tech/docs/otn-batch1/oml-services-hol-models.zip 3.3 First we will download a second ZIP file with the models we will use Copyright © 2021, Oracle and/or its affiliates 45 1. In Section 3, Go to item 3.3 and check the "Body" of the message 2. Click on "Select Files" button, and select the model file you just unzipped named "3.3_OML_Model.mod"
  43. Call to store a serialized OML model to the OML

    Services model repository Store OML model To store a serialized OML model object into the OML Services repository, you need to pass a valid Token, and in the body pass the name, version, modelType='OML', whether is going to be a shared model, the serialized OML model file (usually with a .mod extension), and optionally a namespace for organizing models into groups. The result is a unique model ID. 3.3 OML Services – Repository - Store OML model POST Copyright © 2021, Oracle and/or its affiliates 46
  44. Call to list all the Models currently registered in OML

    Services repository Call the REST endpoint to check all current registered models By passing a valid token to this REST API, OML Services will return a list of all models currently available to the user (and any shared models). These models have not necessarily been deployed as REST Endpoints, but they are stored in the repository. The result is a JSON with a list of the Models with a lot of metadata about the models For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' 3.1 OML Services – Repository – List Models registered in OML Services Copyright © 2021, Oracle and/or its affiliates 47 GET
  45. Call to list all the Models currently registered in OML

    Services repository Call the REST endpoint to check all current registered models By passing a valid token to this REST API, OML Services will return a list of all models currently available to the user (and any shared models). These models have not necessarily been deployed as REST Endpoints, but they are stored in the repository. The result is a JSON with a list of the Models with a lot of metadata about the models 3.1 OML Services – Repository – List Models registered in OML Services Copyright © 2021, Oracle and/or its affiliates 48 GET
  46. Call to create a Rest Endpoint for an OML model

    stored in the OML Services repository Create REST endpoint for OML model To create a Rest Endpoint for an OML model object into the OML Services repository, you need to pass a valid Token, and pass as data-raw the "model ID" of an existing OML Model, and the desired "model URI" to host the model. The result is the HTTP Reference for the Model URI. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --data-raw '{"modelId":"b93af335-bc5b-4f2b-92ef-fd9af5fc933c", \ "uri":"Affinity_Insurance_URI"}' 3.8 OML Services – Repository – Create Rest Endpoint – OML models POST Copyright © 2021, Oracle and/or its affiliates 49
  47. Call to create a Rest Endpoint for an OML model

    stored in the OML Services repository Create REST endpoint for OML model To create a Rest Endpoint for an OML model object into the OML Services repository, you need to pass a valid Token, and pass as data-raw the "model ID" of an existing OML Model, and the desired "model URI" to host the model. The result is the HTTP Reference for the Model URI. 3.8 OML Services – Repository – Create REST Endpoint - OML models POST Copyright © 2021, Oracle and/or its affiliates 50
  48. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/deployment' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' 3.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 51 GET
  49. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model 3.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 52 GET
  50. Call to score a record of data using an existing

    Scoring Endpoint uri in OML Services Call the REST endpoint to use a scoring endpoint uri to get the prediction on data By passing a valid token to this REST API, plus passing the data columns in the "data-raw" section, OML Services will return the result of the model scoring on the data sent. Multiple records can be sent in a Mini- batch as well. Additionally, for OML Models, you can also request the Prediction Details to be returned using the "topNdetails" optional setting. The result is a JSON with a the result of the numeric scoring and/or labels and probabilities (in case of classification models), plus any additional information requested, like the Prediction Details (optional). For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/deployment/MyOMLModelURI/score' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --data-raw '{"topNdetails":5, \ "inputRecords": [ [ {"AGE":41, "BOOKKEEPING_APPLICATION": 1, "CUST_GENDER":"M", "CUST_MARITAL_STATUS":"NeverM", \ "EDUCATION":"HS-grad", "HOME_THEATER_PACKAGE":1, "HOUSEHOLD_SIZE":"4", "OCCUPATION":"Crafts", \ "YRS_RESIDENCE":6, "Y_BOX_GAMES":1 } ] }' 3.13 OML Services – Deployment – Scoring an OML Model in OML Services Copyright © 2021, Oracle and/or its affiliates 53 POST
  51. Call to score a record of data using an existing

    Scoring Endpoint uri in OML Services Call the REST endpoint to use a scoring endpoint uri to get the prediction on data By passing a valid token to this REST API, plus passing the data columns in the "data-raw" section, OML Services will return the result of the model scoring on the data sent. Multiple records can be sent in a Mini-batch as well. Additionally, for OML Models, you can also request the Prediction Details to be returned using the "topNdetails" optional setting. The result is a JSON with a the result of the numeric scoring and/or labels and probabilities (in case of classification models), plus any additional information requested, like the Prediction Details (optional). 3.13 OML Services – Deployment – Scoring an OML Model in OML Services Copyright © 2021, Oracle and/or its affiliates 54 POST
  52. Call to score a record of data using an existing

    Scoring Endpoint uri in OML Services Example 3.14 Scoring an OML Model with data in a mini-batch (two records in this example) Example 3.19 Scoring an OML Model with data in a mini-batch (two records in this example) & Prediction Details 3.14 OML Services – Deployment – Scoring an OML Model in OML Services Copyright © 2021, Oracle and/or its affiliates 55 POST
  53. Copyright © 2021, Oracle and/or its affiliates 56 Lab 3:

    Bonus round: Registering a model to Oracle Machine Learning models from OML AutoML UI
  54. For this, we need to use the information and links

    in the Workshop page We will need to get to the OML AutoML UI Copyright © 2021, Oracle and/or its affiliates 57
  55. For this Bonus Round we will need to get to

    the OML AutoML UI: In the "My Reservations" window at: https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/my-reservations Click on "Launch Workshop", then "Launch Console". You will need to use the Initial Password. Copyright © 2021, Oracle and/or its affiliates 58 1. We will need this password next, so you should copy it 2. Launch the Console (the login will contain your Username LLXXXX- USER)
  56. In the Single Sign-On screen, enter the Password given in

    the Workshop screen for your user LL####-USER. You will need to change the Password (you can use the same), then click on the Hamburger Menu on the Top left of OCI, then Autonomous Database. Copyright © 2021, Oracle and/or its affiliates 59 1. Click the Hamburger Menu 2. Click on Autonomous Database Important note: remember to sign-out of all other OCI Account Tabs you might have open
  57. Select the specific ADW Compartment indicated in the Workshop Main

    screen, and then click on the Autonomous Database Copyright © 2021, Oracle and/or its affiliates 60 2. Click on the Autonomous Database Name assigned to you 1. Click and select the Compartment associated with your Account
  58. Once inside the Autonomous Database, click on "Service Console". In

    there, select "Development" and then click on "Oracle Machine Learning Notebooks" Copyright © 2021, Oracle and/or its affiliates 61 1. Click on the Service Console 2. Click on Development 3. Click on OML Notebooks
  59. In the Sign-In screen of OML Notebooks, use OMLUSER and

    the Password AAbbcc123456. Once you are in, click on the OML Notebooks link Copyright © 2021, Oracle and/or its affiliates 62 Click on AutoML Sign in with OMLUSER and the Password AAbbcc123456
  60. In the AutoML Experiments screen, click "Create" to create a

    new one Copyright © 2021, Oracle and/or its affiliates 63 1. Click on +Create 2. Give the Experiment a name 3. Click on the Loupe to search for a Data Source
  61. In the menu that appears, select the SH.SUPPLEMENTARY_DEMOGRAPHICS Copyright ©

    2021, Oracle and/or its affiliates 64 1. Click on the "SH" Schema 2. Select the "SUPPLEMENTARY_DEMOGRAPHICS" table and click the "OK" button
  62. In the Create Experiments screen, select Predict, Case ID, and

    adjust performance settings Copyright © 2021, Oracle and/or its affiliates 65 1. For the "Predict" attribute, select AFFINITY_CARD from the pull-down menu 2. For the "Case ID" attribute, select CUST_ID from the pull- down menu 3. Expand the "Additional Settings" and reduce the Maximum Top Models to "2" to save time in this exercise. 4. Change the "Database Service Level" to Medium to get increased parallelism
  63. We are ready to start the Experiment Click on the

    Start -> Faster Results Copyright © 2021, Oracle and/or its affiliates 66 1. Click on Start 2. Click on Faster Results to make sure we have a quick result for this Session
  64. Click on the three dots (…) to see the Progress

    Copyright © 2021, Oracle and/or its affiliates 67 1. Click on the three dots to open the Progress Report
  65. When the Experiment finishes, the models can be inspected Let's

    see how to deploy the models to OML Services from here. Copyright © 2021, Oracle and/or its affiliates 68 1. Click anywhere in the area around the Model to highlight the it (the whole row will become a shade of blue) 2. The Deploy button will be available. Click on it to get to the Deploy Model form.
  66. In the Deploy Model form, simply fill in the form

    with the fields like the one below and hit OK. The model will be saved and then immediately deployed Copyright © 2021, Oracle and/or its affiliates 69
  67. Check the Models menu to view User Models and Deployments

    Copyright © 2021, Oracle and/or its affiliates 70
  68. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model 3.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 72 GET
  69. Copyright © 2021, Oracle and/or its affiliates 73 Lab 4:

    Registering and Scoring with ML models in ONNX format
  70. Call to store a third-party ONNX model for classification or

    regression into OML Services repository Store ONNX model To store third-party ONNX model for classification or regression object into the OML Services repository, you need to pass a valid Token, and in the body pass the name, version, modelType='ONNX', whether is going to be a shared model, the zip file with the ONNX model and metadata, and optionally a namespace for organizing models into groups. The result is a unique model ID. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --form 'modelName=onnxTitanicModel' \ --form 'version=1.4' \ --form 'modelType=ONNX' \ --form 'shared=true' \ --form 'modelData=@/Users/MyUser/MyONNXModels/sk_cl_pipeline_titanic_onnx.zip' \ --form 'namespace=ONNX_MODELS' 4.3 OML Services – Repository - Store ONNX model POST Copyright © 2021, Oracle and/or its affiliates 74
  71. In the Body Section of the Collection item 4.3, load

    the modelData 4.3 We need to select the ONNX model to use from the files downloaded Copyright © 2021, Oracle and/or its affiliates 75 1. In Section 4, Go to item 4.3 and check the "Body" of the message 2. Click on "Select Files" button, and select the model file you just unzipped named "4.3_ONNX_ML_Pipeline.zip"
  72. Call to list all the Models currently registered in OML

    Services repository Call the REST endpoint to check all current registered models By passing a valid token to this REST API, OML Services will return a list of all models currently available to the user (and any shared models). These models have not necessarily been deployed as REST Endpoints, but they are stored in the repository. The result is a JSON with a list of the Models with a lot of metadata about the models For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' 4.1 OML Services – Repository – List Models registered in OML Services Copyright © 2021, Oracle and/or its affiliates 76 GET
  73. Call to list all the Models currently registered in OML

    Services repository Call the REST endpoint to check all current registered models By passing a valid token to this REST API, OML Services will return a list of all models currently available to the user (and any shared models). These models have not necessarily been deployed as REST Endpoints, but they are stored in the repository. The result is a JSON with a list of the Models with a lot of metadata about the models 4.1 OML Services – Repository – List Models registered in OML Services Copyright © 2021, Oracle and/or its affiliates 77 GET
  74. Call to store a third-party ONNX model for classification or

    regression into OML Services repository Store ONNX model To store third-party ONNX model for classification or regression object into the OML Services repository, you need to pass a valid Token, and in the body pass the name, version, modelType='ONNX', whether is going to be a shared model, the zip file with the ONNX model and metadata, and optionally a namespace for organizing models into groups. The result is a unique model ID. 4.3 OML Services – Repository - Store ONNX model POST Copyright © 2021, Oracle and/or its affiliates 78
  75. Call to create a Rest Endpoint for a third-party ONNX

    model for classification or regression stored in the OML Services repository Create REST endpoint for third-party ONNX classification or regression model To create a Rest Endpoint for a third-party ONNX classification or regression model that is stored in the OML Services repository, you need to pass a valid Token, and pass as data-raw the "model ID" of an existing ONNX Model, and the desired "model URI" to host the model. The result is the HTTP Reference for the Model URI. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --data-raw '{"modelId":"9ce5b797-27ea-4121-8fed-eb74f2e92a53", \ "uri":"onnxTitanicModeluri"}' 4.8 OML Services – Repository – Create REST Endpoint - ONNX models POST Copyright © 2021, Oracle and/or its affiliates 79
  76. Call to create a Rest Endpoint for a third-party ONNX

    model for classification or regression stored in the OML Services repository Create REST endpoint for third-party ONNX classification or regression model To create a Rest Endpoint for a third-party ONNX classification or regression model that is stored in the OML Services repository, you need to pass a valid Token, and pass as data-raw the "model ID" of an existing ONNX Model, and the desired "model URI" to host the model. The result is the HTTP Reference for the Model URI. 4.8 OML Services – Repository – Create REST Endpoint - ONNX models POST Copyright © 2021, Oracle and/or its affiliates 80
  77. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/deployment' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' 4.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 81 GET
  78. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model 4.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 82 GET
  79. Call to score a record of data using an existing

    Scoring Endpoint uri in OML Services Call the REST endpoint to use a scoring endpoint uri to get the prediction on data By passing a valid token to this REST API, plus passing the data columns in the "data-raw" section, OML Services will return the result of the model scoring on the data sent. Multiple records can be sent in a Mini- batch as well. The result is a JSON with a the result of the numeric scoring and/or labels and probabilities (in case of classification models). For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/deployment/MyONNXModelURI/score' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --data-raw'{ "inputRecords":[ { "pclass": [["3"]], "sex": [["male"]], "age": [["NaN"]], "fare": [[22.3583]], "embarked":[["C"]] } ] }' 4.13 OML Services – Deployment – Scoring an ONNX ML Model in OML Services Copyright © 2021, Oracle and/or its affiliates 83 POST
  80. Call to score a record of data using an existing

    Scoring Endpoint uri in OML Services Call the REST endpoint to use a scoring endpoint uri to get the prediction on data By passing a valid token to this REST API, plus passing the data columns in the "data-raw" section, OML Services will return the result of the model scoring on the data sent. Multiple records can be sent in a Mini-batch as well. The result is a JSON with a the result of the numeric scoring and/or labels and probabilities (in case of classification models). 4.13 OML Services – Deployment – Scoring an ONNX ML Model in OML Services Copyright © 2021, Oracle and/or its affiliates 84 POST
  81. Call to score a record of data using an existing

    Scoring Endpoint uri in OML Services Another example Scoring an ONNX Model with data in a mini- batch (two records in this example) Copyright © 2021, Oracle and/or its affiliates 85 POST 4.14 OML Services – Deployment – Scoring an ONNX ML Model in OML Services
  82. Copyright © 2021, Oracle and/or its affiliates 86 Lab 5:

    Registering and Scoring with Image Classification models in ONNX format
  83. Call to store a third-party ONNX Image model for classification

    into OML Services repository Store ONNX Image model To store third-party ONNX Image model for classification into the OML Services repository, you need to pass a valid Token, and in the body pass the name, version, modelType='ONNX_IMG', whether is going to be a shared model, the zip file with the ONNX Image model and metadata, and optionally a namespace for organizing models into groups. The result is a unique model ID. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --form 'modelName=efficientnetlite' \ --form 'version=1.1' \ --form 'modelType=ONNX_IMG' \ --form 'shared=True' \ --form 'modelData=@/Users/MyUser/MyONNX_IMGModels/efficient-lite4.zip' \ --form 'namespace=ONNX_IMG_MODELS' 5.3 OML Services – Repository - Store ONNX Image model POST Copyright © 2021, Oracle and/or its affiliates 87
  84. In the Body Section of the Collection item 5.3, load

    the modelData 5.3 We need to select the ONNX model to use from the files downloaded Copyright © 2021, Oracle and/or its affiliates 88 1. In Section 5, Go to item 5.3 and check the "Body" of the message 2. Click on "Select Files" button, and select the model file you just unzipped named "5.3_ONNX_Image_Class.zip"
  85. Call to store a third-party ONNX Image model for classification

    into OML Services repository Store ONNX Image model To store third-party ONNX Image models for classification into the OML Services repository, you need to pass a valid Token, and in the body pass the name, version, modelType='ONNX_IMG', whether is going to be a shared model, the zip file with the ONNX Image model and metadata, and optionally a namespace for organizing models into groups. The result is a unique model ID. 5.3 OML Services – Repository - Store ONNX Image model POST Copyright © 2021, Oracle and/or its affiliates 89
  86. Call to list all the Models currently registered in OML

    Services repository Call the REST endpoint to check all current registered models By passing a valid token to this REST API, OML Services will return a list of all models currently available to the user (and any shared models). These models have not necessarily been deployed as REST Endpoints, but they are stored in the repository. The result is a JSON with a list of the Models with a lot of metadata about the models For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' 5.1 OML Services – Repository – List Models registered in OML Services Copyright © 2021, Oracle and/or its affiliates 90 GET
  87. Call to list all the Models currently registered in OML

    Services repository Call the REST endpoint to check all current registered models By passing a valid token to this REST API, OML Services will return a list of all models currently available to the user (and any shared models). These models have not necessarily been deployed as REST Endpoints, but they are stored in the repository. The result is a JSON with a list of the Models with a lot of metadata about the models 5.1 OML Services – Repository – List Models registered in OML Services Copyright © 2021, Oracle and/or its affiliates 91 GET
  88. Call to create a Rest Endpoint for a third-party ONNX

    Image model for classification stored in the OML Services repository Create REST endpoint for third-party ONNX Image classification model To create a REST Endpoint for a third-party ONNX Image classification model that is stored in the OML Services repository, you need to pass a valid Token, and pass as data-raw the "model ID" of an existing ONNX Model, and the desired "model URI" to host the model. The result is the HTTP Reference for the Model URI. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/models' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --data-raw '{"modelId":"ae5e12a8-d859-4cdc-9a15-0ff42e3aa78f", \ "uri":"onnxIMGModeluri"}' 5.8 OML Services – Repository – Create REST Endpoint - ONNX Image models POST Copyright © 2021, Oracle and/or its affiliates 92
  89. Call to create a Rest Endpoint for a third-party ONNX

    Image model for classification stored in the OML Services repository Create REST endpoint for third-party ONNX Image classification model To create a REST Endpoint for a third-party ONNX Image classification model that is stored in the OML Services repository, you need to pass a valid Token, and pass as data-raw the "model ID" of an existing ONNX Model, and the desired "model URI" to host the model. The result is the HTTP Reference for the Model URI. 5.8 OML Services – Repository – Create REST Endpoint - ONNX Image models POST Copyright © 2021, Oracle and/or its affiliates 93
  90. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request GET 'OML_URL/deployment' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' 5.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 94 GET
  91. Call to list all the Scoring Endpoints currently active in

    OML Services repository Call the REST endpoint to check all current registered scoring endpoints By passing a valid token to this REST API, OML Services will return a list of all scoring endpoints currently available to the user (and any shared models). These models endpoints are the ones currently available for scoring. The result is a JSON with a list of the Scoring Endpoints with a lot of metadata about them and the uri of each model 5.11 OML Services – Repository – List Scoring Endpoints in OML Services Copyright © 2021, Oracle and/or its affiliates 95 GET
  92. Call to score an Image using an existing Scoring Endpoint

    uri in OML Services Call the REST endpoint to use a scoring endpoint uri to get the prediction on an image By passing a valid token to this REST API, plus passing the actual local image file (or tensors) in the "form" section, OML Services will return the result of the model scoring on the data sent. The result is a JSON with a the result of the labels and probabilities computed by the Image Classification model. NEW since April 2021 is the option topN that returns only the top "N" ranked labels For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/deployment/MyONNXImageModelURI/score' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --form 'imageData=@"/Users/Me/MyPictures/tiger-shark.jpg"' --form 'topN="3"' 5.13 OML Services – Deployment – Scoring an ONNX Image Model in OML Services Copyright © 2021, Oracle and/or its affiliates 96 POST
  93. Call to score an Image using an existing Scoring Endpoint

    uri in OML Services Call the REST endpoint to use a scoring endpoint uri to get the prediction on an image By passing a valid token to this REST API, plus passing the actual local image file (or tensors) in the "form" section, OML Services will return the result of the model scoring on the data sent. The result is a JSON with a the result of the labels and probabilities computed by the Image Classification model. The example on the right uses a Tiger Shark image for scoring without the new topN option. 5.13 OML Services – Deployment – Scoring an ONNX Image Model in OML Services Copyright © 2021, Oracle and/or its affiliates 97 POST
  94. Call to score an Image using an existing Scoring Endpoint

    uri in OML Services Another example Scoring an ONNX Image Classification Model with a Goldfish Image. The example on the right does not use the new topN option. 5.15 OML Services – Deployment – Scoring an ONNX Image Model in OML Services Copyright © 2021, Oracle and/or its affiliates 98 POST
  95. Copyright © 2021, Oracle and/or its affiliates 99 Lab 6:

    Using OML Services Cognitive Text REST APIs
  96. Call to score a Text using one of the pre-existing

    uri for Cognitive Text in OML Services Call the REST endpoint to use a scoring endpoint uri to access the Cognitive Text functions By passing a valid token to this REST API, plus passing the desired text in the "data-raw" section, OML Services will return keywords/summary/sentiment/similarity/features related to the text. You would reques the number of items to be returned by passing the "topN" option in the data-raw section. The result is a JSON with a the resulting keywords/summary/sentiment/similarity/features computed by OML Services using the built-in Wikipedia embeddings model. For the following REST call, we will consider: omlserver/omlmod/v1 = OML_URL , and remember to provide the full Token after "Bearer" $ curl --location --request POST 'OML_URL/cognitive-text/topics' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI.... ==' \ --data-raw '{ "topN":5, "textList":["With Oracle Machine Learning, Oracle moves the algorithms to the data. \ Oracle runs machine learning within the database, where the data reside. \ This approach minimizes or eliminates data movement, achieves scalability, \ preserves data security, and accelerates time-to-model deployment. "] \ }' 6. OML Services – Cognitive Text – Functions available in OML Services Copyright © 2021, Oracle and/or its affiliates 100 POST
  97. Call to score a Text using one of the pre-existing

    uri for Cognitive Text in OML Services Call the REST endpoint to use a scoring endpoint uri to access the Cognitive Text functions By passing a valid token to this REST API, plus passing the desired text in the "data- raw" section, OML Services will return keywords/summary/sentiment/similarity/f eatures related to the text. You would reques the number of items to be returned by passing the "topN" option in the data- raw section. The result is a JSON with a the resulting keywords/summary/sentiment/similarity/f eatures computed by OML Services using the built-in Wikipedia embeddings model. 6.2 OML Services – Cognitive Text – Functions available in OML Services Copyright © 2021, Oracle and/or its affiliates 101 POST
  98. Call to score a Text using one of the pre-existing

    uri for Cognitive Text in OML Services Example 6.13 Keywords in French Example 6.8 Keywords in Spanish 6. OML Services – Cognitive Text – Functions available in OML Services Copyright © 2021, Oracle and/or its affiliates 102 POST
  99. Call to score a Text using one of the pre-existing

    uri for Cognitive Text in OML Services Example 6.6 Similarity in English Example 6.3 Summary in English 6. OML Services – Cognitive Text – Functions available in OML Services Copyright © 2021, Oracle and/or its affiliates 103 POST
  100. Call to score a Text using one of the pre-existing

    uri for Cognitive Text in OML Services Example 6.4 Sentiment in English Example 6.7 Features in English (mapping of 1,000 weights) 6. OML Services – Cognitive Text – Functions available in OML Services Copyright © 2021, Oracle and/or its affiliates 104 POST
  101. For more information on OML Services Copyright © 2021, Oracle

    and/or its affiliates 106 Current Documentation available at: https://docs.oracle.com/en/cloud/paas/autonomous-data-warehouse-cloud/omlss/index.html
  102. Helpful Links 107 ORACLE MACHINE LEARNING ON O.COM https://www.oracle.com/machine-learning OML

    TUTORIALS OML LiveLab: https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?p180_id=560 OML4Py LiveLab: https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?wid=786 Interactive tour: https://docs.oracle.com/en/cloud/paas/autonomous-database/oml-tour OML OFFICE HOURS https://asktom.oracle.com/pls/apex/asktom.search?office=6801#sessionss ORACLE ANALYTICS CLOUD https://www.oracle.com/solutions/business-analytics/data-visualization/examples.html OML4PY ORACLE AUTOML UI OML SERVICES Oracle Machine Learning AutoML UI (2m video) Oracle Machine Learning Demonstration (6m video) OML AutoML UI Technical Brief Blog: Introducing Oracle Machine Learning AutoML UI Oracle Machine Learning Services (2m video) OML Services Technical Brief Oracle Machine Learning Services Documentation Blog: Introducing Oracle Machine Learning Services GitHub Repository with OML Services examples OML4Py (2m video) OML4Py Introduction (17m video) OML4Py Technical Brief OML4Py User’s Guide Blog: Introducing OML4Py GitHub Repository with Python notebooks
  103. Sessions every Tuesday at 8AM Pacific Time Previous Sessions Oracle

    Machine Learning AskTom Office Hours sessions https://asktom.oracle.com/pls/apex/asktom.search?office=6801#sessionss 108 Machine Learning 101 sessions
  104. On our GitHub, you can find: Copyright © 2021, Oracle

    and/or its affiliates 109 github.com/oracle/oracle-db-examples/tree/master/machine-learning • Example Notebooks in OML4SQL and OML4Python • SQL code examples for DB 18c, 19c and 21c • Labs folder with OML4Py HOL Labs • OML Services demos including Cognitive Text Demos, in PostMan collections