perl for visualization

64
Perl for Visualization YAPCASIA:2013 9/21 1 13921日土曜日

Upload: daichi-morifuji

Post on 31-May-2015

2.270 views

Category:

Technology


0 download

DESCRIPTION

Data::Cube calculates Hash Array in order to pass the data array to d3.js !

TRANSCRIPT

Page 1: Perl for visualization

Perl forVisualization

YAPCASIA:2013 9/21113年9月21日土曜日

Page 2: Perl for visualization

print Dumper $me{ twitter => “@muddydixon”, organization => “NIFTY”, job => “low spec full stack engineer”, skill => [ “data collecting”, “data cleansing”, “visualization”, ]}

213年9月21日土曜日

Page 3: Perl for visualization

Today’s Topic

313年9月21日土曜日

Page 4: Perl for visualization

Today’s Topic

413年9月21日土曜日

Page 5: Perl for visualization

Key of VisualizationSTORIES

are main concept of visualizationare buried in dataenhance your business

513年9月21日土曜日

Page 6: Perl for visualization

VisualizationTwo purposes:

1.Explanatory visualization 2.Exploratory visualization

613年9月21日土曜日

Page 7: Perl for visualization

Explanatory visualizationcommunicating information clearly and effectively

713年9月21日土曜日

Page 8: Perl for visualization

813年9月21日土曜日

Page 9: Perl for visualization

Can you findSTORIES?

913年9月21日土曜日

Page 10: Perl for visualization

1013年9月21日土曜日

Page 11: Perl for visualization

1113年9月21日土曜日

Page 12: Perl for visualization

1213年9月21日土曜日

Page 13: Perl for visualization

加齢による技術向上

The more use, the higher skill

1313年9月21日土曜日

Page 14: Perl for visualization

1413年9月21日土曜日

Page 15: Perl for visualization

ひとりでできない10年選手はいなかった

Everybody who touch perl 10 years use perl :)1513年9月21日土曜日

Page 16: Perl for visualization

1613年9月21日土曜日

Page 17: Perl for visualization

7-9年目にがんばろう

7-10 years users practice more!

1713年9月21日土曜日

Page 18: Perl for visualization

1813年9月21日土曜日

Page 19: Perl for visualization

ここから読み取るのはムリ

We cannot find STORIES from text log1913年9月21日土曜日

Page 20: Perl for visualization

This is thePOWER of Explanatoryvisualization

2013年9月21日土曜日

Page 21: Perl for visualization

I / You caninform STORIES in data

to my / your colleagueto my / your bossto my / your audiences

2113年9月21日土曜日

Page 22: Perl for visualization

Exploratory visualizationVisualization allow you to find STORIES from dataData Mining

2213年9月21日土曜日

Page 23: Perl for visualization

via(道具としての)データサイエンティストのつかい方

2313年9月21日土曜日

Page 24: Perl for visualization

ProblemsData Mining Engineer

a few domain specific knowledgeDomain Specialist

a few mining skill2413年9月21日土曜日

Page 25: Perl for visualization

GOALBusinessSuccess

Domain Specific Knowledge

Data Mining Skill

2513年9月21日土曜日

Page 26: Perl for visualization

How to applyDomain Specific Knowledgeto Data Mining Processes

2613年9月21日土曜日

Page 27: Perl for visualization

What is Glue between two?What is Ladder to Goal?

2713年9月21日土曜日

Page 28: Perl for visualization

GOALBusinessSuccess

Domain Specific Knowledge

Data Mining Skill

2813年9月21日土曜日

Page 29: Perl for visualization

Ans. Visualization

2913年9月21日土曜日

Page 30: Perl for visualization

GOALBusinessSuccess

Domain Specific Knowledge

Data Mining Skill

Trends

five-numbersummary

Co-occurence

Mosaic map

Flow chart

Parallel chart3013年9月21日土曜日

Page 31: Perl for visualization

3113年9月21日土曜日

Page 32: Perl for visualization

Domain Specific Expert

Data Mining Engineer

3213年9月21日土曜日

Page 33: Perl for visualization

It looks like communicationto your data and your collaborators

3313年9月21日土曜日

Page 34: Perl for visualization

Exploratory Visualizationfor Exploratory Data Analysis

do before model processing or fitting, testing

with Domain specific knowledge

3413年9月21日土曜日

Page 35: Perl for visualization

How to communicate ?RSS-PlusSYSTATSPSSPands

3513年9月21日土曜日

Page 36: Perl for visualization

We have Perl !!

3613年9月21日土曜日

Page 37: Perl for visualization

Perl Data Language

3713年9月21日土曜日

Page 38: Perl for visualization

Perl Data Languagestandard Perl the ability to compactly store and speedily manipulate the large N-dimensional data arrays which are the bread and butter of scientific computing.PDL turns Perl into a free, array-oriented, numerical language similar to (but, we believe, better than) such commercial packages as IDL and MatLab. One can write simple perl

3813年9月21日土曜日

Page 39: Perl for visualization

Perl Data Languagestandard Perl the ability to compactly store and speedily manipulate the large N-dimensional data arrays which are the bread and butter of scientific computing.PDL turns Perl into a free, array-oriented, numerical language similar to (but, we believe, better than) such commercial packages as IDL and MatLab. One can write simple perl

3913年9月21日土曜日

Page 40: Perl for visualization

Perl Data Languagestandard Perl the ability to compactly store and speedily manipulate the large N-dimensional data arrays which are the bread and butter of scientific computing.PDL turns Perl into a free, array-oriented, numerical language similar to (but, we believe, better than) such commercial packages as IDL and MatLab. One can write simple perl

We wantHash Object

4013年9月21日土曜日

Page 41: Perl for visualization

#!/usr/bin/env perluse strict;use warnings;use Data::Dumper;use PDL; my $obj;$obj = pdl([[1,2,3],[4,5,6]]);print $obj; # [# [1 2 3]# [4 5 6]# ] $obj = pdl([{a => 1, b => 2, c => 3}, {a => 4, b => 5, c => 6}]);# Hash given as a pdl - but not {PDL} key! at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 1292.

# 工エェ(´Д`)ェエ工

4113年9月21日土曜日

Page 42: Perl for visualization

4213年9月21日土曜日

Page 43: Perl for visualization

Data::Cubeis an array of multi-dimensional datahas OLAP methods: dice, slice, etc.

4313年9月21日土曜日

Page 44: Perl for visualization

Slice Rotate

DiceDrill-down

4413年9月21日土曜日

Page 45: Perl for visualization

4513年9月21日土曜日

Page 46: Perl for visualization

4613年9月21日土曜日

Page 47: Perl for visualization

4713年9月21日土曜日

Page 48: Perl for visualization

え・・・4813年9月21日土曜日

Page 49: Perl for visualization

Data::Cube released!processing Array of Hash Objectadd / remove rollup measure add / remove dimensionadd / remove hierarchy

4913年9月21日土曜日

Page 50: Perl for visualization

Data::Cube 1. Data Date Country SalesPerson Product Units Unit_Cost Total 3/15/2005 US Sorvino Pencil 56 2.99 167.44 3/7/2006 US Sorvino Binder 7 19.99 139.93 8/24/2006 US Sorvino Desk 3 275.00 825.00 9/27/2006 US Sorvino Pen 76 1.99 151.24 5/22/2005 US Thompson Pencil 32 1.99 63.68 10/14/2006 US Thompson Binder 57 19.99 1139.43 4/18/2005 US Andrews Pencil 75 1.99 149.25 4/10/2006 US Andrews Pencil 66 1.99 131.34 10/31/2006 US Andrews Pencil 114 1.29 147.06

5013年9月21日土曜日

Page 51: Perl for visualization

Data::Cube 2. Usage my $file = shift; my $data = Text::CSV::Slurp->load(file => $file); my $cube;  say "============================================================"; say "raw data size: ".(scalar @$data)."\n";  say "\n============================================================"; $cube = new Data::Cube("experience"); $cube->put($data); say Dumper $cube->rollup(noValues => 1);  say "\n============================================================"; $cube->add_dimension("skill"); say Dumper $cube->rollup(noValues => 1);

5113年9月21日土曜日

Page 52: Perl for visualization

Data::Cube 2. Usage my $file = shift; my $data = Text::CSV::Slurp->load(file => $file); my $cube;  say "============================================================"; say "raw data size: ".(scalar @$data)."\n";  say "\n============================================================"; $cube = new Data::Cube("experience"); $cube->put($data); say Dumper $cube->rollup(noValues => 1);  say "\n============================================================"; $cube->add_dimension("skill"); say Dumper $cube->rollup(noValues => 1);

たったのこれだけ

5213年9月21日土曜日

Page 53: Perl for visualization

Data::Cube 3. Results$VAR1 = [ { 'count' => 150, 'dim' => 10年以上 }, { 'count' => 76, 'dim' => 1~3年 }, { 'count' => 32, 'dim' => 1年未満 }, { 'count' => 93, 'dim' => 4~6年 }, { 'count' => 43, 'dim' => 7~9年 } ];

5313年9月21日土曜日

Page 54: Perl for visualization

Data::Cube 4. Results$VAR1 = [ { 'dim' => 10年以上, 'values' => [ { 'count' => 79, 'dim' => 上級者(一通り書こうと思えば書ける。わかんなかったらとりあえずソースコード読んじゃう) }, { 'count' => 71, 'dim' => 中級者(だいたいやりたいことはできるが、本やサイトを頼りにして確認したりする) }]}, { 'dim' => 1~3年, 'values' => [ { 'count' => 8, 'dim' => 上級者(一通り書こうと思えば書ける。わかんなかったらとりあえずソースコード読んじゃう) }, { 'count' => 56, 'dim' => 中級者(だいたいやりたいことはできるが、本やサイトを頼りにして確認したりする) }, { 'count' => 12, 'dim' => 初級者(人に聞いたりしないとなかなか書けない) }]}, { 'dim' => 1年未満, 'values' => [ { 'count' => 11, 'dim' => 中級者(だいたいやりたいことはできるが、本やサイトを頼りにして確認したりする) }, { 'count' => 21, 'dim' => 初級者(人に聞いたりしないとなかなか書けない) }]}, { 'dim' => 4~6年, 'values' => [ { 'count' => 25, 'dim' => 上級者(一通り書こうと思えば書ける。わかんなかったらとりあえずソースコード読んじゃう) }, { 'count' => 64, 'dim' => 中級者(だいたいやりたいことはできるが、本やサイトを頼りにして確認したりする) }, { 'count' => 4, 'dim' => 初級者(人に聞いたりしないとなかなか書けない) }]}, { 'dim' => 7~9年, 'values' => [ { 'count' => 19, 'dim' => 上級者(一通り書こうと思えば書ける。わかんなかったらとりあえずソースコード読んじゃう) }, { 'count' => 23, 'dim' => 中級者(だいたいやりたいことはできるが、本やサイトを頼りにして確認したりする) }, { 'count' => 1, 'dim' => 初級者(人に聞いたりしないとなかなか書けない) }]}];

5413年9月21日土曜日

Page 55: Perl for visualization

Data::Cube 5. Measure my $cube = new Data::Cube("Country"); $cube->put($data); $cube->add_measure("sum", sub { my $sum = 0; foreach my $d (@_){ $sum += $d->{Units};} $sum;}); $cube->add_measure("mean", sub { my $sum = 0; foreach my $d (@_){ $sum += $d->{Units};} $sum / (scalar @_);}); print Dumper $cube->rollup(noValues => 1);  $cube->add_dimension("Product"); print Dumper $cube->rollup(noValues => 1);

5513年9月21日土曜日

Page 56: Perl for visualization

Data::Cube 5. Measure my $cube = new Data::Cube("Country"); $cube->put($data); $cube->add_measure("sum", sub { my $sum = 0; foreach my $d (@_){ $sum += $d->{Units};} $sum;}); $cube->add_measure("mean", sub { my $sum = 0; foreach my $d (@_){ $sum += $d->{Units};} $sum / (scalar @_);}); print Dumper $cube->rollup(noValues => 1);  $cube->add_dimension("Product"); print Dumper $cube->rollup(noValues => 1);たったのこれだけ

5613年9月21日土曜日

Page 57: Perl for visualization

Data::Cube 6. Measure$VAR1 = [ { 'count' => 10, 'dim' => 'CA', 'sum' => 687, 'mean' => '68.7' }, { 'count' => 11, 'dim' => 'UK', 'sum' => 764, 'mean' => '69.4545454545455' }, { 'count' => 22, 'dim' => 'US', 'sum' => 1103, 'mean' => '50.1363636363636' } ];

5713年9月21日土曜日

Page 58: Perl for visualization

Data::Cube 7. Measure$VAR1 = [ { 'values' => [ { 'count' => 5, 'dim' => 'Binder', 'sum' => 288, 'mean' => '57.6'}, { 'count' => 1, 'dim' => 'Pen', 'sum' => 51, 'mean' => 51}, { 'count' => 1, 'dim' => 'PenSet', 'sum' => 61, 'mean' => 61}, { 'count' => 3, 'dim' => 'Pencil', 'sum' => 287, 'mean' => '95.6666666666667'} ], 'dim' => 'CA' }, { 'values' => [ { 'count' => 4, 'dim' => 'Binder', 'sum' => 242, 'mean' => '60.5'}, { 'count' => 1, 'dim' => 'Pen', 'sum' => 12, 'mean' => 12}, { 'count' => 3, 'dim' => 'PenSet', 'sum' => 205, 'mean' => '68.3333333333333'}, { 'count' => 3, 'dim' => 'Pencil', 'sum' => 305, 'mean' => '101.666666666667'} ], 'dim' => 'UK' },

5813年9月21日土曜日

Page 59: Perl for visualization

to Visualization$cube -> HASH ref -> JSONJSON -> d3.js -> visualization

5913年9月21日土曜日

Page 60: Perl for visualization

Summary

6013年9月21日土曜日

Page 61: Perl for visualization

Summaryせっかく紹介しましたが、僕はこの手の処理はRでやります

6113年9月21日土曜日

Page 62: Perl for visualization

> data = read.csv("./data/perl5census2013.csv")> summary(data) address experience 関東地方 :292 1~3年 : 76 近畿地方 : 39 10年以上:150 中部地方 : 23 1年未満 : 32 九州地方・沖縄: 17 4~6年 : 93 北海道地方 : 12 7~9年 : 43 東北地方 : 6 (Other) : 5 skill 初級者(人に聞いたりしないとなかなか書けない) : 38 上級者(一通り書こうと思えば書ける。わかんなかったらとりあえずソースコード読んじゃう):131 中級者(だいたいやりたいことはできるが、本やサイトを頼りにして確認したりする) :225

frequencyatbusiness frequencyatprivate Min. : 1.000 Min. : 1.000 1st Qu.: 2.000 1st Qu.: 2.000 Median : 6.000 Median : 5.000 Mean : 5.779 Mean : 5.388 3rd Qu.:10.000 3rd Qu.: 8.000 Max. :10.000 Max. :10.000

versionmanager システム Perl  (rpm, yum, インストール済みのperl等) :136 システム Perl  (rpm, yum, インストール済みのperl等), perlbrew : 92 perlbrew : 76 システム Perl  (rpm, yum, インストール済みのperl等), perlbrew, plenv: 14 perlbrew, plenv : 12 plenv : 9 (Other) : 55 2行

6213年9月21日土曜日

Page 63: Perl for visualization

Summary: but継続的な可視化を専門家に見せるとき圧倒的な優位性!

6313年9月21日土曜日

Page 64: Perl for visualization

Summary: ExampleTime Series

sales, repeat rate, DAU, system info, activitiesEffects of trial / campaign

attribution, condition, cost, cash back, etc.

6413年9月21日土曜日