├── data
├── delete.txt
└── iot_sensor_dataset.csv
├── doc
└── images
│ ├── delete.txt
│ ├── pi_flow.png
│ ├── create_wiot.png
│ ├── ftp_data_pi.png
│ ├── launch_wiot.png
│ ├── iea_arch_flow.png
│ ├── import_flow_pi.png
│ ├── note_api_key.png
│ ├── visit_app_url.png
│ ├── DB2_credentials.png
│ ├── create_notebook.png
│ ├── dash_db_out_node.png
│ ├── iea_aainiot_arch.png
│ ├── iea_bmx2rpi_flow.png
│ ├── iea_nodered_bmx.png
│ ├── iea_rpi2bmx_flow.png
│ ├── imported_pi_flow.png
│ ├── table_definition.png
│ ├── configure_api_key.png
│ ├── deploy_nodered_flow.png
│ ├── iea_bmx2rpi_results.png
│ ├── iea_rpi2bmx_results.png
│ ├── note_websocket_url.png
│ ├── start_node_red_pi.png
│ ├── click_watson_iot_node.png
│ ├── create_db2_warehouse.png
│ ├── enter_api_key_details.png
│ ├── iea_nodered_bmx_blank.png
│ ├── iea_nodered_bmx_form.png
│ ├── iea_nodered_bmx_iotp.png
│ ├── iea_nodered_bmx_plan.png
│ ├── iea_nodered_bmx_serv.png
│ ├── modify_db_credentials.png
│ ├── bluemix_service_nodered.png
│ ├── click_explore_schema_db.png
│ ├── enter_device-credentials.png
│ ├── ibm_cloud_node_red_flow.png
│ ├── iea_nodered_bmx_editor.png
│ ├── iea_nodered_bmx_edlaunch.png
│ ├── iea_rpi2bmx_quickstartid.png
│ ├── note_device_credentials.png
│ ├── click_node_red_import_menu.png
│ ├── click_sensor_trigger_event.png
│ ├── select_role_data_processor.png
│ ├── change_websocket_url_notebook.png
│ ├── click_apps_generate_api_key.png
│ ├── iea_bmxreceiveiottemp_results.png
│ ├── simulate_shutdown-condition.png
│ ├── click_watson_iot_commands_node.png
│ ├── iea_bmxreceiveiottemp_bmx_devid.png
│ └── iea_bmxreceiveiottemp_bmx_flow.png
├── notebooks
├── delete.txt
└── watson_iotfailure_prediction_integrated.ipynb
├── DEBUGGING.md
├── configuration
├── RPi
│ ├── LEDOnOff.json
│ ├── RPi2BMX.json
│ └── BMX2RPi.json
└── BMX
│ └── BMXReceiveProcessIoTTemp.json
├── CONTRIBUTING.md
├── node-red-flow
├── pi_flow.json
└── orchestrate_dsx_workflow.json
├── MAINTAINERS.md
├── LICENSE
└── README.md
/data/delete.txt:
--------------------------------------------------------------------------------
1 | Z
2 |
--------------------------------------------------------------------------------
/doc/images/delete.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/notebooks/delete.txt:
--------------------------------------------------------------------------------
1 | delete
2 |
--------------------------------------------------------------------------------
/doc/images/pi_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/pi_flow.png
--------------------------------------------------------------------------------
/doc/images/create_wiot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/create_wiot.png
--------------------------------------------------------------------------------
/doc/images/ftp_data_pi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/ftp_data_pi.png
--------------------------------------------------------------------------------
/doc/images/launch_wiot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/launch_wiot.png
--------------------------------------------------------------------------------
/doc/images/iea_arch_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_arch_flow.png
--------------------------------------------------------------------------------
/doc/images/import_flow_pi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/import_flow_pi.png
--------------------------------------------------------------------------------
/doc/images/note_api_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/note_api_key.png
--------------------------------------------------------------------------------
/doc/images/visit_app_url.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/visit_app_url.png
--------------------------------------------------------------------------------
/doc/images/DB2_credentials.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/DB2_credentials.png
--------------------------------------------------------------------------------
/doc/images/create_notebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/create_notebook.png
--------------------------------------------------------------------------------
/doc/images/dash_db_out_node.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/dash_db_out_node.png
--------------------------------------------------------------------------------
/doc/images/iea_aainiot_arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_aainiot_arch.png
--------------------------------------------------------------------------------
/doc/images/iea_bmx2rpi_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_bmx2rpi_flow.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx.png
--------------------------------------------------------------------------------
/doc/images/iea_rpi2bmx_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_rpi2bmx_flow.png
--------------------------------------------------------------------------------
/doc/images/imported_pi_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/imported_pi_flow.png
--------------------------------------------------------------------------------
/doc/images/table_definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/table_definition.png
--------------------------------------------------------------------------------
/doc/images/configure_api_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/configure_api_key.png
--------------------------------------------------------------------------------
/doc/images/deploy_nodered_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/deploy_nodered_flow.png
--------------------------------------------------------------------------------
/doc/images/iea_bmx2rpi_results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_bmx2rpi_results.png
--------------------------------------------------------------------------------
/doc/images/iea_rpi2bmx_results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_rpi2bmx_results.png
--------------------------------------------------------------------------------
/doc/images/note_websocket_url.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/note_websocket_url.png
--------------------------------------------------------------------------------
/doc/images/start_node_red_pi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/start_node_red_pi.png
--------------------------------------------------------------------------------
/doc/images/click_watson_iot_node.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/click_watson_iot_node.png
--------------------------------------------------------------------------------
/doc/images/create_db2_warehouse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/create_db2_warehouse.png
--------------------------------------------------------------------------------
/doc/images/enter_api_key_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/enter_api_key_details.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_blank.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_form.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_iotp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_iotp.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_plan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_plan.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_serv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_serv.png
--------------------------------------------------------------------------------
/doc/images/modify_db_credentials.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/modify_db_credentials.png
--------------------------------------------------------------------------------
/doc/images/bluemix_service_nodered.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/bluemix_service_nodered.png
--------------------------------------------------------------------------------
/doc/images/click_explore_schema_db.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/click_explore_schema_db.png
--------------------------------------------------------------------------------
/doc/images/enter_device-credentials.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/enter_device-credentials.png
--------------------------------------------------------------------------------
/doc/images/ibm_cloud_node_red_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/ibm_cloud_node_red_flow.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_editor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_editor.png
--------------------------------------------------------------------------------
/doc/images/iea_nodered_bmx_edlaunch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_nodered_bmx_edlaunch.png
--------------------------------------------------------------------------------
/doc/images/iea_rpi2bmx_quickstartid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_rpi2bmx_quickstartid.png
--------------------------------------------------------------------------------
/doc/images/note_device_credentials.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/note_device_credentials.png
--------------------------------------------------------------------------------
/doc/images/click_node_red_import_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/click_node_red_import_menu.png
--------------------------------------------------------------------------------
/doc/images/click_sensor_trigger_event.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/click_sensor_trigger_event.png
--------------------------------------------------------------------------------
/doc/images/select_role_data_processor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/select_role_data_processor.png
--------------------------------------------------------------------------------
/doc/images/change_websocket_url_notebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/change_websocket_url_notebook.png
--------------------------------------------------------------------------------
/doc/images/click_apps_generate_api_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/click_apps_generate_api_key.png
--------------------------------------------------------------------------------
/doc/images/iea_bmxreceiveiottemp_results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_bmxreceiveiottemp_results.png
--------------------------------------------------------------------------------
/doc/images/simulate_shutdown-condition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/simulate_shutdown-condition.png
--------------------------------------------------------------------------------
/doc/images/click_watson_iot_commands_node.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/click_watson_iot_commands_node.png
--------------------------------------------------------------------------------
/doc/images/iea_bmxreceiveiottemp_bmx_devid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_bmxreceiveiottemp_bmx_devid.png
--------------------------------------------------------------------------------
/doc/images/iea_bmxreceiveiottemp_bmx_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBM/iot-edge-predictive-models-dsx/HEAD/doc/images/iea_bmxreceiveiottemp_bmx_flow.png
--------------------------------------------------------------------------------
/DEBUGGING.md:
--------------------------------------------------------------------------------
1 | Troubleshooting
2 | ===============
3 |
4 | Node-RED
5 | --------
6 |
7 | * This Code Pattern uses [Raspberry Pi 3 Model B](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)
8 | * Whie installing Raspbian on Raspberry Pi make sure you installed the correct version.
9 | The version used in this IBMCode pattern can be found [here](http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-08-17/)
10 | * You can refer to a complete list of Raspberry Pi OS archives [here](http://downloads.raspberrypi.org/raspbian/images/)
11 | * Make sure the import of Node-RED ran correctly. Ensure each flow works correctly in the
12 | sequence of data flow before moving on to the next.
13 | * All the flows depend on the outputs from previous flows and also the connectivity.
14 | If there is an issue in any stage stop and resolve the issue before moving further.
15 | Start from the beginning when troubleshooting. Examine the outputs in the debug window in
16 | Node-RED editor thorougly at each stage.
17 | * The flow relies on service credentials from IBM Cloud.
18 | Make sure to add your service credentials correctly.
19 |
20 |
21 | IBM IoT Platform
22 | ----------------
23 | * Make sure data is received and transmitted correctly between Raspberry Pi
24 | and IBM IoT Platform on the cloud.
25 | * Specifically ensure the Region in which your Service is created in IBM Cloud
26 | is consistent
27 | * Also pay special attention to the unique ``Device ID`` you set on the Raspberry Pi
28 | Node-RED flow as well as the Node-RED flow in IBM Cloud. These must be same and unique
29 | to ensure seamless data transfer.
30 |
--------------------------------------------------------------------------------
/configuration/RPi/LEDOnOff.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "e2527403.a3ad9",
4 | "type": "rpi-gpio out",
5 | "z": "45ff02b1.ba00fc",
6 | "name": "Red - LED",
7 | "pin": "11",
8 | "set": true,
9 | "level": "0",
10 | "out": "out",
11 | "x": 646.7666320800781,
12 | "y": 254.46665954589844,
13 | "wires": []
14 | },
15 | {
16 | "id": "38a89cec.276ac4",
17 | "type": "inject",
18 | "z": "45ff02b1.ba00fc",
19 | "name": "On",
20 | "topic": "",
21 | "payload": "1",
22 | "payloadType": "num",
23 | "repeat": "",
24 | "crontab": "",
25 | "once": false,
26 | "x": 177.76666259765625,
27 | "y": 192.01666259765625,
28 | "wires": [
29 | [
30 | "e2527403.a3ad9",
31 | "2e89b10b.e88696"
32 | ]
33 | ]
34 | },
35 | {
36 | "id": "99d1fddc.642fb8",
37 | "type": "inject",
38 | "z": "45ff02b1.ba00fc",
39 | "name": "Off",
40 | "topic": "",
41 | "payload": "0",
42 | "payloadType": "num",
43 | "repeat": "",
44 | "crontab": "",
45 | "once": false,
46 | "x": 183.88333129882812,
47 | "y": 296.8833312988281,
48 | "wires": [
49 | [
50 | "e2527403.a3ad9",
51 | "2e89b10b.e88696"
52 | ]
53 | ]
54 | },
55 | {
56 | "id": "2e89b10b.e88696",
57 | "type": "debug",
58 | "z": "45ff02b1.ba00fc",
59 | "name": "",
60 | "active": true,
61 | "console": "false",
62 | "complete": "false",
63 | "x": 633.7666320800781,
64 | "y": 132.5500030517578,
65 | "wires": []
66 | }
67 | ]
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing In General
2 |
3 | Our project welcomes external contributions! If you have an itch, please
4 | feel free to scratch it.
5 |
6 | To contribute code or documentation, please submit a pull request to the [GitHub
7 | repository](https://github.com/IBM/iot-edge-predictive-models-dsx).
8 |
9 | A good way to familiarize yourself with the codebase and contribution process is
10 | to look for and tackle low-hanging fruit in the [issue
11 | tracker](https://github.com/IBM/iot-edge-predictive-models-dsx/issues). Before embarking on
12 | a more ambitious contribution, please quickly [get in touch](#communication)
13 | with us.
14 |
15 | **We appreciate your effort, and want to avoid a situation where a contribution
16 | requires extensive rework (by you or by us), sits in the queue for a long time,
17 | or cannot be accepted at all!**
18 |
19 | ### Proposing new features
20 |
21 | If you would like to implement a new feature, please [raise an
22 | issue](https://github.com/IBM/iot-edge-predictive-models-dsx/issues) before sending a pull
23 | request so the feature can be discussed. This is to avoid you spending your
24 | valuable time working on a feature that the project developers are not willing
25 | to accept into the code base.
26 |
27 | ### Fixing bugs
28 |
29 | If you would like to fix a bug, please [raise an
30 | issue](https://github.com/IBM/iot-edge-predictive-models-dsx/issues) before sending a pull
31 | request so it can be discussed. If the fix is trivial or non controversial then
32 | this is not usually necessary.
33 |
34 | ### Merge approval
35 |
36 | The project maintainers use LGTM (Looks Good To Me) in comments on the code
37 | review to indicate acceptance. A change requires LGTMs from two of the
38 | maintainers of each component affected.
39 |
40 | For more details, see the [MAINTAINERS](MAINTAINERS.md) page.
41 |
42 | ## Communication
43 |
44 | Please feel free to connect with us: [here](https://github.com/IBM/iot-edge-predictive-models-dsx/issues)
45 |
46 | ## Setup
47 |
48 | Please add any special setup instructions for your project to help the
49 | developer become productive quickly.
50 |
51 | ## Testing
52 |
53 | Please provide information that helps the developer test any changes they
54 | make before submitting.
55 |
56 | ## Coding style guidelines
57 |
58 | Beautiful code rocks! Please share any specific style guidelines you might
59 | have for your project.
60 |
--------------------------------------------------------------------------------
/node-red-flow/pi_flow.json:
--------------------------------------------------------------------------------
1 | [{"id":"1bd9c8d5.6c2ca7","type":"wiotp in","z":"cb9d34cc.77518","authType":"d","deviceKey":"33a84934.5a651e","deviceType":"","deviceId":"","command":"+","commandType":"g","qos":0,"name":"","x":113,"y":329.5,"wires":[["d3572d25.05498"]]},{"id":"d3572d25.05498","type":"debug","z":"cb9d34cc.77518","name":"","active":true,"console":"false","complete":"false","x":361,"y":329.75,"wires":[]},{"id":"204757f1.448de8","type":"file in","z":"cb9d34cc.77518","name":"","filename":"/home/pi/iot_sensor_dataset.csv","format":"utf8","x":419,"y":96.5,"wires":[["beebaca6.c19b3"]]},{"id":"beebaca6.c19b3","type":"csv","z":"cb9d34cc.77518","name":"","sep":",","hdrin":true,"hdrout":"","multi":"one","ret":"\\n","temp":"","x":650,"y":94,"wires":[["2bd955c0.357b32","988060ba.46f6c8"]]},{"id":"95845415.d531d","type":"inject","z":"cb9d34cc.77518","name":"Sensor event trigger","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":136.5,"y":96.5,"wires":[["204757f1.448de8"]]},{"id":"2bd955c0.357b32","type":"wiotp out","z":"cb9d34cc.77518","authType":"d","qs":"false","qsDeviceId":"","deviceKey":"33a84934.5a651e","deviceType":"","deviceId":"","event":"event","format":"json","qos":"","name":"","x":841,"y":93.75,"wires":[]},{"id":"a4b3638e.9538b8","type":"comment","z":"cb9d34cc.77518","name":"Send sensor events to Watson IoT Platform.","info":"","x":212,"y":41,"wires":[]},{"id":"574ded47.1eb7cc","type":"comment","z":"cb9d34cc.77518","name":"Recieve commands from Watson IoT platform","info":"","x":212,"y":284,"wires":[]},{"id":"f1bc890f.9c8f38","type":"inject","z":"cb9d34cc.77518","name":"Event - Running","topic":"","payload":"{\"footfall\":31,\"atemp\":2,\"selfLR\":7,\"ClinLR\":2,\"DoleLR\":6,\"PID\":6,\"outpressure\":19,\"inpressure\":4,\"temp\":3}","payloadType":"json","repeat":"","crontab":"","once":false,"x":578.5,"y":189.25,"wires":[["2bd955c0.357b32"]]},{"id":"22c60dbe.5a6a92","type":"inject","z":"cb9d34cc.77518","name":"Event - Failing","topic":"","payload":"{\"footfall\":31,\"atemp\":1,\"selfLR\":7,\"ClinLR\":2,\"DoleLR\":6,\"PID\":1,\"outpressure\":20,\"inpressure\":4,\"temp\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"x":580.5,"y":241.25,"wires":[["2bd955c0.357b32"]]},{"id":"988060ba.46f6c8","type":"debug","z":"cb9d34cc.77518","name":"","active":true,"console":"false","complete":"false","x":778.5,"y":26.5,"wires":[]},{"id":"33a84934.5a651e","type":"wiotp-credentials","z":"","name":"","org":"","serverName":"","devType":"Equipment","devId":"Sensors","keepalive":"60","cleansession":true}]
2 |
--------------------------------------------------------------------------------
/configuration/RPi/RPi2BMX.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "95b1e818.738bd8",
4 | "type": "inject",
5 | "z": "582b50ec.ce2268",
6 | "name": "",
7 | "topic": "",
8 | "payload": "",
9 | "payloadType": "date",
10 | "repeat": "5",
11 | "crontab": "",
12 | "once": true,
13 | "x": 109,
14 | "y": 130.5,
15 | "wires": [
16 | [
17 | "8e128d15.a06be8"
18 | ]
19 | ]
20 | },
21 | {
22 | "id": "8e128d15.a06be8",
23 | "type": "exec",
24 | "z": "582b50ec.ce2268",
25 | "command": "vcgencmd",
26 | "addpay": false,
27 | "append": "measure_temp",
28 | "useSpawn": "",
29 | "timer": "",
30 | "name": "getCPUtemp",
31 | "x": 326,
32 | "y": 209,
33 | "wires": [
34 | [
35 | "483a2d3.28ae5d4",
36 | "e36fd413.601ef8"
37 | ],
38 | [],
39 | []
40 | ]
41 | },
42 | {
43 | "id": "483a2d3.28ae5d4",
44 | "type": "debug",
45 | "z": "582b50ec.ce2268",
46 | "name": "",
47 | "active": false,
48 | "console": "false",
49 | "complete": "payload",
50 | "x": 670,
51 | "y": 196,
52 | "wires": []
53 | },
54 | {
55 | "id": "e36fd413.601ef8",
56 | "type": "function",
57 | "z": "582b50ec.ce2268",
58 | "name": "Temperature",
59 | "func": "// Create MQTT message in JSON\nmsg = {\n payload: JSON.stringify(\n {\n d:{\n \"value\" : msg.payload.replace(\"temp=\", \"\").replace(\"\\'C\",\"\").replace(\"\\n\",\"\")}\n }\n )\n};\n\nreturn msg;\n",
60 | "outputs": 1,
61 | "noerr": 0,
62 | "x": 376,
63 | "y": 315.5,
64 | "wires": [
65 | [
66 | "483a2d3.28ae5d4",
67 | "47e56175.5c90c8"
68 | ]
69 | ]
70 | },
71 | {
72 | "id": "47e56175.5c90c8",
73 | "type": "wiotp out",
74 | "z": "582b50ec.ce2268",
75 | "authType": "d",
76 | "qs": "true",
77 | "qsDeviceId": "kpedgetobmx20171207",
78 | "deviceKey": "",
79 | "deviceType": "",
80 | "deviceId": "",
81 | "event": "event",
82 | "format": "json",
83 | "qos": "",
84 | "name": "",
85 | "x": 659,
86 | "y": 314,
87 | "wires": []
88 | },
89 | {
90 | "id": "b0b5b4dd.2c35d8",
91 | "type": "comment",
92 | "z": "582b50ec.ce2268",
93 | "name": "IoT on Edge - Sensor data to Bluemix",
94 | "info": "Collect Sensor data and send to IBM Bluemix",
95 | "x": 163,
96 | "y": 69,
97 | "wires": []
98 | }
99 | ]
--------------------------------------------------------------------------------
/MAINTAINERS.md:
--------------------------------------------------------------------------------
1 | ## Maintainers Guide
2 |
3 | This guide is intended for maintainers — anybody with commit access to one or
4 | more Developer Journey repositories.
5 |
6 | ## Methodology:
7 |
8 | A master branch. This branch MUST be releasable at all times. Commits and
9 | merges against this branch MUST contain only bugfixes and/or security fixes.
10 | Maintenance releases are tagged against master.
11 |
12 | A develop branch. This branch contains your proposed changes.
13 |
14 | The remainder of this document details how to merge pull requests to the
15 | repositories.
16 |
17 | ## Merge approval
18 |
19 | The project maintainers use LGTM (Looks Good To Me) in comments on the code
20 | review to indicate acceptance. A change requires LGTMs from two of the members
21 | of the [cda-journey-dev-admins](https://github.com/orgs/IBM/teams/cda-journey-dev-admins)
22 | team. If the code is written by a member, the change only requires one more
23 | LGTM.
24 |
25 | ## Reviewing Pull Requests
26 |
27 | We recommend reviewing pull requests directly within GitHub. This allows a
28 | public commentary on changes, providing transparency for all users. When
29 | providing feedback be civil, courteous, and kind. Disagreement is fine, so
30 | long as the discourse is carried out politely. If we see a record of uncivil
31 | or abusive comments, we will revoke your commit privileges and invite you to
32 | leave the project.
33 |
34 | During your review, consider the following points:
35 |
36 | ### Does the change have impact?
37 |
38 | While fixing typos is nice as it adds to the overall quality of the project,
39 | merging a typo fix at a time can be a waste of effort.
40 | (Merging many typo fixes because somebody reviewed the entire component,
41 | however, is useful!) Other examples to be wary of:
42 |
43 | Changes in variable names. Ask whether or not the change will make
44 | understanding the code easier, or if it could simply a personal preference
45 | on the part of the author.
46 |
47 | Essentially: feel free to close issues that do not have impact.
48 |
49 | ### Do the changes make sense?
50 |
51 | If you do not understand what the changes are or what they accomplish,
52 | ask the author for clarification. Ask the author to add comments and/or
53 | clarify test case names to make the intentions clear.
54 |
55 | At times, such clarification will reveal that the author may not be using
56 | the code correctly, or is unaware of features that accommodate their needs.
57 | If you feel this is the case, work up a code sample that would address the
58 | issue for them, and feel free to close the issue once they confirm.
59 |
60 | ### Is this a new feature? If so:
61 |
62 | Does the issue contain narrative indicating the need for the feature? If not,
63 | ask them to provide that information. Since the issue will be linked in the
64 | changelog, this will often be a user's first introduction to it.
65 |
66 | Are new unit tests in place that test all new behaviors introduced? If not, do
67 | not merge the feature until they are!
68 | Is documentation in place for the new feature? (See the documentation
69 | guidelines). If not do not merge the feature until it is!
70 | Is the feature necessary for general use cases? Try and keep the scope of any
71 | given component narrow. If a proposed feature does not fit that scope,
72 | recommend to the user that they maintain the feature on their own, and close
73 | the request. You may also recommend that they see if the feature gains traction
74 | amongst other users, and suggest they re-submit when they can show such support.
75 |
--------------------------------------------------------------------------------
/configuration/RPi/BMX2RPi.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "d4755d28.f93438",
4 | "type": "comment",
5 | "z": "a34917aa.b0ba6",
6 | "name": "IoT on Edge - Receive command from Bluemix",
7 | "info": "Receive command from Bluemix and \ninitiate Action",
8 | "x": 210,
9 | "y": 53,
10 | "wires": []
11 | },
12 | {
13 | "id": "121333e0.a71ef4",
14 | "type": "ibmiot in",
15 | "z": "a34917aa.b0ba6",
16 | "authentication": "quickstart",
17 | "apiKey": "325cb44c.cda34c",
18 | "inputType": "evt",
19 | "deviceId": "kpbmxtoedge20171207",
20 | "applicationId": "",
21 | "deviceType": "+",
22 | "eventType": "+",
23 | "commandType": "",
24 | "format": "json",
25 | "name": "Receive IBM IoT BMX command to Edge",
26 | "service": "quickstart",
27 | "allDevices": "",
28 | "allApplications": "",
29 | "allDeviceTypes": true,
30 | "allEvents": true,
31 | "allCommands": "",
32 | "allFormats": "",
33 | "qos": 0,
34 | "x": 205,
35 | "y": 126,
36 | "wires": [
37 | [
38 | "7d925507.4cd9fc",
39 | "f2672dcf.f28f08"
40 | ]
41 | ]
42 | },
43 | {
44 | "id": "7d925507.4cd9fc",
45 | "type": "debug",
46 | "z": "a34917aa.b0ba6",
47 | "name": "",
48 | "active": false,
49 | "console": "false",
50 | "complete": "false",
51 | "x": 557,
52 | "y": 119,
53 | "wires": []
54 | },
55 | {
56 | "id": "f2672dcf.f28f08",
57 | "type": "function",
58 | "z": "a34917aa.b0ba6",
59 | "name": "getAction",
60 | "func": "return {payload:msg.payload.d.action};",
61 | "outputs": 1,
62 | "noerr": 0,
63 | "x": 139,
64 | "y": 217,
65 | "wires": [
66 | [
67 | "4b9c00bb.04c71",
68 | "d3b90e66.320688"
69 | ]
70 | ]
71 | },
72 | {
73 | "id": "4b9c00bb.04c71",
74 | "type": "switch",
75 | "z": "a34917aa.b0ba6",
76 | "name": "Read Command",
77 | "property": "payload",
78 | "propertyType": "msg",
79 | "rules": [
80 | {
81 | "t": "eq",
82 | "v": "fanon",
83 | "vt": "str"
84 | },
85 | {
86 | "t": "else"
87 | }
88 | ],
89 | "checkall": "true",
90 | "outputs": 2,
91 | "x": 287.76666259765625,
92 | "y": 327.23333740234375,
93 | "wires": [
94 | [
95 | "16c8b586.568b72"
96 | ],
97 | [
98 | "80a2f35b.90f9b"
99 | ]
100 | ]
101 | },
102 | {
103 | "id": "16c8b586.568b72",
104 | "type": "template",
105 | "z": "a34917aa.b0ba6",
106 | "name": "On",
107 | "field": "payload",
108 | "fieldType": "msg",
109 | "format": "handlebars",
110 | "syntax": "mustache",
111 | "template": "1",
112 | "x": 510.7666320800781,
113 | "y": 292.3166809082031,
114 | "wires": [
115 | [
116 | "55a023b9.11de54",
117 | "ccabdca6.66545"
118 | ]
119 | ]
120 | },
121 | {
122 | "id": "80a2f35b.90f9b",
123 | "type": "template",
124 | "z": "a34917aa.b0ba6",
125 | "name": "Off",
126 | "field": "payload",
127 | "fieldType": "msg",
128 | "format": "handlebars",
129 | "syntax": "mustache",
130 | "template": "0",
131 | "x": 512.8833312988281,
132 | "y": 351.8833312988281,
133 | "wires": [
134 | [
135 | "55a023b9.11de54",
136 | "ccabdca6.66545"
137 | ]
138 | ]
139 | },
140 | {
141 | "id": "55a023b9.11de54",
142 | "type": "debug",
143 | "z": "a34917aa.b0ba6",
144 | "name": "",
145 | "active": true,
146 | "console": "false",
147 | "complete": "false",
148 | "x": 727.88330078125,
149 | "y": 276.8833312988281,
150 | "wires": []
151 | },
152 | {
153 | "id": "d3b90e66.320688",
154 | "type": "debug",
155 | "z": "a34917aa.b0ba6",
156 | "name": "",
157 | "active": true,
158 | "console": "false",
159 | "complete": "false",
160 | "x": 612.88330078125,
161 | "y": 200.88333129882812,
162 | "wires": []
163 | },
164 | {
165 | "id": "ccabdca6.66545",
166 | "type": "rpi-gpio out",
167 | "z": "a34917aa.b0ba6",
168 | "name": "Red - LED",
169 | "pin": "11",
170 | "set": true,
171 | "level": "0",
172 | "out": "out",
173 | "x": 755.88330078125,
174 | "y": 395.8833312988281,
175 | "wires": []
176 | },
177 | {
178 | "id": "325cb44c.cda34c",
179 | "type": "ibmiot",
180 | "z": "",
181 | "name": "CarKey",
182 | "keepalive": "60",
183 | "domain": "",
184 | "cleansession": true,
185 | "appId": "carsim",
186 | "shared": false
187 | }
188 | ]
--------------------------------------------------------------------------------
/node-red-flow/orchestrate_dsx_workflow.json:
--------------------------------------------------------------------------------
1 | [{"id":"6e2a5dcb.d635dc","type":"dashDB out","z":"60cfbb27.7bd1d4","dashDB":"","service":"Db2 Warehouse-9z","table":"EQUIPMENT_DATA","name":"","x":930,"y":420,"wires":[]},{"id":"5d798f0b.b9bac8","type":"ibmiot in","z":"60cfbb27.7bd1d4","authentication":"quickstart","apiKey":"","inputType":"evt","logicalInterface":"","ruleId":"","deviceId":"","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT","service":"quickstart","allDevices":"","allApplications":"","allDeviceTypes":true,"allLogicalInterfaces":"","allEvents":true,"allCommands":"","allFormats":"","qos":0,"x":234,"y":300,"wires":[["4be54eb3.fe3dd"]]},{"id":"cb0b9fa7.d11e","type":"comment","z":"60cfbb27.7bd1d4","name":"Store data into DB2 Warehouse","info":"","x":950,"y":340,"wires":[]},{"id":"f1a3e54f.bad098","type":"debug","z":"60cfbb27.7bd1d4","name":"Equipment data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":280,"wires":[]},{"id":"723b895d.4b6558","type":"function","z":"60cfbb27.7bd1d4","name":"Prepare payload for storage","func":"var output = {};\nmsg.payload = msg.data;\noutput.payload =\n{\n FOOTFALL : msg.payload.d.footfall,\n ATEMP : msg.payload.d.atemp,\n SELFLR : msg.payload.d.selfLR,\n CLINLR : msg.payload.d.ClinLR,\n DOLELR : msg.payload.d.DoleLR,\n PID : msg.payload.d.PID,\n OUTPRESSURE : msg.payload.d.outpressure,\n INPRESSURE : msg.payload.d.inpressure,\n TEMP : msg.payload.d.temp,\n FAIL : msg.payload.d.fail\n}\nreturn output;\n","outputs":1,"noerr":0,"x":680,"y":380,"wires":[["f1a3e54f.bad098","6e2a5dcb.d635dc"]]},{"id":"96b17958.01e608","type":"dashDB in","z":"60cfbb27.7bd1d4","dashDB":"","service":"Db2 Warehouse-9z","query":"DELETE FROM EQUIPMENT_DATA","params":"","name":"EQUIPMENT_DATA","x":613,"y":618,"wires":[["b4935a29.af2e98"]]},{"id":"f710affd.dc8e58","type":"inject","z":"60cfbb27.7bd1d4","name":"Delete data in the EQUIPMENT_DATA table","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":383,"y":538,"wires":[["96b17958.01e608"]]},{"id":"b4935a29.af2e98","type":"debug","z":"60cfbb27.7bd1d4","name":"DB response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":854,"y":620,"wires":[]},{"id":"b8077d5f.c314a","type":"comment","z":"60cfbb27.7bd1d4","name":"Delete Table data","info":"","x":304,"y":500,"wires":[]},{"id":"2122d832.7fb5b","type":"websocket in","z":"60cfbb27.7bd1d4","name":"","server":"7e580743.ca826","client":"","x":292,"y":782,"wires":[["b6da6c7b.c861b8","647c9ac0.dd1ddc"]]},{"id":"b6da6c7b.c861b8","type":"function","z":"60cfbb27.7bd1d4","name":"","func":"msg._session=\"\";\nreturn msg;","outputs":1,"noerr":0,"x":572,"y":782,"wires":[["e846ce9.a049d3"]]},{"id":"e846ce9.a049d3","type":"websocket out","z":"60cfbb27.7bd1d4","name":"","server":"7e580743.ca826","client":"","x":842,"y":782,"wires":[]},{"id":"1dfeb46b.246ee4","type":"comment","z":"60cfbb27.7bd1d4","name":"Flow that creates a Web socket server ","info":"This flow creates a web socket server","x":354,"y":720,"wires":[]},{"id":"7fba65bc.f9463c","type":"switch","z":"60cfbb27.7bd1d4","name":"switch","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":300,"wires":[["f6aaa516.404f3"],["723b895d.4b6558"]]},{"id":"2bc6ced2.1a6682","type":"websocket out","z":"60cfbb27.7bd1d4","name":"","server":"7e580743.ca826","client":"","x":960,"y":140,"wires":[]},{"id":"4be54eb3.fe3dd","type":"function","z":"60cfbb27.7bd1d4","name":"Backup data","func":"msg.data = msg.payload;\nvar prop = \"fail\";\nif (msg.data.d.hasOwnProperty(prop)) {\n msg.payload = 0;\n}\nelse {\n msg.payload = 1;\n}\nreturn msg;","outputs":1,"noerr":0,"x":434,"y":300,"wires":[["7fba65bc.f9463c"]]},{"id":"f6aaa516.404f3","type":"function","z":"60cfbb27.7bd1d4","name":"Construct message for invoking DSX","func":"var payload = {}\npayload = {\n 'cmd':'predict',\n 'atemp':msg.data.d.atemp,\n 'PID' : msg.data.d.PID,\n 'outpressure': msg.data.d.outpressure,\n 'inpressure' : msg.data.d.inpressure,\n 'temp' : msg.data.d.temp,\n}\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":220,"wires":[["2bc6ced2.1a6682"]]},{"id":"647c9ac0.dd1ddc","type":"function","z":"60cfbb27.7bd1d4","name":"Assign prediction status","func":"var payload = msg.payload;\nvar jsonobj = JSON.parse(payload);\nvar cmd = jsonobj.cmd;\nvar status = \"Ignore\";\nif (cmd == 'response') {\n status = jsonobj.status;\n}\nmsg.status = status;\nreturn msg;","outputs":1,"noerr":0,"x":372,"y":882,"wires":[["e1c0a7ef.cf0c28"]]},{"id":"e5f018bc.747c9","type":"ibmiot out","z":"60cfbb27.7bd1d4","authentication":"quickstart","apiKey":"","outputType":"evt","deviceId":"Sensors","deviceType":"Equipment","eventCommandType":"shutdown","format":"json","data":"{\"cmd\":\"shutdown\"}","qos":0,"name":"IBM IoT","service":"quickstart","x":1042,"y":882,"wires":[]},{"id":"e1c0a7ef.cf0c28","type":"switch","z":"60cfbb27.7bd1d4","name":"","property":"status","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"Failing","vt":"str"},{"t":"eq","v":"Running","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":612,"y":882,"wires":[["87527042.e7efc"],["5d1b88e5.62fe78"],["9d606002.fa491"]]},{"id":"5d1b88e5.62fe78","type":"function","z":"60cfbb27.7bd1d4","name":"Construct command","func":"var cmd = {}\ncmd = {\n \"cmd\":\"Shutdown\",\n }\nmsg.payload = cmd;\nreturn msg;","outputs":1,"noerr":0,"x":842,"y":882,"wires":[["e5f018bc.747c9","2a0e86dc.ebd882"]]},{"id":"87527042.e7efc","type":"debug","z":"60cfbb27.7bd1d4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":752,"y":842,"wires":[]},{"id":"9d606002.fa491","type":"debug","z":"60cfbb27.7bd1d4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"status","x":792,"y":942,"wires":[]},{"id":"2a0e86dc.ebd882","type":"debug","z":"60cfbb27.7bd1d4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":992,"y":942,"wires":[]},{"id":"81f40670.aa7f5","type":"comment","z":"60cfbb27.7bd1d4","name":"Store data into database / Invoke predctive analytics","info":"If database does not contain all the data, then the predictive analytics is not invoked.","x":374,"y":100,"wires":[]},{"id":"a747455c.71907","type":"ibmiot","z":"","name":"","keepalive":"60","serverName":"","cleansession":true,"appId":"","shared":false},{"id":"7e580743.ca826","type":"websocket-listener","z":"","path":"/ws/orchestrate","wholemsg":"false"}]
2 |
--------------------------------------------------------------------------------
/configuration/BMX/BMXReceiveProcessIoTTemp.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "be58e26e.1faca",
4 | "type": "ibmiot in",
5 | "z": "a60b8a97.0bd088",
6 | "authentication": "quickstart",
7 | "apiKey": "",
8 | "inputType": "evt",
9 | "deviceId": "kpedgetobmx20171207",
10 | "applicationId": "",
11 | "deviceType": "+",
12 | "eventType": "+",
13 | "commandType": "",
14 | "format": "json",
15 | "name": "IBM IoT",
16 | "service": "quickstart",
17 | "allDevices": "",
18 | "allApplications": "",
19 | "allDeviceTypes": true,
20 | "allEvents": true,
21 | "allCommands": "",
22 | "allFormats": "",
23 | "qos": 0,
24 | "x": 90,
25 | "y": 100,
26 | "wires": [
27 | [
28 | "c69c0fc3.2a4bf",
29 | "ac0456dc.7855e"
30 | ]
31 | ]
32 | },
33 | {
34 | "id": "c69c0fc3.2a4bf",
35 | "type": "debug",
36 | "z": "a60b8a97.0bd088",
37 | "name": "",
38 | "active": false,
39 | "console": "false",
40 | "complete": "payload",
41 | "x": 270,
42 | "y": 100,
43 | "wires": []
44 | },
45 | {
46 | "id": "ac0456dc.7855e",
47 | "type": "function",
48 | "z": "a60b8a97.0bd088",
49 | "name": "getTemperature",
50 | "func": "return {payload:parseFloat(msg.payload.d.value)};\n",
51 | "outputs": 1,
52 | "noerr": 0,
53 | "x": 280,
54 | "y": 180,
55 | "wires": [
56 | [
57 | "496324ba.c81eb4",
58 | "b38bf158.48135"
59 | ]
60 | ]
61 | },
62 | {
63 | "id": "496324ba.c81eb4",
64 | "type": "debug",
65 | "z": "a60b8a97.0bd088",
66 | "name": "",
67 | "active": true,
68 | "console": "false",
69 | "complete": "false",
70 | "x": 510,
71 | "y": 180,
72 | "wires": []
73 | },
74 | {
75 | "id": "b38bf158.48135",
76 | "type": "switch",
77 | "z": "a60b8a97.0bd088",
78 | "name": "Classify",
79 | "property": "payload",
80 | "propertyType": "msg",
81 | "rules": [
82 | {
83 | "t": "lte",
84 | "v": "30",
85 | "vt": "str"
86 | },
87 | {
88 | "t": "lte",
89 | "v": "45",
90 | "vt": "str"
91 | },
92 | {
93 | "t": "gt",
94 | "v": "45",
95 | "vt": "str"
96 | }
97 | ],
98 | "checkall": "true",
99 | "outputs": 3,
100 | "x": 280,
101 | "y": 300,
102 | "wires": [
103 | [
104 | "329f834.5f42efc",
105 | "73ad2d84.32d4b4"
106 | ],
107 | [
108 | "5cbdc1b1.89d878",
109 | "cde85339.6e98f"
110 | ],
111 | [
112 | "48715687.5744f",
113 | "1d2db6c8.fea829"
114 | ]
115 | ]
116 | },
117 | {
118 | "id": "329f834.5f42efc",
119 | "type": "template",
120 | "z": "a60b8a97.0bd088",
121 | "name": "Green",
122 | "field": "payload",
123 | "fieldType": "msg",
124 | "format": "handlebars",
125 | "syntax": "mustache",
126 | "template": "Cool: {{payload}} !",
127 | "output": "str",
128 | "x": 470,
129 | "y": 260,
130 | "wires": [
131 | [
132 | "a8662c37.b077b8"
133 | ]
134 | ]
135 | },
136 | {
137 | "id": "5cbdc1b1.89d878",
138 | "type": "template",
139 | "z": "a60b8a97.0bd088",
140 | "name": "Amber",
141 | "field": "payload",
142 | "fieldType": "msg",
143 | "format": "handlebars",
144 | "syntax": "mustache",
145 | "template": "Warm: {{payload}} !",
146 | "output": "str",
147 | "x": 471,
148 | "y": 298,
149 | "wires": [
150 | [
151 | "a8662c37.b077b8"
152 | ]
153 | ]
154 | },
155 | {
156 | "id": "48715687.5744f",
157 | "type": "template",
158 | "z": "a60b8a97.0bd088",
159 | "name": "Red",
160 | "field": "payload",
161 | "fieldType": "msg",
162 | "format": "handlebars",
163 | "syntax": "mustache",
164 | "template": "Hot: {{payload}} !",
165 | "output": "str",
166 | "x": 471,
167 | "y": 338,
168 | "wires": [
169 | [
170 | "a8662c37.b077b8"
171 | ]
172 | ]
173 | },
174 | {
175 | "id": "a8662c37.b077b8",
176 | "type": "debug",
177 | "z": "a60b8a97.0bd088",
178 | "name": "",
179 | "active": true,
180 | "console": "false",
181 | "complete": "false",
182 | "x": 670,
183 | "y": 300,
184 | "wires": []
185 | },
186 | {
187 | "id": "cb73afe4.516eb8",
188 | "type": "comment",
189 | "z": "a60b8a97.0bd088",
190 | "name": "IoT on IBM BMX - Analytics in Bluemix to Edge",
191 | "info": "Analyze data received from edge layer in \nBluemix and return a command of action",
192 | "x": 210,
193 | "y": 37,
194 | "wires": []
195 | },
196 | {
197 | "id": "73ad2d84.32d4b4",
198 | "type": "template",
199 | "z": "a60b8a97.0bd088",
200 | "name": "Green",
201 | "field": "payload",
202 | "fieldType": "msg",
203 | "format": "handlebars",
204 | "syntax": "mustache",
205 | "template": "Cool",
206 | "output": "str",
207 | "x": 470,
208 | "y": 400,
209 | "wires": [
210 | [
211 | "82404a7.f8acc38",
212 | "17420063.a494a8"
213 | ]
214 | ]
215 | },
216 | {
217 | "id": "cde85339.6e98f",
218 | "type": "template",
219 | "z": "a60b8a97.0bd088",
220 | "name": "Amber",
221 | "field": "payload",
222 | "fieldType": "msg",
223 | "format": "handlebars",
224 | "syntax": "mustache",
225 | "template": "Warm",
226 | "output": "str",
227 | "x": 471,
228 | "y": 438,
229 | "wires": [
230 | [
231 | "82404a7.f8acc38",
232 | "17420063.a494a8"
233 | ]
234 | ]
235 | },
236 | {
237 | "id": "1d2db6c8.fea829",
238 | "type": "template",
239 | "z": "a60b8a97.0bd088",
240 | "name": "Red",
241 | "field": "payload",
242 | "fieldType": "msg",
243 | "format": "handlebars",
244 | "syntax": "mustache",
245 | "template": "Hot",
246 | "output": "str",
247 | "x": 471,
248 | "y": 478,
249 | "wires": [
250 | [
251 | "82404a7.f8acc38",
252 | "17420063.a494a8"
253 | ]
254 | ]
255 | },
256 | {
257 | "id": "82404a7.f8acc38",
258 | "type": "debug",
259 | "z": "a60b8a97.0bd088",
260 | "name": "",
261 | "active": true,
262 | "console": "false",
263 | "complete": "false",
264 | "x": 670,
265 | "y": 420,
266 | "wires": []
267 | },
268 | {
269 | "id": "17420063.a494a8",
270 | "type": "function",
271 | "z": "a60b8a97.0bd088",
272 | "name": "Action Comand to Edge",
273 | "func": "// Create MQTT message in JSON\nvar act;\nif (msg.payload ==\"Hot\")\n act = \"fanon\";\nelse\n act = \"fanoff\";\n\nmsg = {\n payload: JSON.stringify(\n {\n d:{\n \"action\" : act}\n }\n )\n};\n\nreturn msg;\n",
274 | "outputs": 1,
275 | "noerr": 0,
276 | "x": 731.36669921875,
277 | "y": 548,
278 | "wires": [
279 | [
280 | "6b6a2b30.265b34",
281 | "82849ad1.6e6be"
282 | ]
283 | ]
284 | },
285 | {
286 | "id": "6b6a2b30.265b34",
287 | "type": "debug",
288 | "z": "a60b8a97.0bd088",
289 | "name": "",
290 | "active": true,
291 | "console": "false",
292 | "complete": "false",
293 | "x": 990,
294 | "y": 480,
295 | "wires": []
296 | },
297 | {
298 | "id": "82849ad1.6e6be",
299 | "type": "ibmiot out",
300 | "z": "a60b8a97.0bd088",
301 | "authentication": "quickstart",
302 | "apiKey": "",
303 | "outputType": "evt",
304 | "deviceId": "kpbmxtoedge20171207",
305 | "deviceType": "0.17.5",
306 | "eventCommandType": "action command",
307 | "format": "json",
308 | "data": "JSON",
309 | "qos": 0,
310 | "name": "IoT BMX Command to Edge",
311 | "service": "quickstart",
312 | "x": 1010,
313 | "y": 580,
314 | "wires": []
315 | }
316 | ]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IoT analytics using predictive models and integration with edge devices to send commands based on prediction outcomes
2 |
3 | Internet of Things (IoT) have evolved tremendously in all spheres of our lives like Industrial applications, Social interactions, Remote management of facilities and equipment to name a few. In general application areas, IoT data collected by Sensors can be used for monitoring as well as predicting the outcomes. If any deviation from the norm is detected, corrective action can be prescribed either manually or by an automated process. Such actions may come out of rule based anomaly detection or a Statistical Change point detection or a Predictive model that predicts a faulty condition ahead of time. This approach goes a long way in implementing Predictive maintenance which is more prudent approach than Scheduled Preventive maintenance which is periodic in nature.
4 |
5 | The end to end process steps for applying Analytics on IoT data are listed below:
6 | 1. Collect IoT data from sensor
7 | 2. Change point detection using IoT Sensor data. Refer code pattern [Detect change points in IoT sensor data](https://developer.ibm.com/code/patterns/detect-change-points-in-iot-sensor-data/) for more details.
8 | 3. Predicting equipment failure using IoT Sensor data. Refer code pattern [Predict equipment failure using IoT sensor data](https://developer.ibm.com/code/patterns/predict-equipment-failure-using-iot-sensor-data/) for more details.
9 | 4. Sending decisions based on Analytics insights to the edge for automated action
10 |
11 | This IBM Code Pattern is a composite pattern that demostrates the building of complete IoT analytics solution.
12 | When you complete this code pattern, you will learn how to:
13 | * Send events from an edge device (we use Raspberry Pi for demonstration) to the Watson IoT Platform
14 | * Store the events in a DB2 database on IBM Cloud
15 | * Invoke a predictive model on Watson Studio for IoT events using the below code patterns:
16 | - [Predict equipment failure using IoT sensor data](https://developer.ibm.com/code/patterns/predict-equipment-failure-using-iot-sensor-data/)
17 | - [Orchestrate data science workflows using Node-RED](https://github.com/IBM/node-red-dsx-workflow)
18 | * Send a command back to the edge (we use Raspberry Pi for demonstration) based on the outcome of the predictive model
19 |
20 | This pattern uses a sample equipment sensors data. This data is sent to the Watson IoT platform and stored in a DB2 database. A predictive model is built using the data in the DB2 database. The predictive model then takes the sensor events from Watson IoT platform as input and returns the state of the equipment as `Running` or `Failing`. If the equipment is failing, then a shutdown command is sent back to the edge device which is a Raspberry Pi.
21 |
22 | This pattern uses [Node-RED](https://nodered.org/) at both device and cloud for building the solution:
23 | - Implementing device client on Raspberry Pi to send events to Watson IoT platform
24 | - Consuming events from Watson IoT platform on IBM Cloud and storing the events in a DB2 database
25 | - Invoke predictive model on Watson Studio and get a response back for an IoT event
26 | - Send a command back to the Raspberry Pi through the Watson IoT platform
27 |
28 | ## Prerequisites:
29 | * [Connect Raspberry Pi to the network and Note IP address for accessing the Pi](https://www.raspberrypi.org/documentation/)
30 | * [Running Node-RED on Raspberry Pi](https://nodered.org/docs/hardware/raspberrypi)
31 |
32 | ## Flow
33 | 
34 |
35 | 1. The Raspberry Pi gets events from the sensors. In the absence of sensors, the sensor events are read from a file.
36 | 2. The Node-RED flows are invoked on the Raspberry Pi.
37 | 3. The sensor events are sent to the Watson IoT platform.
38 | 4. The Watson IoT platform receives the events and sends it to all subscribing applications.
39 | 5. The Node-RED flows on IBM Cloud are triggered. The sensor events are recieved and stored into a database.
40 | 6. The predictive model on Watson Studio is triggered. The outcome of the model execution is sent back to the Node-RED through websockets.
41 | 7. Based on the outcome, the Node-RED flow sends a command with the action to be taken to the edge device(Raspberry Pi) through the Watson IoT platform
42 | 8. The Node-RED flow on Raspberry Pi recieve the command
43 |
44 | ## Included Components
45 | * [IBM Cloud](https://console.bluemix.net/catalog/): IBM's innovative cloud computing platform or IBM Cloud (formerly Bluemix) combines
46 | platform as a service (PaaS) with infrastructure as a service (IaaS) and includes a rich catalog of
47 | cloud services that can be easily integrated with PaaS and IaaS to build business applications rapidly.
48 | * [IBM Watson IoT Platform](https://internetofthings.ibmcloud.com/): IBM Watson™ IoT Platform for IBM Cloud gives you a versatile
49 | toolkit that includes gateway devices, device management, and powerful application access. By using
50 | Watson IoT Platform, you can collect connected device data and perform analytics on real-time data
51 | from your organization.
52 | * [IBM Watson Studio](https://www.ibm.com/bs-en/marketplace/data-science-experience): Analyze data using Python, Jupyter Notebook
53 | and RStudio in a configured, collaborative environment that includes IBM value-adds, such as managed Spark.
54 | * [DB2 Warehouse](https://console.bluemix.net/catalog/services/db2-warehouse): IBM Db2 Warehouse on Cloud is a fully-managed, enterprise-class, cloud data warehouse service.
55 |
56 | ## Featured Technologies
57 |
58 | * [Analytics](https://developer.ibm.com/code/technologies/analytics?cm=IBMCode-_--_-featured_technologies-_-analytics): Finding patterns in data to derive information.
59 | * [Data Science](https://developer.ibm.com/code/technologies/data-science?cm=IBMCode-_--_-featured_technologies-_-data-science): Systems and scientific methods to analyze structured and unstructured data in
60 | order to extract knowledge and insights.
61 | * [Internet of Things](https://en.wikipedia.org/wiki/Internet_of_things)
62 |
63 | ## Watch the Video
64 |
65 | * [Video](https://youtu.be/2CJcqMPIFaY)
66 |
67 | ## Steps
68 |
69 | 1. [Create IBM Cloud services and configure](#1-create-ibm-cloud-services-and-configure)
70 | 2. [Configure Raspberry Pi](#2-configure-raspberry-pi)
71 | 3. [Trigger the Node-RED flow on Raspberry Pi](#3-trigger-the-node-red-flow-on-raspberry-pi)
72 | 4. [Run the notebook](#4-run-the-notebook)
73 | 5. [Analyze results](#5-analyze-results)
74 |
75 | ### 1. Create IBM Cloud services and configure
76 |
77 | #### Internet of Things Platform
78 | * Click on [Internet of Things Platform](https://console.bluemix.net/catalog/services/internet-of-things-platform) and create an instance of Internet of Things Platform.
79 | 
80 |
81 | * Click on `Launch` to launch the `Dashboard`
82 | 
83 |
84 | * Create a device type `Equipment` and device `Sensors`.
85 | Refer [documentation](https://console.bluemix.net/docs/services/IoT/getting-started.html#getting-started-with-iotp) and [article](https://developer.ibm.com/recipes/tutorials/how-to-register-devices-in-ibm-iot-foundation/).
86 | 
87 |
88 | * Note down the device credentials. They cannot be retrieved later.
89 | > The device credentials will be used later to configure Node-RED.
90 |
91 | * Click on `Apps` on the menu.
92 | 
93 |
94 | * Click on `Generate API Key`. Click `Next`.
95 | * Select the role as `Data processor application`.
96 | 
97 |
98 | * Make a note of the `API Key` and `Authentication Token`. This will be needed in the Node-RED flow configuration in the subsequent steps.
99 | 
100 |
101 |
102 | #### DB2 Warehouse
103 | * Create a [DB2 Warehouse](https://console.bluemix.net/catalog/services/db2-warehouse) instance.
104 | 
105 | > Make a note of the service name. This needs to be bound to Node-RED that is created in the next step.
106 | * Click on `Service Credentials`. Click on `New Credential`. Click on `View Credentials`.
107 | 
108 | > Make a note of the database credentials to be entered into Watson Studio notebook later.
109 |
110 | * Click on `Manage`
111 | * Click on `Open` to launch the `Dashboard`
112 | * Click on `Explore`.
113 | * Click on the schema starting with `DASH`.
114 | 
115 | > Make a note of the schema name to be configured later on Watson Studio.
116 |
117 | * Click on `New Table` and create a table `EQUIPMENT_DATA` with the configuration as shown.
118 | 
119 |
120 | #### Node-RED on IBM Cloud
121 | * Create the [Node-RED Starter application](https://console.bluemix.net/catalog/starters/node-red-starter).
122 | * Choose an appropriate name for the Node-RED application - `App name:`.
123 | * Click on `Create`.
124 |
125 | 
126 |
127 | * On the newly created Node-RED application page, click on `Connections`.
128 | * Click on `Create Connection` and select the DB2 Warehouse service that was created in the previous step. Click on `Connect`. This binds the DB2 Warehouse service to Node-RED.
129 | * Click on `Getting Started`.
130 | * Click on `Visit App URL` to launch the Node-RED editor once the application is in `Running` state.
131 | * On the `Welcome to your new Node-RED instance on IBM Cloud` screen, Click on `Next`.
132 | * On the `Secure your Node-RED editor` screen, enter a username and password to secure the Node-RED editor and click on `Next`.
133 | * On the `Browse available IBM Cloud nodes` screen, click on `Next`.
134 | * On the `Finish the install` screen, click on Finish.
135 | * Click on `Go to your Node-RED flow editor`.
136 |
137 | ##### Import the Node-RED flow
138 |
139 | * [Clone this repo](https://github.com/IBM/iot-edge-predictive-models-dsx).
140 | * Navigate to the [orchestrate_dsx_workflow.json](node-red-flow/orchestrate_dsx_workflow.json).
141 | * Open the file with a text editor and copy the contents to Clipboard.
142 | * On the Node-RED flow editor, click the Menu and select `Import` -> `Clipboard` and paste the contents.
143 | 
144 |
145 | The imported Node-RED flow appears on the editor.
146 | 
147 |
148 |
149 | * On the two DB2 nodes named `EQUIPMENT_DATA`. Select the DB2 Warehouse service.
150 | 
151 |
152 | * Configure the two IoT nodes with the API Key and Authentication Token. Click on `Edit` icon shown in the image.
153 | 
154 |
155 | * Enter the `API Key` and `Authentication Token` noted earlier.
156 | 
157 |
158 | ##### Deploy the Node-RED flow by clicking on the `Deploy` button
159 |
160 | 
161 |
162 | ##### Note the websocket URL
163 |
164 | 
165 |
166 | The websocket URL is ws://``/ws/orchestrate where the `NODERED_BASE_URL` is the marked portion of the URL in the above image.
167 | ### Note:
168 | An example websocket URL for a Node-RED app with name `myApp` is `ws://myApp.mybluemix.net/ws/orchestrate`, where `myApp.mybluemix.net` is the `NODERED_BASE_URL`.
169 |
170 | The `NODERED_BASE_URL` may have additional region information i.e. `eu-gb` for the UK region. In this case `NODERED_BASE_URL` would be: `myApp.eu-gb.mybluemix.net`.
171 |
172 | #### Watson Studio
173 | * Sign up for IBM's [Watson Studio](https://dataplatform.ibm.com/).
174 | * Create a project if necessary, provisioning an object storage service if required.
175 | * In the `Assets` tab, select the `Create notebook` option.
176 | * Select the `From URL` tab.
177 | * Enter a name for the notebook.
178 | * Optionally, enter a description for the notebook.
179 | * Enter this Notebook URL: https://github.com/IBM/iot-edge-predictive-models-dsx/blob/master/notebooks/watson_iotfailure_prediction_integrated.ipynb
180 | * Select the free runtime.
181 | * Click the `Create` button.
182 | 
183 |
184 | * In Section 7. of the notebook, enter the websocket URL noted earlier.
185 | 
186 |
187 | * In Section 4. of the notebook, enter the database credentials for DB2 Warehouse noted earlier.
188 | 
189 |
190 | ### 2. Configure Raspberry Pi
191 |
192 | #### Copy the data file to Raspberry Pi and start Node-RED
193 |
194 | The data file can be found at the location - https://github.com/IBM/iot-edge-predictive-models-dsx/blob/master/data. Using ftp the file `iot_sensor_dataset.csv` is transferred to the Pi. The file is stored at the location `/home/pi`. After that Node-RED is started by running the command `node-red`.
195 |
196 | ##### Copy data file
197 | 
198 |
199 | ##### Start Node-RED
200 | 
201 |
202 | #### Configure Node-RED on the Raspberry Pi
203 |
204 | * Navigate to the [pi_flow.json](node-red-flow/pi_flow.json).
205 | * Open the file with a text editor and copy the contents to Clipboard.
206 | * Access Node-RED using the IP address of the RaspberryPi as shown below.
207 | * On the Node-RED flow editor, click the Menu and select `Import` -> `Clipboard` and paste the contents.
208 | 
209 |
210 | The below flow will be imported into the Node-RED editor.
211 | 
212 |
213 | * Click on the `event` node.
214 |
215 | 
216 |
217 | * Configure the device credentials noted earlier.
218 | 
219 |
220 | * Click on the `all commands` node. Select the credentials configured in the previous step.
221 | 
222 |
223 | * Click on `Deploy` to deploy the Node-RED flow.
224 |
225 | ## 3. Trigger the Node-RED flow on Raspberry Pi
226 | Click on the inject node `Sensor event trigger`. This will send sensor events to the Watson IoT Platform. These events will get stored in the DB2 Warehouse.
227 | 
228 |
229 | ## 4. Run the notebook
230 | > Note: Only after the previous step (3. Trigger the Node-RED flow on Raspberry Pi) is complete and all events are stored into the DB2 Warehouse, run the cells in the notebook. The data in the DB2 Warehouse is then used for building the model.
231 |
232 | When a notebook is executed, what is actually happening is that each code cell in the notebook is executed, in order, from top to bottom.
233 |
234 | Each code cell is selectable and is preceded by a tag in the left margin. The tag
235 | format is `In [x]:`. Depending on the state of the notebook, the `x` can be:
236 |
237 | * A `blank`, this indicates that the cell has never been executed.
238 | * A `number`, this number represents the relative order this code step was executed.
239 | * A `*`, this indicates that the cell is currently executing.
240 |
241 | There are several ways to execute the code cells in your notebook:
242 |
243 | * One cell at a time.
244 | * Select the cell, and then press the `Play` button in the toolbar.
245 | * Batch mode, in sequential order.
246 | * From the `Cell` menu bar, there are several options available. For example, you
247 | can `Run All` cells in your notebook, or you can `Run All Below`, that will
248 | start executing from the first cell under the currently selected cell, and then
249 | continue executing all cells that follow.
250 | * At a scheduled time.
251 | * Press the `Schedule` button located in the top right section of your notebook
252 | panel. Here you can schedule your notebook to be executed once at some future
253 | time, or repeatedly at your specified interval.
254 |
255 | For this Notebook, you can simply `Run All` cells.
256 | The websocket client will be started when you run the cell under `7. Start websocket client`. This will start the communication between the UI and the Notebook.
257 |
258 | ## 5. Analyze results
259 | Go to the Node-RED flow on the Raspberry Pi.
260 | Click on the inject node `Event - Running`. This sends an event with values indicating a good health to the Watson IoT Platform.
261 | Click on the inject node `Event - Failing`. This sends an event with values indicating a failing health to the Watson IoT Platform. A shutdown command is received from the Watson IoT platform after running of the predictive model.
262 | 
263 |
264 | ## 6. Troubleshooting
265 | See [Debugging.md](https://github.com/IBM/iot-edge-predictive-models-dsx/blob/master/DEBUGGING.md)
266 |
267 | ## 7. License
268 | This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](http://www.apache.org/licenses/LICENSE-2.0.txt).
269 |
270 | [Apache Software License (ASL) FAQ](http://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN)
271 |
272 |
--------------------------------------------------------------------------------
/notebooks/watson_iotfailure_prediction_integrated.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {
6 | "collapsed": true
7 | },
8 | "source": [
9 | "# IoT Equipment Failure Prediction using Sensor data\n",
10 | "## 1 Environment Setup\n",
11 | "### 1.1 Install packages and Import dependent libraries"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": 1,
17 | "metadata": {},
18 | "outputs": [
19 | {
20 | "name": "stdout",
21 | "output_type": "stream",
22 | "text": [
23 | "Collecting websocket-client\n",
24 | " Downloading https://files.pythonhosted.org/packages/8a/a1/72ef9aa26cfe1a75cee09fc1957e4723add9de098c15719416a1ee89386b/websocket_client-0.48.0-py2.py3-none-any.whl (198kB)\n",
25 | "\u001b[K 100% |████████████████████████████████| 204kB 3.8MB/s eta 0:00:01\n",
26 | "\u001b[?25hRequirement not upgraded as not directly required: six in /opt/conda/envs/DSX-Python35/lib/python3.5/site-packages (from websocket-client)\n",
27 | "Installing collected packages: websocket-client\n",
28 | "Successfully installed websocket-client-0.48.0\n"
29 | ]
30 | }
31 | ],
32 | "source": [
33 | "!pip install websocket-client\n",
34 | "\n",
35 | "# Import libraries\n",
36 | "import pandas as pd\n",
37 | "import numpy as np\n",
38 | "import pdb\n",
39 | "import json\n",
40 | "import re\n",
41 | "import requests\n",
42 | "import sys\n",
43 | "import types\n",
44 | "import ibm_boto3\n",
45 | "import websocket"
46 | ]
47 | },
48 | {
49 | "cell_type": "code",
50 | "execution_count": 2,
51 | "metadata": {},
52 | "outputs": [
53 | {
54 | "name": "stderr",
55 | "output_type": "stream",
56 | "text": [
57 | "/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
58 | " \"This module will be removed in 0.20.\", DeprecationWarning)\n"
59 | ]
60 | }
61 | ],
62 | "source": [
63 | "# Import libraries\n",
64 | "from io import StringIO\n",
65 | "from sklearn.cross_validation import train_test_split\n",
66 | "from sklearn.linear_model import LogisticRegression\n",
67 | "from sklearn import metrics\n",
68 | "from botocore.client import Config"
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {},
74 | "source": [
75 | "## 2 Create IoT Predictive Analytics Functions"
76 | ]
77 | },
78 | {
79 | "cell_type": "code",
80 | "execution_count": 3,
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "# Function to extract Column names of dataset\n",
85 | "def dataset_columns(dataset):\n",
86 | " return list(dataset.columns.values)\n",
87 | "\n",
88 | "# Function to train Logistic regression model\n",
89 | "def train_logistic_regression(x_vals, y_vals):\n",
90 | " logistic_regression_model = LogisticRegression()\n",
91 | " logistic_regression_model.fit(x_vals, y_vals)\n",
92 | " return logistic_regression_model\n",
93 | "\n",
94 | "# Function to return Predicted values\n",
95 | "def score_data(trained_model, x_vals):\n",
96 | " ypredict = trained_model.predict(x_vals)\n",
97 | " return ypredict\n",
98 | "\n",
99 | "# Function to calculate Prediction accuracy of model\n",
100 | "def model_accuracy(trained_model, variables, targets):\n",
101 | " accuracy_score = trained_model.score(variables, targets)\n",
102 | " return accuracy_score\n",
103 | "\n",
104 | "# Function to generate Confusion matrix\n",
105 | "def confusion_matrix(actfail, predictfail):\n",
106 | " # Compute Confusion matrix\n",
107 | " print(\"Actual, Predicted Observations: \",len(actfail), len(predictfail))\n",
108 | " # print(actfail, predictfail)\n",
109 | " anpn = 0\n",
110 | " anpy = 0\n",
111 | " aypn = 0\n",
112 | " aypy = 0\n",
113 | " \n",
114 | " for i in range(len(actfail)):\n",
115 | " if (actfail[i]==0 and predictfail[i]==0):\n",
116 | " anpn = anpn + 1\n",
117 | " elif (actfail[i]==0 and predictfail[i]==1):\n",
118 | " anpy = anpy + 1\n",
119 | " elif (actfail[i]==1 and predictfail[i]==0):\n",
120 | " aypn = aypn + 1\n",
121 | " else:\n",
122 | " aypy = aypy + 1\n",
123 | " # Confusoin matrix\n",
124 | " print (\"--------------------------------------------\")\n",
125 | " print (\"Confusion Matrix\")\n",
126 | " print (\"--------------------------------------------\")\n",
127 | " print (\" \", \"Predicted N\", \"Predicted Y\")\n",
128 | " print (\"Actual N \", anpn,\" \", anpy) \n",
129 | " print (\"Actual Y \", aypn,\" \", aypy)\n",
130 | " print (\"--------------------------------------------\")\n",
131 | " print (\"Total observations : \", anpn+anpy+aypn+aypy)\n",
132 | " print (\"False Positives : \", anpy)\n",
133 | " print (\"False Negatives : \", aypn)\n",
134 | " print (\"Overall Accuracy : \", round((float(anpn+aypy)/float(anpn+anpy+aypn+aypy))*100, 2), \"%\")\n",
135 | " print (\"Sensitivity/Recall : \", round((float(aypy)/float(aypn+aypy))*100, 2), \"%\")\n",
136 | " print (\"Specificity : \", round((float(anpn)/float(anpn+anpy))*100, 2), \"%\")\n",
137 | " print (\"Precision : \", round((float(aypy)/float(anpy+aypy))*100, 2), \"%\")\n",
138 | " print (\"--------------------------------------------\")\n"
139 | ]
140 | },
141 | {
142 | "cell_type": "markdown",
143 | "metadata": {},
144 | "source": [
145 | "## 3. Read Configuration parametric values"
146 | ]
147 | },
148 | {
149 | "cell_type": "code",
150 | "execution_count": 4,
151 | "metadata": {},
152 | "outputs": [],
153 | "source": [
154 | "# Function to Read json parametric values\n",
155 | "def f_getconfigval(injsonstr, invarname):\n",
156 | " # paramname, paramvalue\n",
157 | " # Unpack the json parameter values\n",
158 | " # This section requires regex\n",
159 | " for i in range(len(injsonstr)):\n",
160 | " pair = injsonstr[i]\n",
161 | " # Return parametric value\n",
162 | " if pair['paramname'] == invarname:\n",
163 | " return(pair['paramvalue'])"
164 | ]
165 | },
166 | {
167 | "cell_type": "code",
168 | "execution_count": 5,
169 | "metadata": {},
170 | "outputs": [
171 | {
172 | "name": "stdout",
173 | "output_type": "stream",
174 | "text": [
175 | "[{'paramname': 'features', 'paramvalue': \"['ATEMP', 'PID', 'OUTPRESSURE', 'INPRESSURE', 'TEMP']\"}, {'paramname': 'target', 'paramvalue': 'FAIL'}, {'paramname': 'data_size', 'paramvalue': '0.7'}]\n"
176 | ]
177 | }
178 | ],
179 | "source": [
180 | "# Configuration parameters\n",
181 | "\n",
182 | "d = [{'paramvalue': \"['ATEMP', 'PID', 'OUTPRESSURE', 'INPRESSURE', 'TEMP']\", 'paramname': 'features'}, {'paramvalue': 'FAIL', 'paramname': 'target'}, {'paramvalue': '0.7', 'paramname': 'data_size'}]\n",
183 | "print(d)\n"
184 | ]
185 | },
186 | {
187 | "cell_type": "code",
188 | "execution_count": 6,
189 | "metadata": {},
190 | "outputs": [],
191 | "source": [
192 | "# Read JSON configuration parametric values\n",
193 | "# Unpack the json parameter values\n",
194 | "# This section uses regex\n",
195 | "v_feature_list = eval(\"list(\"+ f_getconfigval(d, \"features\") +\")\")\n",
196 | "v_target = str(f_getconfigval(d, \"target\"))\n",
197 | "v_train_datasize = float(f_getconfigval(d, \"data_size\"))\n"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": 7,
203 | "metadata": {},
204 | "outputs": [
205 | {
206 | "name": "stdout",
207 | "output_type": "stream",
208 | "text": [
209 | "['ATEMP', 'PID', 'OUTPRESSURE', 'INPRESSURE', 'TEMP'] FAIL 0.7\n"
210 | ]
211 | }
212 | ],
213 | "source": [
214 | "# Verify configuration parametric values\n",
215 | "# print (feature_list, target, train_datasize)\n",
216 | "print (v_feature_list, v_target, v_train_datasize)"
217 | ]
218 | },
219 | {
220 | "cell_type": "markdown",
221 | "metadata": {},
222 | "source": [
223 | "## 4 Read IoT Sensor data from database"
224 | ]
225 | },
226 | {
227 | "cell_type": "code",
228 | "execution_count": 8,
229 | "metadata": {},
230 | "outputs": [
231 | {
232 | "name": "stdout",
233 | "output_type": "stream",
234 | "text": [
235 | "Number of Observations : 540\n"
236 | ]
237 | },
238 | {
239 | "data": {
240 | "text/html": [
241 | "\n",
242 | "\n",
255 | "
\n",
256 | " \n",
257 | " \n",
258 | " | \n",
259 | " FOOTFALL | \n",
260 | " ATEMP | \n",
261 | " SELFLR | \n",
262 | " CLINLR | \n",
263 | " DOLELR | \n",
264 | " PID | \n",
265 | " OUTPRESSURE | \n",
266 | " INPRESSURE | \n",
267 | " TEMP | \n",
268 | " FAIL | \n",
269 | "
\n",
270 | " \n",
271 | " \n",
272 | " \n",
273 | " | 0 | \n",
274 | " 0 | \n",
275 | " 7 | \n",
276 | " 7 | \n",
277 | " 1 | \n",
278 | " 6 | \n",
279 | " 6 | \n",
280 | " 36 | \n",
281 | " 3 | \n",
282 | " 1 | \n",
283 | " 1 | \n",
284 | "
\n",
285 | " \n",
286 | " | 1 | \n",
287 | " 190 | \n",
288 | " 1 | \n",
289 | " 3 | \n",
290 | " 3 | \n",
291 | " 5 | \n",
292 | " 1 | \n",
293 | " 20 | \n",
294 | " 4 | \n",
295 | " 1 | \n",
296 | " 0 | \n",
297 | "
\n",
298 | " \n",
299 | " | 2 | \n",
300 | " 110 | \n",
301 | " 3 | \n",
302 | " 3 | \n",
303 | " 4 | \n",
304 | " 6 | \n",
305 | " 1 | \n",
306 | " 21 | \n",
307 | " 4 | \n",
308 | " 1 | \n",
309 | " 0 | \n",
310 | "
\n",
311 | " \n",
312 | " | 3 | \n",
313 | " 100 | \n",
314 | " 7 | \n",
315 | " 5 | \n",
316 | " 6 | \n",
317 | " 4 | \n",
318 | " 1 | \n",
319 | " 77 | \n",
320 | " 4 | \n",
321 | " 1 | \n",
322 | " 0 | \n",
323 | "
\n",
324 | " \n",
325 | " | 4 | \n",
326 | " 31 | \n",
327 | " 1 | \n",
328 | " 5 | \n",
329 | " 4 | \n",
330 | " 5 | \n",
331 | " 4 | \n",
332 | " 21 | \n",
333 | " 4 | \n",
334 | " 1 | \n",
335 | " 0 | \n",
336 | "
\n",
337 | " \n",
338 | "
\n",
339 | "
"
340 | ],
341 | "text/plain": [
342 | " FOOTFALL ATEMP SELFLR CLINLR DOLELR PID OUTPRESSURE INPRESSURE \\\n",
343 | "0 0 7 7 1 6 6 36 3 \n",
344 | "1 190 1 3 3 5 1 20 4 \n",
345 | "2 110 3 3 4 6 1 21 4 \n",
346 | "3 100 7 5 6 4 1 77 4 \n",
347 | "4 31 1 5 4 5 4 21 4 \n",
348 | "\n",
349 | " TEMP FAIL \n",
350 | "0 1 1 \n",
351 | "1 1 0 \n",
352 | "2 1 0 \n",
353 | "3 1 0 \n",
354 | "4 1 0 "
355 | ]
356 | },
357 | "execution_count": 8,
358 | "metadata": {},
359 | "output_type": "execute_result"
360 | }
361 | ],
362 | "source": [
363 | "# Read data from DB2 warehouse in BMX\n",
364 | "# -----------------------------------\n",
365 | "from ibmdbpy import IdaDataBase, IdaDataFrame\n",
366 | "\n",
367 | "# Call function to read data for specific sensor\n",
368 | "# @hidden_cell\n",
369 | "# The section below needs to be modified:\n",
370 | "# Insert your credentials to read data from your data sources and replace \n",
371 | "# the idaConnect() section below\n",
372 | "# This connection object is used to access your data and contains your credentials.\n",
373 | "idadb_d281f6cd34eb4bc98f0183a45598dbb9 = IdaDataBase(dsn='DASHDB;Database=BLUDB;Hostname=;Port=50000;PROTOCOL=TCPIP;UID=;PWD=')\n",
374 | "\n",
375 | "df_iotdata = IdaDataFrame(idadb_d281f6cd34eb4bc98f0183a45598dbb9, '.EQUIPMENT_DATA').as_dataframe()\n",
376 | "\n",
377 | "# Check Number of observations read for analysis\n",
378 | "print (\"Number of Observations :\", len(df_iotdata))\n",
379 | "# Inspect a few observations\n",
380 | "df_iotdata.head()\n"
381 | ]
382 | },
383 | {
384 | "cell_type": "code",
385 | "execution_count": 9,
386 | "metadata": {},
387 | "outputs": [
388 | {
389 | "name": "stdout",
390 | "output_type": "stream",
391 | "text": [
392 | "Data set columns : ['FOOTFALL', 'ATEMP', 'SELFLR', 'CLINLR', 'DOLELR', 'PID', 'OUTPRESSURE', 'INPRESSURE', 'TEMP', 'FAIL']\n"
393 | ]
394 | }
395 | ],
396 | "source": [
397 | "# Print dataset column names\n",
398 | "datacolumns = dataset_columns(df_iotdata)\n",
399 | "print (\"Data set columns : \", list(datacolumns))"
400 | ]
401 | },
402 | {
403 | "cell_type": "markdown",
404 | "metadata": {},
405 | "source": [
406 | "## 5 Run Failure Prediction algorithm on IoT data\n",
407 | "### 5.1 Split data into Training and Test data"
408 | ]
409 | },
410 | {
411 | "cell_type": "code",
412 | "execution_count": 10,
413 | "metadata": {},
414 | "outputs": [
415 | {
416 | "name": "stdout",
417 | "output_type": "stream",
418 | "text": [
419 | "Train x counts : 378 5\n",
420 | "Train y counts : 378\n",
421 | "Test x counts : 162 5\n",
422 | "Test y counts : 162\n"
423 | ]
424 | }
425 | ],
426 | "source": [
427 | "# Split Training and Testing data\n",
428 | "train_x, test_x, train_y, test_y = train_test_split(df_iotdata[v_feature_list], df_iotdata[v_target], train_size=v_train_datasize)\n",
429 | "print (\"Train x counts : \", len(train_x), len(train_x.columns.values))\n",
430 | "print (\"Train y counts : \", len(train_y))\n",
431 | " \n",
432 | "print (\"Test x counts : \", len(test_x), len(test_x.columns.values))\n",
433 | "print (\"Test y counts : \", len(test_y))\n"
434 | ]
435 | },
436 | {
437 | "cell_type": "markdown",
438 | "metadata": {},
439 | "source": [
440 | "### 5.2 Train the Predictive model"
441 | ]
442 | },
443 | {
444 | "cell_type": "code",
445 | "execution_count": 11,
446 | "metadata": {},
447 | "outputs": [
448 | {
449 | "name": "stdout",
450 | "output_type": "stream",
451 | "text": [
452 | "Training Accuracy : 92.06 %\n"
453 | ]
454 | }
455 | ],
456 | "source": [
457 | "# Training Logistic regression model\n",
458 | "trained_logistic_regression_model = train_logistic_regression(train_x, train_y)\n",
459 | "\n",
460 | "train_accuracy = model_accuracy(trained_logistic_regression_model, train_x, train_y)\n",
461 | "\n",
462 | "# Testing the logistic regression model\n",
463 | "test_accuracy = model_accuracy(trained_logistic_regression_model, test_x, test_y)\n",
464 | "\n",
465 | "print (\"Training Accuracy : \", round(train_accuracy * 100, 2), \"%\")\n",
466 | "\n"
467 | ]
468 | },
469 | {
470 | "cell_type": "markdown",
471 | "metadata": {},
472 | "source": [
473 | "### 5.3 Score the Test data using the Trained model"
474 | ]
475 | },
476 | {
477 | "cell_type": "code",
478 | "execution_count": 12,
479 | "metadata": {},
480 | "outputs": [],
481 | "source": [
482 | "# Model accuracy: Score and construct Confusion matrix for Test data\n",
483 | "actfail = test_y.values\n",
484 | "predictfail = score_data(trained_logistic_regression_model, test_x)"
485 | ]
486 | },
487 | {
488 | "cell_type": "markdown",
489 | "metadata": {},
490 | "source": [
491 | "## 6 Confusion matrix for deeper analysis of Prediction accuracy\n",
492 | "##### Confusion matrix outputs below can be used for calculating more customised Accuracy metrics"
493 | ]
494 | },
495 | {
496 | "cell_type": "code",
497 | "execution_count": 13,
498 | "metadata": {},
499 | "outputs": [
500 | {
501 | "name": "stdout",
502 | "output_type": "stream",
503 | "text": [
504 | "Actual, Predicted Observations: 162 162\n",
505 | "--------------------------------------------\n",
506 | "Confusion Matrix\n",
507 | "--------------------------------------------\n",
508 | " Predicted N Predicted Y\n",
509 | "Actual N 100 8\n",
510 | "Actual Y 5 49\n",
511 | "--------------------------------------------\n",
512 | "Total observations : 162\n",
513 | "False Positives : 8\n",
514 | "False Negatives : 5\n",
515 | "Overall Accuracy : 91.98 %\n",
516 | "Sensitivity/Recall : 90.74 %\n",
517 | "Specificity : 92.59 %\n",
518 | "Precision : 85.96 %\n",
519 | "--------------------------------------------\n"
520 | ]
521 | }
522 | ],
523 | "source": [
524 | "# Print Count of Actual fails, Predicted fails\n",
525 | "# Print Confusion matrix\n",
526 | "confusion_matrix(actfail, predictfail)"
527 | ]
528 | },
529 | {
530 | "cell_type": "markdown",
531 | "metadata": {},
532 | "source": [
533 | "## 7. Expose integration point with a websocket client"
534 | ]
535 | },
536 | {
537 | "cell_type": "code",
538 | "execution_count": 14,
539 | "metadata": {},
540 | "outputs": [],
541 | "source": [
542 | "def on_message(ws, message):\n",
543 | " msg = json.loads(message)\n",
544 | " cmd = msg['cmd'];\n",
545 | " \n",
546 | " if(cmd == 'predict'):\n",
547 | " d = {'ATEMP': [msg['atemp']], 'PID': [msg['PID']], 'OUTPRESSURE':[msg['outpressure']], 'INPRESSURE':msg['inpressure'], 'TEMP':msg['temp']}\n",
548 | " df = pd.DataFrame(data=d)\n",
549 | " predict_fail = score_data(trained_logistic_regression_model, df)\n",
550 | " fail = predict_fail[0]\n",
551 | " status = \"Running\";\n",
552 | " if(fail == 0):\n",
553 | " status = \"Running\";\n",
554 | " else:\n",
555 | " status = \"Failing\";\n",
556 | " response = {}\n",
557 | " response['cmd'] = 'response';\n",
558 | " response['status'] = status;\n",
559 | " print(msg)\n",
560 | " print(response)\n",
561 | " ws.send(json.dumps(response));\n",
562 | " \n",
563 | "def on_error(ws, error):\n",
564 | " print(error)\n",
565 | "\n",
566 | "def on_close(ws):\n",
567 | " ws.send(\"DSX Listen End\")\n",
568 | "\n",
569 | "def on_open(ws):\n",
570 | " def run(*args):\n",
571 | " for i in range(10000):\n",
572 | " hbeat = '{\"cmd\":\"DSX HeartBeat\"}'\n",
573 | " ws.send(hbeat)\n",
574 | " time.sleep(100)\n",
575 | " \n",
576 | " _thread.start_new_thread(run, ())\n",
577 | "\n",
578 | "\n",
579 | "def start_websocket_listener():\n",
580 | " websocket.enableTrace(True)\n",
581 | " ws = websocket.WebSocketApp(\"ws:///ws/orchestrate\",\n",
582 | " on_message = on_message,\n",
583 | " on_error = on_error,\n",
584 | " on_close = on_close)\n",
585 | " ws.on_open = on_open\n",
586 | " ws.run_forever()"
587 | ]
588 | },
589 | {
590 | "cell_type": "code",
591 | "execution_count": 15,
592 | "metadata": {},
593 | "outputs": [
594 | {
595 | "name": "stderr",
596 | "output_type": "stream",
597 | "text": [
598 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_app.py\", line 320, in _callback\n",
599 | " callback(self, *args)\n",
600 | " File \"\", line 35, in on_open\n",
601 | " _thread.start_new_thread(run, ())\n"
602 | ]
603 | },
604 | {
605 | "name": "stdout",
606 | "output_type": "stream",
607 | "text": [
608 | "\n"
609 | ]
610 | },
611 | {
612 | "name": "stderr",
613 | "output_type": "stream",
614 | "text": [
615 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_app.py\", line 320, in _callback\n",
616 | " callback(self, *args)\n",
617 | " File \"\", line 26, in on_close\n",
618 | " ws.send(\"DSX Listen End\")\n",
619 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_app.py\", line 151, in send\n",
620 | " if not self.sock or self.sock.send(data, opcode) == 0:\n",
621 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_core.py\", line 240, in send\n",
622 | " return self.send_frame(frame)\n",
623 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_core.py\", line 265, in send_frame\n",
624 | " l = self._send(data)\n",
625 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_core.py\", line 430, in _send\n",
626 | " return send(self.sock, data)\n",
627 | " File \"/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/websocket/_socket.py\", line 114, in send\n",
628 | " raise WebSocketConnectionClosedException(\"socket is already closed.\")\n"
629 | ]
630 | }
631 | ],
632 | "source": [
633 | "start_websocket_listener();"
634 | ]
635 | },
636 | {
637 | "cell_type": "code",
638 | "execution_count": null,
639 | "metadata": {},
640 | "outputs": [],
641 | "source": []
642 | }
643 | ],
644 | "metadata": {
645 | "kernelspec": {
646 | "display_name": "Python 3.5",
647 | "language": "python",
648 | "name": "python3"
649 | },
650 | "language_info": {
651 | "codemirror_mode": {
652 | "name": "ipython",
653 | "version": 3
654 | },
655 | "file_extension": ".py",
656 | "mimetype": "text/x-python",
657 | "name": "python",
658 | "nbconvert_exporter": "python",
659 | "pygments_lexer": "ipython3",
660 | "version": "3.5.4"
661 | }
662 | },
663 | "nbformat": 4,
664 | "nbformat_minor": 1
665 | }
666 |
--------------------------------------------------------------------------------
/data/iot_sensor_dataset.csv:
--------------------------------------------------------------------------------
1 | footfall,atemp,selfLR,ClinLR,DoleLR,PID,outpressure,inpressure,temp,fail
2 | 0,7,7,1,6,6,36,3,1,1
3 | 190,1,3,3,5,1,20,4,1,0
4 | 31,7,2,2,6,1,24,6,1,0
5 | 83,4,3,4,5,1,28,6,1,0
6 | 640,7,5,6,4,0,68,6,1,0
7 | 110,3,3,4,6,1,21,4,1,0
8 | 100,7,5,6,4,1,77,4,1,0
9 | 31,1,5,4,5,4,21,4,1,0
10 | 180,7,4,6,3,3,31,4,1,0
11 | 2800,0,3,3,7,0,39,3,1,0
12 | 1600,0,3,2,4,4,26,2,1,0
13 | 330,5,4,3,6,1,31,4,1,0
14 | 190,2,5,4,6,5,22,4,1,1
15 | 100,7,4,4,6,0,42,5,1,0
16 | 1000,7,5,7,4,0,74,1,1,0
17 | 0,7,6,7,5,0,62,3,1,0
18 | 130,7,4,4,5,1,58,3,1,0
19 | 5,5,3,3,6,1,24,6,1,0
20 | 33,7,6,2,6,5,51,4,1,1
21 | 19,2,2,1,4,0,36,3,2,0
22 | 74,7,4,4,7,2,88,2,2,0
23 | 190,0,2,4,6,2,20,4,2,0
24 | 12,3,4,6,3,2,27,3,2,0
25 | 0,7,6,1,6,6,44,4,2,1
26 | 19,0,4,2,2,1,45,3,2,0
27 | 0,2,4,3,6,1,21,4,2,0
28 | 390,5,3,4,7,1,40,5,2,0
29 | 40,7,4,3,4,0,40,6,2,0
30 | 3,3,5,5,4,1,48,3,2,0
31 | 450,3,4,7,1,0,34,3,2,0
32 | 350,0,3,4,7,2,26,2,2,0
33 | 64,3,4,4,2,1,60,2,3,0
34 | 3,0,4,4,3,0,32,3,3,0
35 | 0,1,4,3,7,1,31,3,3,0
36 | 640,7,7,5,7,4,33,3,3,1
37 | 0,7,3,4,6,0,57,3,3,0
38 | 12,7,4,3,6,1,84,3,3,0
39 | 62,6,7,2,7,5,75,3,3,1
40 | 31,2,7,2,6,6,19,4,3,1
41 | 0,1,3,2,6,1,47,6,3,0
42 | 180,6,5,5,5,0,51,2,3,0
43 | 640,3,6,4,4,5,40,3,3,0
44 | 110,0,2,3,6,1,22,6,3,0
45 | 100,1,7,7,5,6,35,2,3,0
46 | 100,7,4,4,7,2,43,5,3,0
47 | 11,3,6,6,3,2,76,6,3,0
48 | 0,7,4,3,1,6,45,3,3,1
49 | 4,7,4,6,6,0,88,2,3,0
50 | 35,6,4,4,2,1,46,3,4,0
51 | 0,1,3,4,5,2,22,6,4,0
52 | 0,7,5,1,6,5,68,3,4,1
53 | 0,2,5,2,6,5,38,3,4,1
54 | 33,7,4,3,6,3,69,2,4,0
55 | 270,2,5,4,3,0,67,3,4,0
56 | 45,7,2,4,6,0,88,4,4,0
57 | 40,3,6,2,5,5,68,3,4,1
58 | 6,1,5,2,4,2,76,3,4,1
59 | 2,7,4,4,6,0,72,2,4,0
60 | 0,0,6,2,6,6,37,6,4,1
61 | 35,3,4,2,6,0,69,3,4,0
62 | 83,0,2,4,6,0,33,6,4,0
63 | 3500,7,2,2,6,0,34,4,4,0
64 | 100,2,4,4,7,2,30,3,4,0
65 | 350,2,3,3,6,1,19,3,4,0
66 | 100,3,4,6,2,0,44,3,4,0
67 | 67,1,4,4,7,1,64,3,4,0
68 | 30,5,7,7,2,0,37,4,4,0
69 | 0,7,6,3,5,4,31,5,5,1
70 | 0,0,6,1,5,4,88,4,5,1
71 | 6,7,6,2,6,6,77,4,5,1
72 | 350,1,4,5,6,5,30,6,5,0
73 | 400,1,2,3,7,1,32,4,5,0
74 | 15,7,6,2,6,6,59,1,5,1
75 | 0,0,4,4,4,3,47,4,5,0
76 | 3,2,4,6,5,1,22,3,5,0
77 | 22,5,4,2,6,2,55,3,5,0
78 | 64,2,2,1,3,0,24,2,5,0
79 | 32,5,3,7,4,1,65,1,5,0
80 | 390,7,3,6,2,2,24,3,5,0
81 | 0,7,3,4,5,3,30,3,5,0
82 | 0,7,4,5,2,3,73,3,5,0
83 | 59,5,3,3,5,1,73,5,5,0
84 | 0,6,4,3,6,2,91,1,5,0
85 | 35,7,3,2,5,0,71,2,5,0
86 | 0,2,6,4,5,4,34,4,5,1
87 | 170,7,4,3,2,0,48,2,6,0
88 | 12,1,6,2,6,5,42,4,6,1
89 | 40,4,6,5,4,0,72,2,6,0
90 | 31,2,3,4,6,6,20,4,6,1
91 | 31,7,2,2,7,0,22,4,6,0
92 | 1600,1,3,3,6,1,24,6,6,0
93 | 1,1,4,2,7,2,39,6,6,0
94 | 4,7,6,1,6,6,83,5,6,1
95 | 190,0,6,2,6,6,39,3,6,1
96 | 53,3,5,3,6,1,33,5,6,0
97 | 31,7,4,3,6,1,53,3,6,1
98 | 16,7,5,3,6,5,82,3,6,1
99 | 33,5,4,3,5,6,82,3,6,1
100 | 0,3,5,3,6,5,47,6,7,1
101 | 0,3,4,2,7,4,68,3,7,0
102 | 0,7,4,3,5,0,84,6,7,0
103 | 27,2,6,1,6,5,35,5,7,1
104 | 84,7,4,5,6,1,67,2,7,0
105 | 22,3,5,3,5,4,33,2,7,1
106 | 0,3,3,3,5,0,49,7,7,0
107 | 3500,0,4,3,7,0,91,1,7,0
108 | 390,7,4,5,3,1,43,3,7,0
109 | 0,7,4,3,2,6,65,4,7,0
110 | 16,7,5,6,3,0,69,3,7,0
111 | 200,0,5,5,4,1,56,4,8,0
112 | 640,0,2,3,5,0,24,6,8,0
113 | 0,7,4,4,5,0,77,3,8,0
114 | 45,7,6,3,7,0,74,3,8,0
115 | 12,0,7,3,6,6,25,6,8,1
116 | 20,7,6,2,5,4,85,1,8,1
117 | 7300,5,7,7,6,3,21,2,8,0
118 | 64,7,6,3,1,0,24,4,8,0
119 | 13,7,5,4,7,4,73,4,8,0
120 | 190,0,4,5,3,2,37,3,8,0
121 | 9,4,4,5,1,2,35,4,8,0
122 | 0,7,4,4,7,0,47,3,8,0
123 | 170,2,4,2,6,6,21,3,8,1
124 | 640,7,3,6,4,0,55,5,8,0
125 | 9,4,6,3,6,6,30,6,8,1
126 | 0,4,5,3,6,4,76,7,8,1
127 | 7300,5,3,4,3,3,36,4,8,0
128 | 2800,0,1,1,7,0,38,3,9,0
129 | 0,7,2,3,5,0,67,3,9,0
130 | 30,7,7,3,7,6,70,2,9,1
131 | 44,7,5,3,7,2,78,4,9,0
132 | 7300,1,2,2,7,3,27,6,9,0
133 | 330,4,3,5,6,1,51,4,9,0
134 | 3,0,6,7,3,5,33,4,9,0
135 | 51,2,6,1,5,6,80,6,9,1
136 | 29,5,4,1,6,1,79,1,9,0
137 | 630,2,6,4,5,4,66,1,9,1
138 | 170,0,4,1,6,0,32,3,10,0
139 | 33,7,4,5,7,0,70,2,10,0
140 | 0,3,2,3,6,3,42,3,10,0
141 | 9,5,5,4,5,5,73,4,10,1
142 | 22,4,4,4,6,0,87,2,10,0
143 | 100,0,7,5,1,1,30,5,10,0
144 | 2,2,4,4,5,3,52,3,10,0
145 | 0,6,5,3,6,1,62,4,10,0
146 | 50,7,6,3,4,0,67,3,10,0
147 | 15,4,6,3,4,4,37,6,10,0
148 | 3,4,3,5,7,0,37,4,10,0
149 | 720,5,1,5,6,1,64,6,10,0
150 | 640,7,1,1,5,0,34,3,10,0
151 | 5,7,4,4,7,0,70,3,10,0
152 | 24,2,6,2,6,6,31,5,10,1
153 | 22,7,2,2,6,0,29,6,11,0
154 | 55,7,4,5,4,1,71,2,11,0
155 | 0,2,4,4,4,0,67,1,11,0
156 | 1600,5,4,4,6,0,41,7,11,0
157 | 170,6,1,2,6,0,49,6,11,0
158 | 1000,7,4,4,5,0,42,5,11,0
159 | 63,0,6,3,2,0,78,2,11,0
160 | 110,0,4,1,6,1,24,3,11,0
161 | 16,7,4,6,6,1,29,3,11,0
162 | 100,3,4,2,6,5,39,5,11,1
163 | 7300,3,5,3,6,1,19,4,11,0
164 | 22,2,4,2,7,1,32,5,11,0
165 | 71,3,4,2,6,5,69,3,11,1
166 | 900,4,5,2,5,5,83,3,11,1
167 | 35,7,4,1,5,4,76,2,11,1
168 | 2,7,7,1,2,0,62,2,11,0
169 | 83,2,3,3,6,0,47,7,11,0
170 | 370,5,6,7,4,0,35,3,11,0
171 | 12,0,4,5,3,4,23,3,11,0
172 | 370,7,4,4,1,1,79,4,11,0
173 | 100,7,6,2,6,5,64,5,11,1
174 | 470,7,6,2,4,5,70,4,11,1
175 | 22,7,6,1,6,6,87,5,11,1
176 | 2800,0,3,6,1,0,28,2,12,0
177 | 47,5,3,5,7,1,58,3,12,0
178 | 900,5,4,4,6,1,85,2,12,0
179 | 330,7,3,6,4,0,62,3,12,0
180 | 84,0,3,2,7,1,26,6,12,0
181 | 0,0,6,2,5,5,28,3,12,1
182 | 33,3,6,1,7,6,88,2,12,1
183 | 53,7,2,3,6,0,57,6,12,0
184 | 8,7,2,2,6,0,78,3,12,0
185 | 2,7,4,4,2,0,56,3,12,0
186 | 0,0,4,6,3,3,46,5,12,0
187 | 0,2,4,4,3,5,20,3,12,1
188 | 0,0,5,6,4,1,24,4,12,0
189 | 0,7,5,2,6,2,72,4,12,0
190 | 15,7,2,4,7,1,51,4,12,0
191 | 900,0,6,2,5,6,34,6,12,1
192 | 30,2,4,2,6,1,21,4,12,0
193 | 0,7,4,4,6,2,74,7,12,0
194 | 170,3,4,4,6,1,48,1,12,0
195 | 900,2,3,3,7,5,28,3,12,0
196 | 0,6,7,1,7,5,38,2,12,1
197 | 1600,7,4,6,1,0,70,3,12,0
198 | 0,7,4,5,4,0,72,2,12,0
199 | 2800,0,4,5,6,0,41,3,12,0
200 | 110,5,3,4,5,1,50,7,12,0
201 | 1,7,6,2,5,5,73,3,12,1
202 | 3,5,5,2,4,0,79,6,12,0
203 | 0,4,5,1,4,5,76,2,12,1
204 | 22,0,5,3,5,5,62,5,12,1
205 | 63,3,6,2,6,6,30,6,12,1
206 | 290,0,6,3,6,5,35,4,12,1
207 | 2,7,1,2,7,1,66,4,12,0
208 | 40,0,2,4,6,0,35,4,12,0
209 | 67,0,6,1,5,6,57,6,12,1
210 | 0,5,4,5,4,5,37,5,12,1
211 | 470,7,5,5,2,1,61,3,13,0
212 | 0,7,6,2,6,6,56,3,13,1
213 | 4,6,3,4,5,1,53,3,13,0
214 | 20,0,4,5,3,2,24,6,13,1
215 | 2800,7,4,1,6,5,74,3,13,1
216 | 0,0,4,4,3,1,36,3,13,0
217 | 1,0,6,2,4,5,30,5,13,1
218 | 640,0,4,7,4,1,55,2,13,0
219 | 170,3,3,2,7,2,35,6,13,0
220 | 270,2,3,4,6,0,26,4,13,0
221 | 390,0,3,4,6,2,25,4,13,0
222 | 16,2,6,7,4,3,27,3,13,0
223 | 11,7,4,1,6,5,66,3,13,1
224 | 0,1,5,2,6,2,39,2,13,0
225 | 270,7,1,1,2,2,58,5,13,0
226 | 170,2,4,4,4,0,53,3,13,1
227 | 900,7,6,7,4,0,76,3,13,0
228 | 270,7,5,2,7,1,51,3,13,0
229 | 0,7,4,2,7,0,70,2,13,0
230 | 350,3,6,3,6,6,68,4,13,1
231 | 0,0,5,4,5,2,32,3,13,1
232 | 6,0,5,4,5,5,55,3,13,0
233 | 290,7,2,2,6,0,52,4,13,0
234 | 630,7,6,4,6,4,73,2,13,1
235 | 900,0,5,4,7,0,42,2,13,0
236 | 31,2,4,4,3,4,23,5,13,1
237 | 1600,5,2,3,6,0,30,7,14,0
238 | 71,7,2,2,7,0,68,4,14,0
239 | 200,7,5,2,3,2,68,3,14,0
240 | 0,0,6,4,7,3,68,6,14,0
241 | 30,5,2,3,6,0,38,5,14,0
242 | 10,1,4,3,6,2,74,3,14,0
243 | 0,7,5,6,3,0,59,2,14,0
244 | 900,2,5,2,5,2,73,2,14,0
245 | 71,7,2,3,6,0,79,3,14,0
246 | 22,3,7,1,6,5,28,4,14,1
247 | 0,7,6,2,6,6,50,3,14,1
248 | 0,4,6,3,1,1,36,4,14,0
249 | 0,3,6,2,6,6,50,3,14,1
250 | 0,1,6,2,6,6,61,3,14,1
251 | 7300,3,2,2,6,0,37,4,14,0
252 | 83,0,3,4,7,0,29,6,14,0
253 | 93,7,2,3,7,0,39,4,14,0
254 | 0,7,4,5,4,2,83,6,14,1
255 | 51,7,6,1,5,4,68,6,14,1
256 | 31,2,6,1,5,6,25,4,14,1
257 | 93,2,1,3,6,1,41,6,14,0
258 | 0,7,3,2,6,1,67,3,14,0
259 | 0,3,4,2,6,4,36,6,14,1
260 | 31,4,6,2,6,4,66,4,14,1
261 | 900,1,3,2,7,1,55,4,14,0
262 | 0,4,3,2,6,2,42,5,14,0
263 | 2,7,6,3,5,5,42,3,14,1
264 | 110,3,4,5,7,1,36,3,14,0
265 | 63,1,6,4,6,4,53,5,14,1
266 | 900,0,3,2,5,1,36,5,14,0
267 | 31,3,4,3,6,2,29,7,14,0
268 | 510,1,4,4,6,0,31,3,14,0
269 | 270,2,3,4,6,1,43,6,14,0
270 | 9,3,3,4,7,1,33,6,14,0
271 | 3,1,6,6,2,0,63,3,14,0
272 | 29,1,5,2,4,2,25,5,14,0
273 | 45,2,3,2,6,0,72,4,14,0
274 | 83,5,3,3,6,1,40,4,14,0
275 | 22,7,4,2,6,2,27,6,14,0
276 | 15,3,5,4,7,2,26,4,15,0
277 | 110,7,5,2,5,6,67,3,15,1
278 | 8,0,4,5,5,1,21,3,15,0
279 | 11,5,6,2,6,6,27,7,15,1
280 | 56,4,6,5,3,0,78,6,15,1
281 | 8,3,4,4,3,1,32,3,15,0
282 | 100,5,4,2,6,1,68,4,15,0
283 | 900,7,4,2,6,5,76,4,15,0
284 | 67,7,3,3,6,0,33,5,15,0
285 | 35,4,6,2,5,4,38,2,15,1
286 | 35,3,4,3,5,1,49,7,15,0
287 | 22,0,5,4,6,5,61,4,15,1
288 | 110,7,7,1,5,4,57,3,15,1
289 | 12,0,4,2,5,2,20,3,15,0
290 | 7300,7,4,2,4,4,63,6,15,1
291 | 0,0,4,1,5,4,53,3,15,1
292 | 19,5,4,2,6,5,35,4,15,1
293 | 470,3,4,4,7,0,39,3,15,0
294 | 4,3,3,5,3,4,48,3,15,1
295 | 640,4,6,2,5,4,62,3,15,1
296 | 640,2,4,2,3,1,30,5,15,0
297 | 200,7,7,1,4,6,26,6,15,1
298 | 0,7,3,2,4,5,74,6,15,1
299 | 29,4,3,4,6,2,37,5,15,0
300 | 330,2,4,5,5,1,43,5,15,0
301 | 19,5,5,1,4,6,68,3,15,1
302 | 1,7,5,3,4,5,73,5,15,1
303 | 110,5,6,1,6,6,60,7,15,1
304 | 0,7,5,4,6,1,35,3,15,0
305 | 350,4,3,4,6,0,29,6,15,0
306 | 2,5,3,3,5,1,25,6,15,0
307 | 0,7,2,2,6,0,25,7,15,0
308 | 7,4,2,4,5,0,70,6,15,0
309 | 71,1,6,2,5,6,41,3,15,1
310 | 53,0,4,2,6,1,37,6,15,0
311 | 0,0,6,1,6,6,39,5,15,1
312 | 2,6,3,4,6,0,35,4,15,0
313 | 190,4,2,3,6,0,62,7,15,0
314 | 31,0,3,2,6,1,30,7,15,0
315 | 16,7,4,2,6,0,74,4,15,0
316 | 22,7,3,3,4,5,47,3,15,0
317 | 3,4,4,5,3,1,43,6,15,0
318 | 0,6,5,3,6,5,64,2,15,1
319 | 0,7,4,3,5,2,75,4,15,1
320 | 67,3,4,4,7,1,27,6,15,0
321 | 40,7,4,4,6,0,21,3,15,0
322 | 74,4,2,2,6,1,70,2,15,0
323 | 3,6,5,2,6,5,67,3,15,1
324 | 140,7,6,4,5,6,82,5,15,0
325 | 14,0,2,2,6,0,40,6,15,0
326 | 110,0,5,3,6,5,26,4,15,1
327 | 35,3,4,3,5,1,29,6,15,0
328 | 0,1,4,5,6,2,28,6,15,0
329 | 310,7,6,4,3,5,65,3,15,0
330 | 900,2,6,5,3,1,25,3,15,0
331 | 0,7,3,2,7,1,65,2,15,0
332 | 11,4,6,2,6,5,38,5,15,1
333 | 0,2,4,3,5,5,72,7,15,1
334 | 270,7,3,2,7,1,67,3,15,0
335 | 51,7,3,1,7,0,74,3,15,0
336 | 11,5,2,4,4,2,71,6,15,0
337 | 2,0,4,6,4,0,47,3,15,0
338 | 20,7,5,4,6,1,69,1,15,0
339 | 31,3,3,3,6,1,29,6,15,0
340 | 2,0,6,2,5,6,34,3,15,1
341 | 5,3,4,3,6,0,43,4,15,0
342 | 22,7,2,1,7,0,30,3,15,0
343 | 0,7,5,5,4,0,76,2,15,0
344 | 27,0,2,4,6,1,26,5,16,0
345 | 7,7,4,3,6,2,76,5,16,0
346 | 0,0,1,4,6,1,42,7,16,0
347 | 0,4,3,1,4,5,33,3,16,1
348 | 0,1,6,2,5,5,25,3,16,1
349 | 2800,0,2,2,7,0,51,4,16,0
350 | 0,4,4,2,5,4,57,3,16,1
351 | 22,1,6,1,5,6,21,4,16,1
352 | 9,7,5,1,4,5,79,7,16,1
353 | 0,1,6,2,5,5,35,5,16,1
354 | 9,5,4,2,5,4,57,6,16,1
355 | 0,1,4,4,6,5,32,6,16,0
356 | 37,5,4,5,5,2,51,6,16,0
357 | 23,0,5,2,4,6,62,7,16,1
358 | 0,4,5,1,6,5,48,4,16,1
359 | 0,7,7,1,6,6,39,3,16,1
360 | 0,5,3,2,6,5,26,6,16,1
361 | 40,0,4,2,4,1,38,3,16,1
362 | 0,5,3,3,4,0,50,4,16,0
363 | 9,2,5,5,6,4,33,3,16,1
364 | 15,5,4,3,6,2,36,3,16,0
365 | 640,5,4,4,6,0,24,6,16,0
366 | 0,4,3,2,6,0,25,5,16,0
367 | 0,7,6,5,3,0,62,3,16,0
368 | 0,2,4,3,3,6,33,3,16,1
369 | 0,7,6,2,5,6,53,6,16,1
370 | 22,7,6,2,5,6,68,6,16,1
371 | 22,7,5,4,6,1,68,3,16,0
372 | 10,1,6,1,5,5,38,3,16,1
373 | 29,1,4,5,3,0,58,1,16,0
374 | 170,7,4,2,6,5,34,6,16,1
375 | 4,2,4,3,4,1,58,2,16,0
376 | 11,0,3,4,7,1,35,5,16,0
377 | 31,3,7,2,6,6,42,6,16,1
378 | 0,7,4,4,6,0,54,3,16,0
379 | 0,7,6,2,5,6,69,3,16,1
380 | 360,2,4,6,5,0,35,4,16,0
381 | 0,7,6,1,5,6,66,4,16,1
382 | 900,2,3,2,7,0,58,3,16,0
383 | 51,5,2,4,7,1,41,3,16,0
384 | 0,2,5,2,6,4,35,6,16,0
385 | 110,0,3,3,6,1,40,7,16,0
386 | 1,7,4,7,2,0,53,1,16,0
387 | 8,5,6,2,6,5,67,6,16,1
388 | 5,5,4,4,6,0,32,5,16,0
389 | 87,4,3,4,6,0,41,4,16,0
390 | 3,1,2,1,6,1,43,7,16,0
391 | 51,1,5,3,2,0,65,2,16,0
392 | 350,7,3,3,7,0,60,5,16,0
393 | 3,7,5,3,6,0,77,6,16,0
394 | 630,0,6,5,4,1,35,4,16,0
395 | 180,4,6,7,5,1,48,4,16,0
396 | 0,0,6,2,6,6,52,3,16,1
397 | 35,7,5,3,6,2,43,7,16,0
398 | 0,7,6,2,6,6,43,5,16,1
399 | 0,7,6,2,6,6,67,4,16,1
400 | 6,1,4,4,7,0,56,3,16,0
401 | 7300,2,3,3,4,0,62,4,16,0
402 | 2,1,7,7,5,0,62,3,16,0
403 | 35,3,3,2,6,1,22,6,16,0
404 | 0,0,2,2,6,1,21,5,16,0
405 | 45,3,6,1,6,6,34,3,16,1
406 | 0,7,4,3,5,0,70,3,16,0
407 | 5,1,3,2,6,2,50,3,16,0
408 | 35,5,6,1,6,6,42,4,16,1
409 | 900,5,6,2,6,6,73,3,16,1
410 | 35,2,3,1,6,0,57,7,16,0
411 | 0,7,6,1,5,6,40,6,16,1
412 | 0,2,6,1,6,6,58,6,16,1
413 | 11,7,4,6,2,1,62,3,16,0
414 | 40,1,3,5,3,1,44,3,17,0
415 | 0,3,5,3,7,6,30,6,17,0
416 | 23,7,3,3,7,0,76,5,17,0
417 | 270,3,4,3,3,1,50,4,17,0
418 | 9,1,6,2,5,5,41,4,17,1
419 | 0,6,6,3,6,6,77,3,17,1
420 | 0,3,6,3,5,6,35,6,17,1
421 | 0,7,4,3,4,3,39,4,17,0
422 | 2,0,4,2,4,4,72,3,17,1
423 | 0,2,6,2,5,6,42,7,17,1
424 | 16,7,5,2,6,5,85,2,17,1
425 | 7300,0,4,2,6,3,79,4,17,0
426 | 0,5,2,3,6,0,39,4,17,0
427 | 23,4,6,1,5,6,58,6,17,1
428 | 42,0,4,2,6,5,27,6,17,1
429 | 2,4,4,3,5,1,43,5,17,0
430 | 0,0,3,3,6,0,58,4,17,0
431 | 42,7,4,3,6,4,28,7,17,1
432 | 470,2,5,3,6,5,27,6,17,0
433 | 42,0,3,6,5,2,40,3,17,0
434 | 0,5,1,3,6,0,43,6,17,0
435 | 40,7,5,4,6,5,64,3,17,1
436 | 180,7,2,2,6,0,39,6,17,0
437 | 110,7,4,2,6,4,76,4,17,1
438 | 140,5,3,3,6,0,64,5,17,0
439 | 0,4,4,6,3,2,28,4,17,0
440 | 0,2,4,2,6,1,45,3,17,0
441 | 190,1,6,2,6,6,22,3,17,1
442 | 35,1,3,3,6,1,27,6,17,0
443 | 45,0,1,2,7,0,31,4,17,0
444 | 170,1,2,2,7,0,34,6,17,0
445 | 0,4,2,3,7,0,30,4,17,0
446 | 0,2,6,1,6,6,64,3,17,1
447 | 35,0,6,1,6,4,36,6,17,1
448 | 5,7,4,3,5,4,31,2,17,1
449 | 350,1,4,3,4,5,37,3,17,1
450 | 4,0,6,4,2,1,48,3,17,0
451 | 70,0,5,7,7,3,41,3,17,0
452 | 8,2,5,2,6,5,25,4,17,1
453 | 12,5,4,2,6,6,82,3,17,1
454 | 5,1,6,2,5,4,36,7,17,1
455 | 0,7,6,2,5,1,47,3,17,1
456 | 16,6,2,3,6,0,67,4,17,0
457 | 0,0,4,6,2,5,24,4,17,1
458 | 9,0,4,5,3,5,33,6,17,1
459 | 14,7,4,1,5,1,59,4,17,1
460 | 22,7,7,1,6,6,71,4,17,1
461 | 0,7,6,2,5,6,36,3,17,1
462 | 1,3,3,3,5,0,41,3,17,0
463 | 1600,5,6,2,6,6,38,6,17,1
464 | 7300,1,6,3,6,6,32,3,17,1
465 | 19,0,5,6,7,1,32,4,17,0
466 | 9,6,5,4,6,0,75,6,17,0
467 | 0,7,5,2,4,4,52,3,17,1
468 | 1600,5,2,3,6,0,29,7,17,0
469 | 12,7,3,4,6,0,71,3,17,0
470 | 1,0,6,2,5,2,33,6,17,0
471 | 0,3,1,2,7,2,67,7,17,0
472 | 0,2,6,1,6,6,49,4,17,1
473 | 0,0,2,3,5,1,31,7,17,0
474 | 9,7,3,4,6,1,53,2,17,0
475 | 0,3,2,3,7,0,35,7,17,0
476 | 170,7,6,2,6,6,49,7,18,1
477 | 3,7,6,4,4,0,74,3,18,0
478 | 14,0,6,1,5,6,29,4,18,1
479 | 1,5,2,3,6,0,27,6,18,0
480 | 23,5,4,4,6,5,70,4,18,0
481 | 0,0,6,1,6,6,43,6,18,1
482 | 1,5,2,3,6,2,47,7,18,0
483 | 0,4,4,4,6,0,42,7,18,0
484 | 9,0,6,2,5,6,41,6,18,1
485 | 130,2,6,4,6,6,37,4,18,1
486 | 5,5,5,5,4,1,61,3,18,0
487 | 4,7,4,2,6,0,84,4,18,0
488 | 2800,7,5,3,7,0,46,6,18,0
489 | 4,0,4,3,6,5,39,7,18,0
490 | 6,7,2,3,6,0,53,3,18,0
491 | 4,7,5,1,6,6,87,6,18,1
492 | 84,2,4,6,2,0,51,3,18,0
493 | 0,0,5,2,5,4,37,5,18,1
494 | 9,1,4,3,5,4,37,6,18,1
495 | 290,0,5,2,6,6,40,6,18,1
496 | 0,3,4,4,6,2,46,6,18,0
497 | 9,7,1,4,1,3,44,3,18,1
498 | 0,2,4,3,6,1,37,3,18,0
499 | 0,7,4,2,6,2,55,7,18,0
500 | 22,0,5,2,5,1,40,6,18,1
501 | 0,5,3,2,6,1,42,7,18,0
502 | 640,7,6,2,6,6,40,3,18,1
503 | 10,0,6,2,6,6,32,3,18,1
504 | 4,5,5,2,5,4,58,7,18,1
505 | 0,2,5,1,6,4,37,3,18,1
506 | 640,4,4,5,5,5,51,3,18,1
507 | 110,5,3,5,4,5,44,5,18,0
508 | 0,2,4,5,2,0,23,2,18,0
509 | 0,2,6,2,6,6,38,3,18,1
510 | 67,0,3,4,6,0,42,7,18,0
511 | 520,7,4,2,5,4,60,4,18,1
512 | 0,3,4,3,6,1,34,4,18,0
513 | 51,1,6,2,6,6,49,3,18,1
514 | 0,0,4,2,3,4,40,3,18,1
515 | 2800,7,2,2,7,0,23,4,18,0
516 | 110,2,2,3,6,0,47,3,18,0
517 | 7300,7,4,4,7,0,44,5,18,0
518 | 7300,5,5,2,6,1,37,7,18,1
519 | 0,2,6,1,6,5,26,5,18,1
520 | 16,7,7,6,5,2,51,4,18,0
521 | 140,4,4,4,6,0,69,3,18,0
522 | 54,2,2,2,7,0,36,6,18,0
523 | 2,2,2,3,6,2,28,4,18,0
524 | 470,4,5,2,6,5,40,4,19,1
525 | 0,1,6,1,6,5,45,4,19,1
526 | 75,3,5,2,5,5,75,6,19,1
527 | 11,2,6,2,5,5,32,6,19,1
528 | 0,0,3,2,6,1,27,3,19,0
529 | 2800,6,5,2,5,3,63,6,19,1
530 | 140,1,5,3,6,6,79,7,19,1
531 | 9,7,3,2,6,1,40,6,19,0
532 | 7300,2,4,3,6,1,57,6,19,0
533 | 45,3,3,4,5,1,44,6,19,0
534 | 1600,7,5,2,5,6,78,6,19,1
535 | 9,7,4,5,5,5,58,7,19,0
536 | 0,7,2,2,7,1,55,3,19,0
537 | 130,4,3,4,6,2,25,6,19,0
538 | 9,0,2,3,6,0,27,7,19,0
539 | 3500,3,4,2,7,2,21,3,19,0
540 | 0,3,6,2,6,5,37,4,19,1
541 | 0,0,7,3,4,5,31,3,19,1
542 | 35,7,2,4,6,0,85,7,19,0
543 | 900,1,4,2,6,5,33,3,19,0
544 | 27,7,3,7,4,3,63,2,19,1
545 | 900,7,4,4,6,1,51,3,19,0
546 | 0,2,3,5,2,0,46,3,19,0
547 | 64,2,5,2,6,6,26,5,19,1
548 | 4,7,3,3,6,0,57,6,19,0
549 | 0,3,4,2,6,1,48,3,19,1
550 | 0,2,7,1,5,5,55,3,19,1
551 | 53,0,3,6,4,1,37,5,19,0
552 | 290,2,6,2,6,6,39,3,19,1
553 | 15,2,2,3,4,1,24,3,19,1
554 | 0,0,6,3,6,6,30,6,19,1
555 | 35,0,3,4,6,1,36,7,19,0
556 | 0,0,5,4,6,4,45,3,19,0
557 | 470,1,5,2,6,2,29,3,19,0
558 | 16,7,6,3,6,5,41,4,19,1
559 | 40,1,5,3,5,4,28,5,19,1
560 | 290,7,2,2,7,0,35,4,19,0
561 | 4,7,2,3,6,0,46,4,19,0
562 | 1,7,1,2,7,1,55,4,19,0
563 | 140,3,2,3,6,6,65,4,19,0
564 | 110,1,4,2,6,1,22,4,19,0
565 | 0,1,4,4,6,1,41,4,19,0
566 | 900,1,2,3,6,2,43,7,19,0
567 | 0,2,4,3,6,0,49,4,19,0
568 | 0,4,4,2,5,4,35,7,19,1
569 | 51,7,3,3,5,1,80,3,19,0
570 | 71,2,4,6,2,0,57,4,19,0
571 | 900,4,3,3,6,0,48,3,19,0
572 | 83,4,1,4,6,2,43,6,19,0
573 | 360,3,4,4,7,0,34,4,19,0
574 | 180,7,2,2,4,0,44,5,19,0
575 | 1,3,6,1,6,4,49,6,20,1
576 | 22,7,5,2,7,2,43,7,20,0
577 | 1,0,4,3,5,6,39,4,20,1
578 | 2,2,4,3,7,1,27,3,20,0
579 | 34,4,6,2,6,6,30,6,20,1
580 | 33,2,6,2,6,4,33,6,20,1
581 | 10,1,2,3,7,0,32,5,20,0
582 | 290,7,5,2,6,6,31,6,20,1
583 | 0,2,5,3,7,2,27,5,20,0
584 | 76,3,2,2,6,0,36,4,20,0
585 | 20,7,3,2,6,2,45,5,20,0
586 | 0,5,4,6,5,2,51,3,20,0
587 | 0,0,6,2,3,5,36,4,20,1
588 | 0,7,6,4,6,4,47,7,20,1
589 | 470,4,4,4,6,1,42,6,20,0
590 | 9,6,6,1,5,6,70,6,20,1
591 | 0,0,3,3,6,3,40,4,20,0
592 | 0,7,2,5,7,0,38,3,20,0
593 | 8,0,5,1,6,4,29,3,20,1
594 | 1,0,4,2,5,6,58,3,20,1
595 | 1,7,4,6,1,2,28,3,20,0
596 | 7,1,6,3,6,5,30,4,20,1
597 | 0,3,4,3,6,2,48,5,20,0
598 | 170,0,6,2,6,6,35,4,20,1
599 | 270,3,6,7,6,0,38,3,20,0
600 | 0,0,4,2,5,4,56,7,20,1
601 | 13,4,5,3,6,5,62,4,20,1
602 | 10,7,6,1,6,5,56,4,20,1
603 | 22,0,6,2,5,6,32,3,20,1
604 | 640,5,4,5,7,1,50,5,20,0
605 | 900,3,3,4,6,1,45,6,20,0
606 | 22,7,3,3,4,0,36,6,20,0
607 | 62,1,6,2,6,6,49,4,20,1
608 | 110,2,7,1,6,6,31,6,20,1
609 | 84,4,2,3,6,2,33,7,20,0
610 | 0,1,6,2,6,6,35,4,20,1
611 | 13,2,4,2,5,4,73,4,20,1
612 | 20,7,6,1,5,6,54,5,20,1
613 | 0,3,4,2,7,1,48,3,20,0
614 | 16,3,6,2,6,4,65,4,20,1
615 | 6,7,5,6,5,6,46,4,20,0
616 | 12,0,2,2,6,0,45,7,20,0
617 | 0,7,6,2,5,6,65,7,20,1
618 | 0,0,6,2,6,6,45,6,20,1
619 | 170,7,4,1,5,4,89,7,20,1
620 | 100,0,5,3,6,4,32,4,20,0
621 | 5,4,6,4,4,1,38,4,20,0
622 | 3500,5,2,4,2,5,33,4,20,1
623 | 71,4,6,2,5,6,49,7,20,1
624 | 4,7,5,2,6,5,64,6,20,1
625 | 7300,5,5,4,7,1,55,4,20,0
626 | 7,0,3,3,5,1,56,7,20,0
627 | 290,4,4,5,3,5,30,6,20,0
628 | 0,0,5,4,6,5,41,7,20,1
629 | 0,1,6,2,5,6,39,5,20,1
630 | 520,7,4,4,6,4,34,3,20,0
631 | 430,5,4,5,7,1,53,3,20,0
632 | 9,2,3,3,6,2,40,6,20,0
633 | 40,0,3,3,6,1,48,6,20,0
634 | 2,7,6,5,5,5,59,4,20,0
635 | 75,7,6,2,4,4,54,4,20,1
636 | 170,0,3,5,6,1,41,6,20,0
637 | 170,1,2,3,6,0,41,6,20,0
638 | 640,5,5,3,6,4,63,7,20,0
639 | 2800,1,7,1,6,4,39,3,20,1
640 | 9,3,7,2,5,4,46,3,20,0
641 | 150,7,4,3,6,0,55,3,20,0
642 | 0,7,4,1,5,3,42,3,20,1
643 | 0,7,6,3,6,4,58,2,20,1
644 | 100,0,3,2,6,2,42,4,20,0
645 | 33,7,4,3,4,2,40,6,20,1
646 | 310,7,5,2,5,1,56,6,20,1
647 | 53,1,4,5,2,2,37,4,20,0
648 | 13,2,3,2,6,2,37,6,20,0
649 | 290,6,5,1,5,5,49,6,20,1
650 | 310,7,6,1,6,6,63,4,20,1
651 | 0,7,6,2,5,6,30,7,20,1
652 | 54,7,4,2,6,4,62,5,20,1
653 | 1600,0,4,3,6,1,30,6,20,0
654 | 14,0,6,3,6,6,34,6,20,1
655 | 25,7,6,3,6,5,41,4,20,1
656 | 45,0,4,5,4,6,43,3,20,1
657 | 20,2,5,2,6,4,33,5,20,0
658 | 18,6,4,3,5,5,67,7,20,1
659 | 740,7,5,1,6,0,55,5,20,1
660 | 9,6,2,2,6,0,33,5,20,0
661 | 5,0,6,1,5,5,61,4,20,1
662 | 7300,7,4,1,6,4,45,3,20,0
663 | 81,7,4,3,7,0,34,3,20,0
664 | 190,1,6,2,6,6,35,3,20,1
665 | 51,1,4,4,5,2,50,6,20,0
666 | 7300,7,3,4,2,0,38,4,20,0
667 | 350,0,6,2,6,5,56,3,20,1
668 | 27,2,4,1,6,5,31,3,20,1
669 | 33,5,6,1,4,5,40,7,20,1
670 | 50,4,3,2,6,0,44,3,20,0
671 | 1,7,6,5,2,2,39,4,20,0
672 | 11,1,4,3,6,1,45,3,20,0
673 | 51,5,3,3,6,0,72,6,20,0
674 | 160,7,2,3,5,1,44,7,20,0
675 | 16,7,1,3,6,0,61,7,21,0
676 | 110,6,6,2,6,6,34,7,21,1
677 | 110,4,5,2,5,5,61,6,21,1
678 | 13,6,3,3,7,1,67,4,21,0
679 | 220,7,4,1,4,6,38,6,21,1
680 | 470,7,4,2,6,1,50,6,21,0
681 | 22,6,6,1,6,6,62,4,21,1
682 | 9,2,6,3,6,5,36,6,21,1
683 | 22,3,6,3,5,4,50,6,21,1
684 | 190,2,4,2,7,1,30,6,21,0
685 | 100,5,6,2,6,6,59,5,21,1
686 | 14,7,3,3,6,0,62,6,21,0
687 | 0,7,4,3,6,3,40,4,21,0
688 | 180,1,6,1,6,6,30,4,21,1
689 | 3,6,3,2,6,2,47,3,21,0
690 | 51,2,5,2,6,1,41,6,21,0
691 | 9,2,6,1,6,6,35,7,21,1
692 | 0,7,5,2,6,6,45,4,21,1
693 | 0,2,4,2,6,4,34,6,21,1
694 | 71,2,5,7,2,2,55,3,21,0
695 | 290,1,5,3,6,2,37,4,21,0
696 | 45,3,5,2,4,4,61,7,21,1
697 | 0,3,4,5,4,1,62,2,21,0
698 | 26,1,5,2,6,6,54,6,21,1
699 | 87,3,2,3,6,1,33,6,21,0
700 | 0,0,2,3,6,1,50,6,21,0
701 | 630,0,3,4,7,2,37,3,21,0
702 | 50,5,5,3,6,3,44,3,21,1
703 | 35,7,4,3,4,3,78,3,21,0
704 | 180,7,6,2,4,6,56,3,21,0
705 | 32,0,2,3,4,2,29,6,21,0
706 | 0,7,3,2,5,4,52,6,21,0
707 | 51,1,6,4,5,1,31,3,21,0
708 | 40,0,6,3,6,6,34,7,21,1
709 | 0,2,5,3,6,5,31,7,21,1
710 | 0,7,4,3,5,2,43,6,21,0
711 | 0,1,4,4,3,5,31,3,21,1
712 | 1,6,6,1,6,6,63,7,21,1
713 | 7,2,2,3,7,4,38,4,21,0
714 | 0,2,6,2,6,6,31,5,21,1
715 | 71,2,2,1,7,0,64,3,21,0
716 | 75,2,3,2,5,5,55,7,21,0
717 | 55,1,2,2,6,0,41,3,21,0
718 | 290,4,3,4,5,5,38,4,21,1
719 | 88,4,6,3,6,5,28,6,21,1
720 | 0,7,4,3,5,5,42,5,21,1
721 | 16,7,2,4,3,1,43,4,21,0
722 | 75,1,5,1,6,5,37,4,21,1
723 | 220,1,4,2,6,3,47,5,21,0
724 | 3,5,5,1,6,5,52,7,21,1
725 | 130,0,5,2,6,5,32,4,21,1
726 | 0,5,4,4,3,2,29,3,21,0
727 | 110,2,6,2,5,4,56,3,21,1
728 | 12,7,4,3,5,5,63,7,21,1
729 | 180,3,3,3,6,1,35,5,21,0
730 | 93,7,4,3,5,3,36,4,21,1
731 | 170,7,4,2,7,0,75,5,21,0
732 | 31,5,3,3,6,1,48,6,21,0
733 | 62,4,7,2,6,6,36,5,21,1
734 | 30,4,4,3,6,2,34,6,21,0
735 | 66,7,4,3,7,1,35,5,21,0
736 | 3,3,5,2,5,6,50,4,21,1
737 | 18,3,5,2,5,6,39,7,21,1
738 | 350,5,5,4,6,5,70,7,21,1
739 | 71,7,4,2,5,6,76,3,21,1
740 | 3500,5,5,2,5,5,35,6,21,1
741 | 0,0,3,4,3,3,53,7,21,1
742 | 360,6,5,2,6,4,46,6,21,1
743 | 81,2,5,2,5,4,34,4,21,1
744 | 350,5,4,4,6,5,69,4,21,0
745 | 190,1,5,2,5,1,32,3,21,0
746 | 0,7,5,1,6,6,50,2,21,1
747 | 290,1,5,3,6,6,35,6,21,1
748 | 18,0,6,1,6,6,67,5,21,1
749 | 11,3,5,5,6,5,47,3,21,0
750 | 2,2,6,3,5,4,50,6,21,1
751 | 570,0,6,2,6,4,32,3,21,1
752 | 310,3,5,4,6,2,58,5,21,0
753 | 1,7,3,2,7,0,49,7,21,0
754 | 0,2,6,3,6,1,43,4,21,1
755 | 35,1,5,2,6,5,24,6,21,1
756 | 22,7,5,3,4,2,58,7,21,0
757 | 2,1,2,2,5,0,43,4,21,0
758 | 0,7,4,3,6,5,59,3,21,1
759 | 0,3,6,1,6,6,40,5,21,1
760 | 310,0,5,2,7,0,35,4,21,0
761 | 470,5,2,3,5,1,48,4,21,0
762 | 0,4,6,1,6,6,40,3,21,1
763 | 270,3,3,2,7,0,48,3,21,0
764 | 110,0,2,4,6,0,47,7,21,0
765 | 50,3,6,4,1,1,23,3,21,0
766 | 0,0,6,1,6,6,38,3,21,1
767 | 3,7,6,2,6,6,81,7,21,1
768 | 31,5,3,3,6,1,48,6,21,0
769 | 22,7,5,6,2,4,52,3,21,0
770 | 83,2,4,1,6,3,24,6,21,1
771 | 9,0,4,2,6,1,21,5,21,0
772 | 5,7,5,2,6,5,70,6,21,1
773 | 0,7,7,1,7,6,24,6,21,1
774 | 0,7,4,3,5,1,57,7,21,0
775 | 0,6,3,5,6,4,37,6,21,0
776 | 27,1,3,5,3,5,25,5,21,0
777 | 110,1,6,5,1,1,33,3,21,0
778 | 0,7,4,6,3,0,45,3,22,0
779 | 0,3,5,2,7,5,42,6,22,0
780 | 350,3,3,3,6,2,47,6,22,0
781 | 0,7,6,1,6,6,51,7,22,1
782 | 5,7,5,4,6,5,85,2,22,0
783 | 15,4,3,3,6,2,32,7,22,0
784 | 35,7,3,3,6,2,31,7,22,0
785 | 0,2,4,3,6,2,23,6,22,0
786 | 75,3,3,3,6,0,42,6,22,0
787 | 0,5,6,2,5,5,55,6,22,1
788 | 16,7,6,2,6,6,45,6,22,1
789 | 0,1,6,2,5,6,35,7,22,1
790 | 0,0,2,4,6,0,45,6,22,0
791 | 0,0,3,3,5,2,42,3,22,0
792 | 4,1,6,2,6,5,37,4,22,1
793 | 62,0,4,4,4,5,38,3,22,1
794 | 0,3,2,2,6,1,47,7,22,0
795 | 4,7,4,2,6,2,32,6,22,0
796 | 56,2,5,2,6,5,35,6,22,1
797 | 2,6,4,2,6,5,38,4,22,1
798 | 0,0,4,4,4,3,40,3,22,0
799 | 75,7,6,2,5,6,62,6,22,1
800 | 10,2,2,2,6,1,28,7,22,0
801 | 0,6,6,2,5,6,59,5,22,1
802 | 0,2,1,2,6,0,25,6,22,0
803 | 220,2,4,2,6,6,31,6,22,1
804 | 0,1,7,2,6,6,45,4,22,1
805 | 75,0,5,2,7,5,42,6,22,0
806 | 0,3,2,2,5,1,56,7,22,0
807 | 140,5,3,3,6,1,47,7,22,0
808 | 290,1,6,2,5,5,38,6,22,1
809 | 350,7,4,3,7,2,47,6,22,0
810 | 55,1,5,2,6,6,49,4,22,1
811 | 31,3,3,3,6,2,29,7,22,0
812 | 17,7,2,2,6,0,57,6,22,0
813 | 51,4,6,3,5,6,68,3,22,1
814 | 140,7,2,2,4,0,76,6,22,0
815 | 9,4,6,2,6,5,66,6,22,1
816 | 0,7,5,1,6,4,59,4,22,1
817 | 640,7,5,3,6,4,37,7,22,0
818 | 32,2,5,2,6,6,38,6,22,1
819 | 5,7,6,2,6,5,47,7,22,1
820 | 8,1,5,2,4,5,36,7,22,1
821 | 18,0,5,4,6,0,45,7,22,0
822 | 0,6,5,2,6,5,39,7,22,1
823 | 0,1,3,2,6,1,34,6,22,0
824 | 0,3,6,6,4,0,49,4,22,0
825 | 31,2,6,2,6,5,36,6,22,1
826 | 350,7,6,1,6,6,81,5,22,1
827 | 20,1,5,2,6,4,29,4,22,1
828 | 70,3,5,3,4,0,45,6,22,0
829 | 31,3,5,2,6,5,21,4,22,1
830 | 3,7,2,4,3,6,33,6,22,1
831 | 9,7,4,4,2,2,44,3,23,0
832 | 59,1,2,2,6,4,52,7,23,0
833 | 27,2,3,5,7,1,38,4,23,0
834 | 51,4,2,3,6,2,44,5,23,0
835 | 9,7,6,2,6,6,87,7,23,1
836 | 0,2,7,2,6,5,22,3,23,1
837 | 88,0,3,3,5,2,32,6,23,1
838 | 67,0,4,5,6,4,69,3,23,0
839 | 29,2,6,2,5,6,49,6,23,1
840 | 5,0,6,2,6,6,53,3,23,1
841 | 0,0,6,1,6,5,44,6,23,1
842 | 900,1,6,2,7,5,34,6,23,1
843 | 18,1,6,1,5,5,55,7,23,1
844 | 190,2,3,3,6,0,35,6,23,0
845 | 2,7,4,5,5,3,55,3,23,0
846 | 5,3,6,3,5,5,27,6,23,1
847 | 56,3,4,4,5,1,26,6,23,0
848 | 75,7,4,2,6,5,54,6,23,0
849 | 56,0,5,2,6,5,42,4,23,1
850 | 0,5,6,1,6,6,57,7,23,1
851 | 0,0,7,1,4,6,54,6,23,1
852 | 75,6,6,3,6,6,55,6,23,1
853 | 1600,7,5,3,6,6,50,7,23,1
854 | 15,0,5,5,6,1,57,7,23,0
855 | 19,3,5,3,7,3,46,4,23,0
856 | 16,7,6,2,6,6,53,6,23,1
857 | 42,2,3,3,5,0,32,7,23,0
858 | 18,5,5,2,5,3,53,5,23,1
859 | 0,3,3,3,6,1,39,6,23,0
860 | 310,1,5,2,5,4,47,6,23,1
861 | 1600,7,5,2,4,2,57,4,23,0
862 | 23,5,6,3,6,6,49,6,23,1
863 | 20,1,5,4,6,5,31,5,23,0
864 | 51,5,5,3,5,5,43,6,23,1
865 | 0,2,5,2,5,4,44,6,23,1
866 | 0,4,4,3,6,0,39,6,23,0
867 | 0,2,6,1,6,5,49,4,23,1
868 | 18,7,5,4,6,4,72,6,23,1
869 | 7300,7,5,2,6,5,50,6,23,1
870 | 110,1,5,2,6,6,28,4,23,1
871 | 0,0,5,2,7,3,48,7,23,1
872 | 3500,1,3,4,7,1,32,6,23,0
873 | 720,7,5,5,5,1,63,4,23,0
874 | 9,4,4,5,6,5,36,4,23,1
875 | 47,7,6,3,6,6,36,6,23,1
876 | 350,7,3,2,7,2,53,3,23,0
877 | 0,5,2,2,6,2,44,7,23,0
878 | 0,0,4,2,6,6,41,7,24,1
879 | 83,0,2,3,6,1,56,7,24,0
880 | 1,4,4,4,6,2,63,7,24,0
881 | 190,7,2,4,6,0,52,6,24,0
882 | 0,7,3,3,7,2,43,7,24,0
883 | 12,7,4,3,6,2,40,3,24,0
884 | 9,5,5,1,7,4,69,4,24,1
885 | 23,7,2,2,6,0,49,7,24,0
886 | 9,1,3,3,6,2,65,7,24,0
887 | 18,5,6,1,6,5,53,7,24,1
888 | 0,5,5,3,5,6,50,4,24,1
889 | 12,3,2,4,6,0,27,5,24,0
890 | 0,6,5,3,5,5,44,6,24,1
891 | 170,2,2,3,5,0,54,7,24,0
892 | 0,7,4,2,6,4,33,5,24,1
893 | 9,0,4,4,6,3,48,7,24,0
894 | 23,3,5,2,6,5,54,5,24,1
895 | 0,0,6,2,5,6,56,3,24,1
896 | 9,1,2,4,7,2,34,7,24,0
897 | 290,7,6,4,7,6,41,6,24,0
898 | 1,0,5,1,5,6,40,6,24,1
899 | 350,1,7,2,6,6,55,6,24,1
900 | 20,0,4,3,5,5,38,6,24,1
901 | 0,3,6,2,6,6,40,6,24,1
902 | 23,1,6,1,6,6,46,4,24,1
903 | 150,4,3,3,4,0,26,6,24,0
904 | 31,0,5,2,7,3,49,6,24,0
905 | 0,7,4,1,5,6,51,5,24,1
906 | 9,2,5,2,6,4,46,6,24,0
907 | 47,0,3,4,6,2,40,7,24,0
908 | 900,0,3,4,7,2,30,5,24,0
909 | 83,3,2,3,6,2,45,5,24,0
910 | 18,7,5,4,6,4,52,7,24,1
911 | 0,0,6,1,5,6,36,6,24,1
912 | 20,0,4,3,5,3,49,6,24,0
913 | 24,7,3,4,5,1,38,7,24,0
914 | 18,0,2,4,6,1,51,7,24,0
915 | 9,3,3,2,5,1,47,6,24,0
916 | 0,1,6,1,5,6,52,7,24,1
917 | 9,0,6,2,6,6,33,6,24,1
918 | 0,4,4,2,6,6,50,4,24,1
919 | 18,7,6,2,5,4,48,7,24,1
920 | 19,3,2,2,6,0,36,6,24,0
921 | 31,3,2,3,6,1,35,7,24,0
922 | 3500,7,7,3,5,4,34,7,24,0
923 | 0,7,2,4,5,2,53,6,24,0
924 | 33,0,4,3,6,2,33,7,24,0
925 | 0,1,6,3,6,6,52,6,24,1
926 | 18,3,4,3,6,4,44,7,24,0
927 | 0,0,3,4,4,0,48,6,24,0
928 | 31,3,5,2,6,5,20,4,24,1
929 | 0,5,3,2,4,6,45,6,24,1
930 | 59,7,4,2,6,2,70,3,24,0
931 | 0,0,3,3,4,2,39,3,24,0
932 | 7300,7,3,3,5,1,40,7,24,1
933 | 75,4,5,2,7,5,62,6,24,1
934 | 0,7,5,2,6,4,46,6,24,1
935 | 27,7,4,4,7,2,46,3,24,0
936 | 1600,7,4,2,5,6,56,7,24,1
937 | 0,7,6,3,6,6,55,7,24,1
938 | 0,7,6,2,6,6,41,4,24,1
939 | 7300,1,2,3,6,0,43,7,24,0
940 | 16,7,7,1,7,6,34,3,24,1
941 | 0,7,7,1,6,4,73,6,24,1
942 | 0,7,5,2,6,6,50,6,24,1
943 | 0,3,6,2,7,5,43,6,24,1
944 | 0,6,6,2,5,6,46,7,24,1
945 | 18,7,4,2,6,3,61,7,24,1
946 |
--------------------------------------------------------------------------------