Difference between revisions of "Meteos/ExampleLinear"
(Created page with "== Predict sales using Meteos == In this example, user creates a prediction model which predict sales by using Linear Regression. Linear Regression is one of the algorithms i...") |
(→Predict sales using Meteos) |
||
Line 1: | Line 1: | ||
− | == Predict | + | == Predict a Sales Figures using Meteos == |
− | In this example, | + | In this example, you create a prediction model which predict sales by using Linear Regression. |
− | |||
− | + | Linear Regression is one of the algorithms in supervised learning. | |
− | |||
− | |||
[[File:Usecase.png]] | [[File:Usecase.png]] | ||
Line 15: | Line 12: | ||
Experiment is a workspace of Machine Learning. | Experiment is a workspace of Machine Learning. | ||
− | ''' | + | You have to confirm a glance image id of meteos image, and a neutron network id before creating a template. |
− | { | + | |
+ | You can use a format located in '''python-meteosclient/sample/json/template.json''' | ||
+ | |||
+ | <pre> | ||
+ | $ glance image-list | grep meteos | ||
+ | | 45de4bbd-8419-40ff-8ed7-fc065c05e34f | meteos | | ||
+ | </pre> | ||
+ | <pre> | ||
+ | $ neutron net-list | grep public | ||
+ | | 84c13e76-ced9-4142-a885-280784f1f7a3 | public | a14de1c5-b8d4-434b-a056-9b0049b93402 | | ||
+ | </pre> | ||
+ | <pre> | ||
+ | $ vim sample/json/template.json | ||
+ | </pre> | ||
+ | <pre> | ||
+ | $ cat sample/json/template.json | ||
+ | { | ||
"display_name": "example-template", | "display_name": "example-template", | ||
"display_description": "This is a sample template of experiment", | "display_description": "This is a sample template of experiment", | ||
− | "image_id" : " | + | "image_id" : "45de4bbd-8419-40ff-8ed7-fc065c05e34f", |
"master_nodes_num": 1, | "master_nodes_num": 1, | ||
+ | "master_flavor_id": "4", | ||
"worker_nodes_num": 2, | "worker_nodes_num": 2, | ||
− | "spark_version": "1.6" | + | "worker_flavor_id": "2", |
− | + | "spark_version": "1.6.0", | |
− | + | "floating_ip_pool": "84c13e76-ced9-4142-a885-280784f1f7a3" | |
− | + | } | |
+ | </pre> | ||
+ | <pre> | ||
+ | $ meteos template-create --json sample/json/template.json | ||
+ | +---------------+-----------------------------------------+ | ||
+ | | Property | Value | | ||
+ | +---------------+-----------------------------------------+ | ||
+ | | cluster_id | None | | ||
+ | | created_at | 2016-12-04T07:16:29.000000 | | ||
+ | | description | This is a sample template of experiment | | ||
+ | | id | 8b7b9b89-f119-4b9b-b9b0-31598f819f1a | | ||
+ | | master_flavor | 4 | | ||
+ | | master_nodes | 1 | | ||
+ | | name | example-template | | ||
+ | | project_id | 67401cca74c2409b939e944bc6c8fcbe | | ||
+ | | spark_version | 1.6.0 | | ||
+ | | status | available | | ||
+ | | user_id | 181b1caa9d5b470393ca66b9e511d5b0 | | ||
+ | | worker_flavor | 2 | | ||
+ | | worker_nodes | 2 | | ||
+ | +---------------+-----------------------------------------+ | ||
+ | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== 2. Create a experiment from template === | === 2. Create a experiment from template === | ||
Create a experiment by using template created in the above step. | Create a experiment by using template created in the above step. | ||
+ | You have to confirm a neutron private network id and create keypair before creating a template. | ||
+ | |||
+ | You can use a format located in '''python-meteosclient/sample/json/experiment.json''' | ||
− | + | <pre> | |
− | + | $ nova keypair-add key1 > ~/key1.pem && chmod 600 ~/key1.pem | |
+ | </pre> | ||
+ | <pre> | ||
+ | $ neutron net-list | grep private | ||
+ | | 8abc626e-2b06-4c67-9b2c-0231f0cef5b8 | private | cb58940f-859b-48c6-b92a-3861470f1fc1 20.0.0.0/26 | | ||
+ | </pre> | ||
+ | <pre> | ||
+ | $ vim sample/json/experiment.json | ||
+ | </pre> | ||
+ | <pre> | ||
+ | $ cat sample/json/experiment.json | ||
+ | { | ||
"display_name": "example-experiment", | "display_name": "example-experiment", | ||
"display_description": "This is a sample experiment", | "display_description": "This is a sample experiment", | ||
"key_name": "key1", | "key_name": "key1", | ||
− | " | + | "neutron_management_network": "8abc626e-2b06-4c67-9b2c-0231f0cef5b8", |
− | "template_id": " | + | "template_id": "8b7b9b89-f119-4b9b-b9b0-31598f819f1a" |
− | + | } | |
− | + | </pre> | |
− | + | <pre> | |
− | + | $ meteos experiment-create --json sample/json/experiment.json | |
− | + | +--------------------+--------------------------------------+ | |
− | + | | Property | Value | | |
− | + | +--------------------+--------------------------------------+ | |
− | + | | created_at | 2016-12-04T07:20:11.000000 | | |
− | + | | description | This is a sample experiment | | |
− | + | | id | 91504a65-01cf-428f-81aa-596be7ca8619 | | |
− | + | | key_name | key1 | | |
− | + | | management_network | 8abc626e-2b06-4c67-9b2c-0231f0cef5b8 | | |
− | + | | name | example-experiment | | |
− | + | | project_id | 67401cca74c2409b939e944bc6c8fcbe | | |
+ | | status | creating | | ||
+ | | user_id | 181b1caa9d5b470393ca66b9e511d5b0 | | ||
+ | +--------------------+--------------------------------------+ | ||
+ | </pre> | ||
Meteos creates a experiment using OpenStack Sahara spark plugin. | Meteos creates a experiment using OpenStack Sahara spark plugin. | ||
− | |||
− | + | You can see a sahara cluster and nova VMs created by Meteos as below. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <pre> | |
− | + | $ openstack dataprocessing cluster list (or sahara cluster-list) | |
− | + | +------------------+--------------------------------------+-------------+----------------+----------+ | |
− | + | | Name | Id | Plugin name | Plugin version | Status | | |
− | + | +------------------+--------------------------------------+-------------+----------------+----------+ | |
− | + | | cluster-91504a65 | 13418fd9-5d2a-4ee6-b384-cb250b7e7714 | spark | 1.6.0 | Spawning | | |
− | + | +------------------+--------------------------------------+-------------+----------------+----------+ | |
− | + | </pre> | |
+ | <pre> | ||
+ | $ openstack server list (or nova list) | ||
+ | +--------------------------------------+----------------------------+--------+----------+------------+ | ||
+ | | ID | Name | Status | Networks | Image Name | | ||
+ | +--------------------------------------+----------------------------+--------+----------+------------+ | ||
+ | | 58818eb5-ade7-407c-8c76-9fd9809632b4 | cluster-91504a65-workers-1 | BUILD | | meteos | | ||
+ | | a151dbd9-de51-43ca-afb8-1fdeecce2891 | cluster-91504a65-workers-0 | BUILD | | meteos | | ||
+ | | d02d85c5-0960-4b7e-880c-26b73c5dd8ad | cluster-91504a65-master-0 | BUILD | | meteos | | ||
+ | +--------------------------------------+----------------------------+--------+----------+------------+ | ||
+ | </pre> | ||
=== 3. Upload a raw data === | === 3. Upload a raw data === | ||
− | Upload a raw data (sales data) to OpenStack Swift | + | Upload a raw data (in this example past sales figures data) to OpenStack Swift. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ''' | + | You can use a sample data located in '''python-meteosclient/sample/data/linear_data.txt''' |
− | + | Raw data shows "sales figures", "day", "month", "year", "day of week", "parameter which indicates weather", "degree", "humidity" from left. | |
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 00:39, 8 December 2016
Contents
Predict a Sales Figures using Meteos
In this example, you create a prediction model which predict sales by using Linear Regression.
Linear Regression is one of the algorithms in supervised learning.
1. Create a experiment template
Create template of experiment. Experiment is a workspace of Machine Learning.
You have to confirm a glance image id of meteos image, and a neutron network id before creating a template.
You can use a format located in python-meteosclient/sample/json/template.json
$ glance image-list | grep meteos | 45de4bbd-8419-40ff-8ed7-fc065c05e34f | meteos |
$ neutron net-list | grep public | 84c13e76-ced9-4142-a885-280784f1f7a3 | public | a14de1c5-b8d4-434b-a056-9b0049b93402 |
$ vim sample/json/template.json
$ cat sample/json/template.json { "display_name": "example-template", "display_description": "This is a sample template of experiment", "image_id" : "45de4bbd-8419-40ff-8ed7-fc065c05e34f", "master_nodes_num": 1, "master_flavor_id": "4", "worker_nodes_num": 2, "worker_flavor_id": "2", "spark_version": "1.6.0", "floating_ip_pool": "84c13e76-ced9-4142-a885-280784f1f7a3" }
$ meteos template-create --json sample/json/template.json +---------------+-----------------------------------------+ | Property | Value | +---------------+-----------------------------------------+ | cluster_id | None | | created_at | 2016-12-04T07:16:29.000000 | | description | This is a sample template of experiment | | id | 8b7b9b89-f119-4b9b-b9b0-31598f819f1a | | master_flavor | 4 | | master_nodes | 1 | | name | example-template | | project_id | 67401cca74c2409b939e944bc6c8fcbe | | spark_version | 1.6.0 | | status | available | | user_id | 181b1caa9d5b470393ca66b9e511d5b0 | | worker_flavor | 2 | | worker_nodes | 2 | +---------------+-----------------------------------------+
2. Create a experiment from template
Create a experiment by using template created in the above step. You have to confirm a neutron private network id and create keypair before creating a template.
You can use a format located in python-meteosclient/sample/json/experiment.json
$ nova keypair-add key1 > ~/key1.pem && chmod 600 ~/key1.pem
$ neutron net-list | grep private | 8abc626e-2b06-4c67-9b2c-0231f0cef5b8 | private | cb58940f-859b-48c6-b92a-3861470f1fc1 20.0.0.0/26 |
$ vim sample/json/experiment.json
$ cat sample/json/experiment.json { "display_name": "example-experiment", "display_description": "This is a sample experiment", "key_name": "key1", "neutron_management_network": "8abc626e-2b06-4c67-9b2c-0231f0cef5b8", "template_id": "8b7b9b89-f119-4b9b-b9b0-31598f819f1a" }
$ meteos experiment-create --json sample/json/experiment.json +--------------------+--------------------------------------+ | Property | Value | +--------------------+--------------------------------------+ | created_at | 2016-12-04T07:20:11.000000 | | description | This is a sample experiment | | id | 91504a65-01cf-428f-81aa-596be7ca8619 | | key_name | key1 | | management_network | 8abc626e-2b06-4c67-9b2c-0231f0cef5b8 | | name | example-experiment | | project_id | 67401cca74c2409b939e944bc6c8fcbe | | status | creating | | user_id | 181b1caa9d5b470393ca66b9e511d5b0 | +--------------------+--------------------------------------+
Meteos creates a experiment using OpenStack Sahara spark plugin.
You can see a sahara cluster and nova VMs created by Meteos as below.
$ openstack dataprocessing cluster list (or sahara cluster-list) +------------------+--------------------------------------+-------------+----------------+----------+ | Name | Id | Plugin name | Plugin version | Status | +------------------+--------------------------------------+-------------+----------------+----------+ | cluster-91504a65 | 13418fd9-5d2a-4ee6-b384-cb250b7e7714 | spark | 1.6.0 | Spawning | +------------------+--------------------------------------+-------------+----------------+----------+
$ openstack server list (or nova list) +--------------------------------------+----------------------------+--------+----------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------------------------+--------+----------+------------+ | 58818eb5-ade7-407c-8c76-9fd9809632b4 | cluster-91504a65-workers-1 | BUILD | | meteos | | a151dbd9-de51-43ca-afb8-1fdeecce2891 | cluster-91504a65-workers-0 | BUILD | | meteos | | d02d85c5-0960-4b7e-880c-26b73c5dd8ad | cluster-91504a65-master-0 | BUILD | | meteos | +--------------------------------------+----------------------------+--------+----------+------------+
3. Upload a raw data
Upload a raw data (in this example past sales figures data) to OpenStack Swift.
You can use a sample data located in python-meteosclient/sample/data/linear_data.txt
Raw data shows "sales figures", "day", "month", "year", "day of week", "parameter which indicates weather", "degree", "humidity" from left.