SlideShare a Scribd company logo
1 of 21
Download to read offline
データマイニング⼊⾨
Raspberry PIで学ぶR
20180125@nmiri
技術士(情報工学)・博士(工学)
小川清(名古屋市工業研究所)
@kaizen_nagoya ©
<資料中敬称略>
2017/09/24
1
⽬次
´⽬標設定
´機材確認
´データ取得
´導⼊
´起動
´実⾏
´描画
2017/09/24
2
(c) @kaizen_nagoya
´⼀括実⾏
´知⾒
´まとめ
´警告・誤り
´⼀括実⾏時エラー
´⽬標達成度
´参考⽂献・URL
´資料の作り⽅
データマイニング⼊⾨
2017/09/24
(c) @kaizen_nagoya
3
´R
´オープンソースの統計処理
´理論中⼼からデータ中⼼
´データマイニング
´マイニング:⾦鉱を掘り当てる
´理論的⼿法と発⾒的⼿法
´複数の⼿法による⽐較
⽬標設定
´Rの仕組みを習得する
´Pythonとの住み分けを考える
´どのOSで操作すると便利かを検討する
´企業向けのR & Pythonの教材を揃える
´⽂字コードの対応を整理する
2017/09/24
4
(c) @kaizen_nagoya
機材確認
´ Raspberry PI 3B
´ 電源⽤USBケーブル+USBスイッチ
´ マイクロSDカード
´ Raspbian導⼊
´ rootパスワード設定
´ piパスアード設定
´ HDMIケーブル
´ Macintosh mini(以下Raspberry Piと共有)
´ ディスプレイ
´ マウス
´ キーボード
2017/09/24
(c) @kaizen_nagoya
5
データ取得
´ ダウンロード
´ wget推奨
´ apt-get install wget
´ Mac: brew install wget
´ wget http://www.tokyo-tosho.co.jp/books/978-4-489-02045-2/DL02045_2017.zip
´ unzip DL02045_2017.zip
´ cd Program
´ cd chap1
´ cp *.csv RD.csv
´ cp *.txt RD.txt
´ 課題:ファイル名
´ ⽂字コード変換する(OSが⽇本語ファイル名に対応している場合)
´ 簡単な略称にする
2017/09/24
(c) @kaizen_nagoya
6
導⼊
´ sudo apt-get update
´ sudo apt-get install r-base
´ 課題:apt-getだとbrew installより版が古い(20190120現在)
´ Raspbian
´ Ubuntu/
´ Mac
2017/09/24
(c) @kaizen_nagoya
7
起動
´ R
´ R version 3.3.3(2017-03-06) -- "Another Canoe”
´ Copyright (C) 2017 The R Foundation for Statistical Computing
´ Platform: arm-unknown-linux-gnueabihf (32-bit)
´ R は、⾃由なソフトウェアであり、「完全に無保証」です。
´ ⼀定の条件に従えば、⾃由にこれを再配布することができます。
´ 配布条件の詳細に関しては、'license()' あるいは 'licence()' と⼊⼒してください。
´ R は多くの貢献者による共同プロジェクトです。
´ 詳しくは 'contributors()' と⼊⼒してください。
´ また、R や R のパッケージを出版物で引⽤する際の形式については
´ 'citation()' と⼊⼒してください。
´ 'demo()' と⼊⼒すればデモをみることができます。
´ 'help()' とすればオンラインヘルプが出ます。
´ 'help.start()' で HTML ブラウザによるヘルプがみられます。
´ 'q()' と⼊⼒すれば R を終了します。
2017/09/24
(c) @kaizen_nagoya
8
実⾏
´ データの⽂字コード変換:資料データがshift-JIS, RaspbianはUTF-8
´ iconv -f Shift_JIS -t UTF8 *.csv > RD8.csv
´ iconv -f Shift_JIS -t UTF8 *.txt > RD8.txt
´ > RR<-read.csv("RD8.csv")
´ > write.csv(RR,"out.csv")
´ > str(RR)
´ 'data.frame': 12 obs. of 5 variables:
´ $ ⾼跳び : num 1.81 1.9 1.8 1.9 1.93 ...
´ $ X100m⾛ : num 12 11 11 10.8 10.8 10.6 10.5 10 9.92 9.96 ...
´ $ ⾛り幅跳び: num 6.35 7.18 7.34 7.48 7.6 ...
´ $ 開催年 : int 1896 1900 1904 1908 1912 1920 1956 1964 1988
1992 ...
´ $ 区分 : Factor w/ 2 levels "戦前","戦後": 1 1 1 1 1 1 2 2 2 2 ...
2017/09/24
(c) @kaizen_nagoya
9
´ > summary(RR) ⾼跳び X100m⾛ ⾛り幅跳び 開催年 区分
´ Min. :1.800 Min. : 9.84 Min. :6.350 Min. :1896 戦前:6
´ 1st Qu.:1.900 1st Qu.: 9.95 1st Qu.:7.301 1st Qu.:1907 戦後:6
´ Median :2.028 Median :10.55 Median :7.715 Median :1938
´ Mean :2.087 Mean :10.52 Mean :7.764 Mean :1945
´ 3rd Qu.:2.345 3rd Qu.:10.85 3rd Qu.:8.357 3rd Qu.:1989
´ Max. :2.390 Max. :12.00 Max. :8.720 Max. :2004
´ > by (RR,RR$ 区分,summary)
´ RR$区分: 戦前 ⾼跳び X100m⾛ ⾛り幅跳び 開催年 区分
´ Min. :1.800 Min. :10.60 Min. :6.350 Min. :1896 戦前:6
´ 1st Qu.:1.833 1st Qu.:10.80 1st Qu.:7.159 1st Qu.:1901 戦後:0
´ Median :1.900 Median :10.90 Median :7.263 Median :1906
´ Mean :1.879 Mean :11.03 Mean :7.184 Mean :1907
´ 3rd Qu.:1.922 3rd Qu.:11.00 3rd Qu.:7.445 3rd Qu.:1911
´ Max. :1.936 Max. :12.00 Max. :7.600 Max. :1920
´ ------------------------------------------------------------
´ RR$区分: 戦後 ⾼跳び X100m⾛ ⾛り幅跳び 開催年 区分
´ Min. :2.120 Min. : 9.840 Min. :7.830 Min. :1956 戦前:0
´ 1st Qu.:2.220 1st Qu.: 9.867 1st Qu.:8.100 1st Qu.:1970 戦後:6
´ Median :2.350 Median : 9.940 Median :8.405 Median :1990
´ Mean :2.295 Mean :10.012 Mean :8.343 Mean :1983
´ 3rd Qu.:2.375 3rd Qu.: 9.990 3rd Qu.:8.627 3rd Qu.:1995
´ Max. :2.390 Max. :10.500 Max. :8.720 Max. :2004
2017/09/24
(c) @kaizen_nagoya
10
描画
2017/09/24
(c) @kaizen_nagoya
11
´ > plot(RR$ 開催年,RR$⾼跳び)
´ > hist(RR$⾛り幅跳び)
⼀括実⾏
´ 実⾏したいコマンド列をテキストファイルで記述
´ R< RD.txt
´ Fatal error: you must specify '--save', '--no-save' or '--vanilla'
´ R < --save DR.txt
´ 警告
´ plot(RR$開催年,RR$⾼跳び)
´ 36 件の警告がありました (警告を⾒るには warnings() を使って下さい)
´ Warnings()の追記:次の⾏に記載すれば良い
´ plot(RR$開催年,RR$⾼跳び)
´ warnings()
´ 警告メッセージ:
´ 1: In title(...) :
´ 'mbcsToSbcs' 中の 'RR$開催年' で変換に失敗: <e9> をドットで置き換えま
した
2017/09/24
(c) @kaizen_nagoya
12
知⾒
´導⼊
´ Apt-getで導⼊するとMac のbrewより古い版になる
´起動
´ Macだと”r“でも起動する。Raspbian, ubuntuでは”R”だけ
´データ整理
´ Windowsでファイル名を⽇本語にすると他のOSに変換する⽅法を
検討しておく必要がある。
´実⾏
´ ⽂字化けする場合は、⽂字コード変換してから読み込む。
´ Ubuntuで⽂字化けしたまま動作。
´描画
´ Raspbian, Mac等X windowを使っているOSは90度傾く図がある
2017/09/24
(c) @kaizen_nagoya
13
まとめ
´わかったこと
´RはRaspbianで導⼊すると楽
´処理速度、メモリ容量、記録媒体などは課題
´わからなかったこと
´ファイル名のコード変換(⽇本語に対応していな
いOSだと無理)
´よかったこと
´Macintoshと⽐較ができた
´あらためたいこと
´⽂字コードの扱いに関する資料の整理(ファイル
名を含む)
2017/09/24
(c) @kaizen_nagoya
14
⽬標達成度
´Rの仕組みを習得する:100%
´Pythonとの住み分けを考える
´どのOSで操作すると便利かを検討する:50%
´Raspbian > Macintosh > ubuntu?
´Windowsとの⽐較がまだ
´企業向けのR & Pythonの教材を揃える:30%
´⽂字コードの対応を整理する
´ファイル名の扱いを検討する
´2章以降の整理
2017/09/24
15
(c) @kaizen_nagoya
警告・誤り
qiita参照
https://qiita.com/kaizen_nagoya/items/e8417310129c2425af59
´ Raspbian
´ SHIFT-JISコードファイルを読み込まない
´ Iconvでutf-8に変換
´ Mac
´ Unzipでsift-jisの⽇本語名ファイルを展開できず
´ ダブルクリックで解凍
´ 描画の際の⽂字化け
´ ubuntu
´ 最新のRを導⼊しようとしてエラー
2017/09/24
(c) @kaizen_nagoya
16
⼀括処理時のエラー
macにて
´ by(RR$区分,summary)
´ unique.default(x, nmax = nmax) でエラー:
´ unique() はベクトルにのみ使⽤できます
´ 呼び出し: by ... lapply -> FUN -> factor -> unique ->
unique.default
´ 実⾏が停⽌されました
´ 正しくはby(RR, RR$区分,summary)だった。⽂字変換誤り
´ plot(RR$開催年,RR$⾼跳び)
´ 36 件の警告がありました (警告を⾒るには warnings() を使って下
さい)
´ hist(RR$⾛り幅跳び)
´ 50 件以上の警告がありました (最初の 50 個の警告を⾒るには
warnings() を使って下さい)
2017/09/24
(c) @kaizen_nagoya
17
参考⽂献・URL
詳しくは下記qiita参照
´データマイニング⼊⾨ Rで学ぶ最新データ
解析、豊⽥秀樹、東京図書、2008
´R(データマイニング⼊⾨) Raspbian
(Raspberry PI),Mac OSX, docker/ubuntu
五段階。導⼊・起動・データ整理・実⾏・
描画。@kaizen_nagoya
´ https://qiita.com/kaizen_nagoya/items/e8417310129c2425af59
2017/09/24
(c) @kaizen_nagoya
18
ご静聴ありがとう
ございました
2017/09/24
19
不明点はご連絡を
©NMIRI
@kaizen_nagoya
(c) @kaizen_nagoya
資料の作り⽅
(⾒出しは60pt)
´ ⽬次をつける
´ 箇条書きは32ptから24ptの間
´ 階層構造を持たせる
´ 資料の出典はその場および参考⽂献(URL)⼀覧の両⽅に記載
´ なるべく図表を⼊れる
´ エラーメッセージ、エラー画像を貼り付ける(量が多い場合はURL)
´ 実演(demonstratiton)を途中で⼊れても良い
´ まとめ
´ わかったこと
´ わからなかったこと
´ よかったこと
´ あらためたいこと
´ 5分:5枚から20枚程度(この資料の20,21は別⽤途)
´ Slideshare.netに掲載しても良い 2017/09/24
(c) @kaizen_nagoya
20
資料の作り⽅
べからず集べし集
´ 真っ⾚は、危険なもの以外に使わない
´ ⽂字の⾊は3種類以内(例:⿊・⻘・薄茶)。
´ 種類の区別が必要な場合はその種類数
´ ⽂字形(フォント)は⽇本語・英語それぞれ3種類以内
´ 英語はTimes New Romanを推奨
´ 画⾯の⽂字は実際のフォントに合わせると良い
´ 斜体(Itaric)はアルファベット以外では⽤いない
´ 太字・下線よりは⽂字の⼤きさを変える
´ 実際の画⾯に合わせる場合はそのまま
´ できたと思ったら、全体を通じて⽂字の⼤きさを⼀回り、ふた回り⼤きく
する
´ 引⽤は「」でくくり著作権表⽰、参照・引⽤を明記する。
´ できればページ数を記載
´ Wikiからの引⽤は、引⽤した⽂字数以上をwikiに追記する
´ 簡単なのは参考⽂献の追加、⽂献からの引⽤ 2017/09/24
(c) @kaizen_nagoya
21

More Related Content

What's hot

Wifi商圈分析
Wifi商圈分析Wifi商圈分析
Wifi商圈分析元美 許
 
QGISで河川縦断図
QGISで河川縦断図QGISで河川縦断図
QGISで河川縦断図Mayumit
 
Node.js - sleep sort algorithm
Node.js - sleep sort algorithmNode.js - sleep sort algorithm
Node.js - sleep sort algorithmtakesako
 
Zabbixで学ぶ統計解析入門
Zabbixで学ぶ統計解析入門Zabbixで学ぶ統計解析入門
Zabbixで学ぶ統計解析入門Takeo Noda
 
Iugonet 20120810-nipr-sato
Iugonet 20120810-nipr-satoIugonet 20120810-nipr-sato
Iugonet 20120810-nipr-satoIugo Net
 
kagamicomput201806
kagamicomput201806kagamicomput201806
kagamicomput201806swkagami
 
120414 foss4g nagoya_presentation2
120414 foss4g nagoya_presentation2120414 foss4g nagoya_presentation2
120414 foss4g nagoya_presentation2Takayuki Nuimura
 

What's hot (8)

Wifi商圈分析
Wifi商圈分析Wifi商圈分析
Wifi商圈分析
 
QGISで河川縦断図
QGISで河川縦断図QGISで河川縦断図
QGISで河川縦断図
 
Node.js - sleep sort algorithm
Node.js - sleep sort algorithmNode.js - sleep sort algorithm
Node.js - sleep sort algorithm
 
Zabbixで学ぶ統計解析入門
Zabbixで学ぶ統計解析入門Zabbixで学ぶ統計解析入門
Zabbixで学ぶ統計解析入門
 
仮想記憶の構築法
仮想記憶の構築法仮想記憶の構築法
仮想記憶の構築法
 
Iugonet 20120810-nipr-sato
Iugonet 20120810-nipr-satoIugonet 20120810-nipr-sato
Iugonet 20120810-nipr-sato
 
kagamicomput201806
kagamicomput201806kagamicomput201806
kagamicomput201806
 
120414 foss4g nagoya_presentation2
120414 foss4g nagoya_presentation2120414 foss4g nagoya_presentation2
120414 foss4g nagoya_presentation2
 

More from Kiyoshi Ogawa

Misracompliant20162020
Misracompliant20162020Misracompliant20162020
Misracompliant20162020Kiyoshi Ogawa
 
High Quality Design with Hcd and hazop
High Quality Design with Hcd and hazopHigh Quality Design with Hcd and hazop
High Quality Design with Hcd and hazopKiyoshi Ogawa
 
Deep learningwithgithubanddocker
Deep learningwithgithubanddockerDeep learningwithgithubanddocker
Deep learningwithgithubanddockerKiyoshi Ogawa
 
Deep learningwithgithubanddocker
Deep learningwithgithubanddockerDeep learningwithgithubanddocker
Deep learningwithgithubanddockerKiyoshi Ogawa
 
Who like C++ coding standard
Who like C++ coding standardWho like C++ coding standard
Who like C++ coding standardKiyoshi Ogawa
 
Who enjoy a coding standard? ver. 0.30
Who enjoy a coding standard? ver. 0.30Who enjoy a coding standard? ver. 0.30
Who enjoy a coding standard? ver. 0.30Kiyoshi Ogawa
 
Who enjoy a coding standard? ver. 0.20
Who enjoy a coding standard? ver. 0.20Who enjoy a coding standard? ver. 0.20
Who enjoy a coding standard? ver. 0.20Kiyoshi Ogawa
 
Who enjoy a coding standard?
Who enjoy a coding standard?Who enjoy a coding standard?
Who enjoy a coding standard?Kiyoshi Ogawa
 
TOPPERS as an IoT OS(kernel)
TOPPERS as an IoT OS(kernel)TOPPERS as an IoT OS(kernel)
TOPPERS as an IoT OS(kernel)Kiyoshi Ogawa
 
How can we resolve problems.
How can we resolve problems.How can we resolve problems.
How can we resolve problems.Kiyoshi Ogawa
 
Hazop Safety and Security at Fukui 2017(2/2)
Hazop Safety and Security at Fukui 2017(2/2)Hazop Safety and Security at Fukui 2017(2/2)
Hazop Safety and Security at Fukui 2017(2/2)Kiyoshi Ogawa
 
Hazop Safety and Security at Fukui 2017(1/2)
Hazop Safety and Security at Fukui 2017(1/2)Hazop Safety and Security at Fukui 2017(1/2)
Hazop Safety and Security at Fukui 2017(1/2)Kiyoshi Ogawa
 
Hazop and triz by/of/for the children(3/3)
Hazop and triz by/of/for the children(3/3)Hazop and triz by/of/for the children(3/3)
Hazop and triz by/of/for the children(3/3)Kiyoshi Ogawa
 
Hazop and triz by/of/for the children(2/3)
Hazop and triz by/of/for the children(2/3)Hazop and triz by/of/for the children(2/3)
Hazop and triz by/of/for the children(2/3)Kiyoshi Ogawa
 
Hazop and triz by/of/for the children(1/3)
Hazop and triz by/of/for the children(1/3)Hazop and triz by/of/for the children(1/3)
Hazop and triz by/of/for the children(1/3)Kiyoshi Ogawa
 
Raspberrypitraining20171027
Raspberrypitraining20171027Raspberrypitraining20171027
Raspberrypitraining20171027Kiyoshi Ogawa
 
STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning
STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning
STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning Kiyoshi Ogawa
 

More from Kiyoshi Ogawa (20)

Misracompliant20162020
Misracompliant20162020Misracompliant20162020
Misracompliant20162020
 
High Quality Design with Hcd and hazop
High Quality Design with Hcd and hazopHigh Quality Design with Hcd and hazop
High Quality Design with Hcd and hazop
 
Deep learningwithgithubanddocker
Deep learningwithgithubanddockerDeep learningwithgithubanddocker
Deep learningwithgithubanddocker
 
Deep learningwithgithubanddocker
Deep learningwithgithubanddockerDeep learningwithgithubanddocker
Deep learningwithgithubanddocker
 
Nagoya2018
Nagoya2018Nagoya2018
Nagoya2018
 
Hazop tokyo201809
Hazop tokyo201809Hazop tokyo201809
Hazop tokyo201809
 
Who like C++ coding standard
Who like C++ coding standardWho like C++ coding standard
Who like C++ coding standard
 
Who enjoy a coding standard? ver. 0.30
Who enjoy a coding standard? ver. 0.30Who enjoy a coding standard? ver. 0.30
Who enjoy a coding standard? ver. 0.30
 
Who enjoy a coding standard? ver. 0.20
Who enjoy a coding standard? ver. 0.20Who enjoy a coding standard? ver. 0.20
Who enjoy a coding standard? ver. 0.20
 
Who enjoy a coding standard?
Who enjoy a coding standard?Who enjoy a coding standard?
Who enjoy a coding standard?
 
機械と標準
機械と標準機械と標準
機械と標準
 
TOPPERS as an IoT OS(kernel)
TOPPERS as an IoT OS(kernel)TOPPERS as an IoT OS(kernel)
TOPPERS as an IoT OS(kernel)
 
How can we resolve problems.
How can we resolve problems.How can we resolve problems.
How can we resolve problems.
 
Hazop Safety and Security at Fukui 2017(2/2)
Hazop Safety and Security at Fukui 2017(2/2)Hazop Safety and Security at Fukui 2017(2/2)
Hazop Safety and Security at Fukui 2017(2/2)
 
Hazop Safety and Security at Fukui 2017(1/2)
Hazop Safety and Security at Fukui 2017(1/2)Hazop Safety and Security at Fukui 2017(1/2)
Hazop Safety and Security at Fukui 2017(1/2)
 
Hazop and triz by/of/for the children(3/3)
Hazop and triz by/of/for the children(3/3)Hazop and triz by/of/for the children(3/3)
Hazop and triz by/of/for the children(3/3)
 
Hazop and triz by/of/for the children(2/3)
Hazop and triz by/of/for the children(2/3)Hazop and triz by/of/for the children(2/3)
Hazop and triz by/of/for the children(2/3)
 
Hazop and triz by/of/for the children(1/3)
Hazop and triz by/of/for the children(1/3)Hazop and triz by/of/for the children(1/3)
Hazop and triz by/of/for the children(1/3)
 
Raspberrypitraining20171027
Raspberrypitraining20171027Raspberrypitraining20171027
Raspberrypitraining20171027
 
STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning
STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning
STAMP/STPA and UML/HAZOP on the IoT and AI/Deep Learning
 

Datamining Introduction using R with Raspbian on Raspberry Pi 3B.