Using Bluemix Predictive Analytics Service with Node-RED Enabling I/T and Analytics convergence to tackle the Internet of Things opportunities with agility A step by step example Lionel Momméja Executive Architect mommeja@fr.ibm.com Global Industry Solutions Center Nice-Paris
2 Internet of Things solutions require an agile collaboration between Data Scientists and Developers • The internet will connect 50 billions devices over the next five years. The increase in connectivity and access to real-time information is creating new opportunities such as improving Return on Asset or enabling new disruptive business models • The internet of things is generating a huge amount of data that can be processed in real-time (or near real-time) for a better reactivity to events • This create two new challenges: ability to handle new types of data sets generated by the “things” and ability to process analytics models in near real-time upon events reception. • These challenges require an agile cooperation between two categories of actors in the I/T which are not really used to work together so far: the data scientists and the developers
3 Introducing IBM Bluemix Predictive Analytics Service IBM Predictive Analytics is a full-service Bluemix offering that makes it easy for developers and data scientists to work together to integrate predictive capabilities with their applications. Built SPSS analytics platform, Predictive Analytics allows to develop applications that make smarter decisions, solve tough problems, and improve user outcomes DeveloperData Scientist CRISP-DM Bluemix Garage Method
4 In this Use Case, Data is coming from an IoT scenario built on Texas Instrument SimpleLink™ SensorTag • The SimpleLink™ SensorTag allows quick and easy prototyping of IoT devices. • SensorTag can easily be connected to IBM IoT Platform • It supports the following sensors: TI SimpleLink™ SensorTag • Humidity and Temperature • Ambient & IR Temperatures • Barometric Pressure • 3 axis Accelerometer • 3 axis Gyroscope • 3 axis Magnetometer • 2 push Buttons • 1 Luxometer
5 Data Scenario • The scenario is built on fictitious alerts created upon the following combination of conditions: – object temperature > 25 (Warm tag in your hand) – x-axis accelerometer > 0.3 (Shake the take) – light < 5 (Hide the tag in your hands) • But we are not supposed to know yet those conditions… • The data scientist will create and train a model that will discover them using machine learning Alert
6 Build-time: Simple SPSS Stream aimed at detecting failures from sensor data based on historical records Training input data set based on historical records and - fictitious - failure observations Scoring branch highlighted in blue. Bluemix Predictive Analytics service will discover this branch at load time and execute it when invoked Scoring input is typically real-time or near real-time IoT data collected on Watson IoT Platform. Filter out unnecessary fields specify input and target fields. Target is the alert Chosen machine learning algorithm is a decision tree using Chi- squared Automatic Interaction Detection (CHAID) Model created after execution of the CHAID algorithm (training branch) Scoring output stored in a table after execution of the scoring branch Training branch. This branch is executed at build-time in SPSS to create the model. MQTT Watson IoT PlatformTI SimpleLink™ SensorTag Historical records with failure alerts
7 Build-time: Reviewing the CHAID Decision Tree Model created after execution of the training branch • When the training branch is executed, a CHAID Decision Tree Model is created based on historical data made of sensor’s data and observed failures • The CHAID Decision Tree is a machine learning algorithm that will attempt to correlate sensor data and failures • This decision tree was created with this training data set • The machine learning algorithm established that when acc_x > 0.29 and light <= 2 and object_temp > 25 then there is a failure for sure.
8 Build-time: Testing the model in SPSS Modeler Scoring input Failure predicted by the model Confidence Score Scoring input Confidence Score No failure predicted by the model When executing the model, as expected, when all the following conditions are met, the model scores a failure: • object temperature > 25 • x-axis accelerometer > 0.3 • light < 5
9 Deploying the model in Bluemix Predictive Analytics Service Click here to open the dashboard
10 Deploying the model in Bluemix Predictive Analytics Service The service will search for a scoring branch Context Id is a label that will be used to identify your model in the API
11 Binding the Predictive Analytics Service to a Node-RED application and retrieving service URL and Access Key Click here to open the app dashboard Select your predictive analytics service… This is my Node-RED application Access Key Service instance URL
12 Accessing Predictive Analytics API Documentation The Predictive Analytics service is a set of REST APIs called from any programming language. You can access it here: https://console.ng.bluemix.net/docs/services/PredictiveModeling/index-gentopic1.html#genTopProcId2 POST http://{service instance}/pm/v1/score/{contextId}?accesskey={access_key for this bound application} { "tablename":“Scoring Input", "header":["object_temp", "acc_x", "light"], "data":[[27, 0.33, 1]]} Body:
13 Run-time: Invoking the Predictive Analytics Service from Node-RED Invoking the service is as simple as this: Function node http request node
14 Run-time: Invoking the Predictive Analytics Service from Node-RED Reviewing service invocation results { "topic": "", "payload": "[{"header":["object_temp","acc_x","light","$R-Failure","$RC-Failure"],"data":[[27,0.33,1,1,0.9846153846153847]]}]", "_msgid": "840e7dcc.7bf18", "headers": { "x-powered-by": "Servlet/3.0", "content-type": "application/json;charset=UTF-8", "content-length": "113", "date": "Thu, 12 May 2016 14:52:16 GMT", "set-cookie": ["PASESSIONID=ffffffff0602630a45525d5f4f58455e445a4a421548;path=/;domain=palblyp.pmservice.ibmcloud.com;httponly"] }, "statusCode": 200 } Score result Score input Score confidence
15 Run-time: Parsing Predictive Analytics Service Results To make parsing easy, use JSON Node to convert json into a javascript object Accessing score result is now simple Score result { "topic": "", "payload": "[{"header":["object_temp","acc_x","light","$R- Failure","$RC-Failure"],"data":[[27,0.33,1,1,0.9846153846153847]]}]", …
16 With IBM Bluemix Predictive Analytics Service and Node- RED, Developers and Data Scientists can develop new IoT Solutions with Agility Developer Data Scientist
17 Further Readings • IBM Predictive Analytics service on Bluemix • Engage Machine Learning for detecting anomalous behaviors of things an IBM developerWorks recipe featuring Bluemix Apache Spark service, a solution that can help scale-up in term of performance • IBM SPSS Software • Le parti pris des choses, a collection of prose poems on things from Francis Ponge

Using bluemix predictive analytics service in Node-RED

  • 1.
    Using Bluemix PredictiveAnalytics Service with Node-RED Enabling I/T and Analytics convergence to tackle the Internet of Things opportunities with agility A step by step example Lionel Momméja Executive Architect mommeja@fr.ibm.com Global Industry Solutions Center Nice-Paris
  • 2.
    2 Internet of Thingssolutions require an agile collaboration between Data Scientists and Developers • The internet will connect 50 billions devices over the next five years. The increase in connectivity and access to real-time information is creating new opportunities such as improving Return on Asset or enabling new disruptive business models • The internet of things is generating a huge amount of data that can be processed in real-time (or near real-time) for a better reactivity to events • This create two new challenges: ability to handle new types of data sets generated by the “things” and ability to process analytics models in near real-time upon events reception. • These challenges require an agile cooperation between two categories of actors in the I/T which are not really used to work together so far: the data scientists and the developers
  • 3.
    3 Introducing IBM BluemixPredictive Analytics Service IBM Predictive Analytics is a full-service Bluemix offering that makes it easy for developers and data scientists to work together to integrate predictive capabilities with their applications. Built SPSS analytics platform, Predictive Analytics allows to develop applications that make smarter decisions, solve tough problems, and improve user outcomes DeveloperData Scientist CRISP-DM Bluemix Garage Method
  • 4.
    4 In this UseCase, Data is coming from an IoT scenario built on Texas Instrument SimpleLink™ SensorTag • The SimpleLink™ SensorTag allows quick and easy prototyping of IoT devices. • SensorTag can easily be connected to IBM IoT Platform • It supports the following sensors: TI SimpleLink™ SensorTag • Humidity and Temperature • Ambient & IR Temperatures • Barometric Pressure • 3 axis Accelerometer • 3 axis Gyroscope • 3 axis Magnetometer • 2 push Buttons • 1 Luxometer
  • 5.
    5 Data Scenario • Thescenario is built on fictitious alerts created upon the following combination of conditions: – object temperature > 25 (Warm tag in your hand) – x-axis accelerometer > 0.3 (Shake the take) – light < 5 (Hide the tag in your hands) • But we are not supposed to know yet those conditions… • The data scientist will create and train a model that will discover them using machine learning Alert
  • 6.
    6 Build-time: Simple SPSSStream aimed at detecting failures from sensor data based on historical records Training input data set based on historical records and - fictitious - failure observations Scoring branch highlighted in blue. Bluemix Predictive Analytics service will discover this branch at load time and execute it when invoked Scoring input is typically real-time or near real-time IoT data collected on Watson IoT Platform. Filter out unnecessary fields specify input and target fields. Target is the alert Chosen machine learning algorithm is a decision tree using Chi- squared Automatic Interaction Detection (CHAID) Model created after execution of the CHAID algorithm (training branch) Scoring output stored in a table after execution of the scoring branch Training branch. This branch is executed at build-time in SPSS to create the model. MQTT Watson IoT PlatformTI SimpleLink™ SensorTag Historical records with failure alerts
  • 7.
    7 Build-time: Reviewing theCHAID Decision Tree Model created after execution of the training branch • When the training branch is executed, a CHAID Decision Tree Model is created based on historical data made of sensor’s data and observed failures • The CHAID Decision Tree is a machine learning algorithm that will attempt to correlate sensor data and failures • This decision tree was created with this training data set • The machine learning algorithm established that when acc_x > 0.29 and light <= 2 and object_temp > 25 then there is a failure for sure.
  • 8.
    8 Build-time: Testing themodel in SPSS Modeler Scoring input Failure predicted by the model Confidence Score Scoring input Confidence Score No failure predicted by the model When executing the model, as expected, when all the following conditions are met, the model scores a failure: • object temperature > 25 • x-axis accelerometer > 0.3 • light < 5
  • 9.
    9 Deploying the modelin Bluemix Predictive Analytics Service Click here to open the dashboard
  • 10.
    10 Deploying the modelin Bluemix Predictive Analytics Service The service will search for a scoring branch Context Id is a label that will be used to identify your model in the API
  • 11.
    11 Binding the PredictiveAnalytics Service to a Node-RED application and retrieving service URL and Access Key Click here to open the app dashboard Select your predictive analytics service… This is my Node-RED application Access Key Service instance URL
  • 12.
    12 Accessing Predictive AnalyticsAPI Documentation The Predictive Analytics service is a set of REST APIs called from any programming language. You can access it here: https://console.ng.bluemix.net/docs/services/PredictiveModeling/index-gentopic1.html#genTopProcId2 POST http://{service instance}/pm/v1/score/{contextId}?accesskey={access_key for this bound application} { "tablename":“Scoring Input", "header":["object_temp", "acc_x", "light"], "data":[[27, 0.33, 1]]} Body:
  • 13.
    13 Run-time: Invoking thePredictive Analytics Service from Node-RED Invoking the service is as simple as this: Function node http request node
  • 14.
    14 Run-time: Invoking thePredictive Analytics Service from Node-RED Reviewing service invocation results { "topic": "", "payload": "[{"header":["object_temp","acc_x","light","$R-Failure","$RC-Failure"],"data":[[27,0.33,1,1,0.9846153846153847]]}]", "_msgid": "840e7dcc.7bf18", "headers": { "x-powered-by": "Servlet/3.0", "content-type": "application/json;charset=UTF-8", "content-length": "113", "date": "Thu, 12 May 2016 14:52:16 GMT", "set-cookie": ["PASESSIONID=ffffffff0602630a45525d5f4f58455e445a4a421548;path=/;domain=palblyp.pmservice.ibmcloud.com;httponly"] }, "statusCode": 200 } Score result Score input Score confidence
  • 15.
    15 Run-time: Parsing PredictiveAnalytics Service Results To make parsing easy, use JSON Node to convert json into a javascript object Accessing score result is now simple Score result { "topic": "", "payload": "[{"header":["object_temp","acc_x","light","$R- Failure","$RC-Failure"],"data":[[27,0.33,1,1,0.9846153846153847]]}]", …
  • 16.
    16 With IBM BluemixPredictive Analytics Service and Node- RED, Developers and Data Scientists can develop new IoT Solutions with Agility Developer Data Scientist
  • 17.
    17 Further Readings • IBMPredictive Analytics service on Bluemix • Engage Machine Learning for detecting anomalous behaviors of things an IBM developerWorks recipe featuring Bluemix Apache Spark service, a solution that can help scale-up in term of performance • IBM SPSS Software • Le parti pris des choses, a collection of prose poems on things from Francis Ponge