SlideShare a Scribd company logo
1 of 10
Download to read offline
情強アルゴリズム
DIMSUM Sampling
棚橋 耕太郎
2015.10.30
MLlibとは
• spark付属の機械学習ライブラリ
• 最新バージョンは1.5
• ストリーミングにも対応
• 最近はアルゴリズムの種類が増えてきている
例) L1,L2線形回帰、ロジスティック回帰、ALS(MF)、All-pair
similarities、gradient boosting、ランダムフォレスト、Word2Vec、
LDA、PCA、SVD、SVM、K-means、GMM、SGD、LBFGS
レコメンデーション
• MLlibでs3のデータに対してレコメンデーションの計算処理
を行い,結果をs3に書き出す.
kunuk.wordpress.com
item-item距離行列
を作るのが大変
MLlibを使ったレコメンデーション
	
  def	
  main(args:	
  Array[String])={	
  
	
  	
  	
  	
  val	
  conf	
  =	
  new	
  SparkConf().setMaster("yarn-­‐
client").setAppName("MllibTest")	
  
	
  	
  	
  	
  val	
  sc	
  =	
  new	
  SparkContext(conf)	
  
	
  	
  	
  	
  val	
  INPUT_FILENAME	
  =	
  "s3n://{bucket-­‐name}/spark/
vec.npy"	
  
	
  	
  	
  	
  val	
  rows	
  =	
  sc.textFile(INPUT_FILENAME).map	
  {	
  line	
  =>	
  
	
  	
  	
  	
  	
  	
  val	
  values	
  =	
  line.split('t').map(_.toDouble)	
  
	
  	
  	
  	
  	
  	
  Vectors.dense(values)	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  val	
  mat	
  =	
  new	
  RowMatrix(rows)	
  
	
  	
  	
  	
  val	
  simsPerfect	
  =	
  mat.columnSimilarities()	
  
	
  	
  	
  	
  simsPerfect.entries.saveAsTextFile("s3n://{bucket-­‐
name}/spark/sim")	
  
	
  	
  }	
  
行列に変換し、アイテム同士の
コサイン類似度を計算
columnSimilarities()
0.0 1.1 3.0
1.1 2.0 1.8
0.2 3.1 6.2
7.7 2.7 8.3
a b c
a・b/¦a¦¦b¦=0.3
a・c/¦a¦¦c¦=0.2
b・c/¦b¦¦c¦=0.5
all-pair
m 10^13
n 10^4
情弱(Naive)な方法
Zadeh, Reza Bosagh, and Gunnar Carlsson. "Dimension independent matrix square using
mapreduce." arXiv preprint arXiv:1304.1467 (2013).
シャッフルサイズ=>O(mL^2) m:行数,L:非ゼロ要素の個数
m 10^12, L 100くらいで計算不可能に
情強な方法
DIMSUM Sampling
0.0 1.1 3.0
1.1 2.0 1.8
0.2 3.1 6.2
7.7 2.7 8.3
ri
aij
cj
Zadeh, Reza Bosagh, and Gunnar Carlsson. "Dimension independent matrix square using
mapreduce." arXiv preprint arXiv:1304.1467 (2013).
シャッフルサイズ=>O(nLγ) m 10^13, n 10^4
DIMSUM code
一部抜粋
①
①
②
②
③
③
性能
のとき、計算精度は保存される
• うまく近似計算はできている
proof
multiplicative Chernoff boundを使う
Zadeh, Reza Bosagh, and Gunnar Carlsson. "Dimension independent matrix square using mapreduce." arXiv preprint arXiv:1304.1467 (2013).

More Related Content

More from Kotaro Tanahashi

NIPS Paper Reading, Data Programing
NIPS Paper Reading, Data ProgramingNIPS Paper Reading, Data Programing
NIPS Paper Reading, Data ProgramingKotaro Tanahashi
 
WSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender Systems
WSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender SystemsWSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender Systems
WSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender SystemsKotaro Tanahashi
 
変数の入れ替え(SWAPPING)で最速の方法は?
変数の入れ替え(SWAPPING)で最速の方法は?変数の入れ替え(SWAPPING)で最速の方法は?
変数の入れ替え(SWAPPING)で最速の方法は?Kotaro Tanahashi
 
SWARでpop countをしよう
SWARでpop countをしようSWARでpop countをしよう
SWARでpop countをしようKotaro Tanahashi
 
Deep Q-Network 論文輪読会
Deep Q-Network 論文輪読会Deep Q-Network 論文輪読会
Deep Q-Network 論文輪読会Kotaro Tanahashi
 
2.2. map reduce and the new software stack
2.2. map reduce and the new software stack2.2. map reduce and the new software stack
2.2. map reduce and the new software stackKotaro Tanahashi
 
deep learning library coyoteの開発(CNN編)
deep learning library coyoteの開発(CNN編)deep learning library coyoteの開発(CNN編)
deep learning library coyoteの開発(CNN編)Kotaro Tanahashi
 
recurrent models of visual attentionメモ
recurrent models of visual attentionメモrecurrent models of visual attentionメモ
recurrent models of visual attentionメモKotaro Tanahashi
 
Fokker–Planck equation and DPD simulations
Fokker–Planck equation and DPD simulationsFokker–Planck equation and DPD simulations
Fokker–Planck equation and DPD simulationsKotaro Tanahashi
 
DSP開発におけるSpark MLlibの活用
DSP開発におけるSpark MLlibの活用DSP開発におけるSpark MLlibの活用
DSP開発におけるSpark MLlibの活用Kotaro Tanahashi
 
How nosql fundamentally changed machine learning?
How nosql fundamentally changed machine  learning?How nosql fundamentally changed machine  learning?
How nosql fundamentally changed machine learning?Kotaro Tanahashi
 

More from Kotaro Tanahashi (13)

NIPS Paper Reading, Data Programing
NIPS Paper Reading, Data ProgramingNIPS Paper Reading, Data Programing
NIPS Paper Reading, Data Programing
 
WSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender Systems
WSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender SystemsWSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender Systems
WSDM2016読み会 Collaborative Denoising Auto-Encoders for Top-N Recommender Systems
 
変数の入れ替え(SWAPPING)で最速の方法は?
変数の入れ替え(SWAPPING)で最速の方法は?変数の入れ替え(SWAPPING)で最速の方法は?
変数の入れ替え(SWAPPING)で最速の方法は?
 
SWARでpop countをしよう
SWARでpop countをしようSWARでpop countをしよう
SWARでpop countをしよう
 
Deep Q-Network 論文輪読会
Deep Q-Network 論文輪読会Deep Q-Network 論文輪読会
Deep Q-Network 論文輪読会
 
2.2. map reduce and the new software stack
2.2. map reduce and the new software stack2.2. map reduce and the new software stack
2.2. map reduce and the new software stack
 
Cythonの一喜一憂
Cythonの一喜一憂Cythonの一喜一憂
Cythonの一喜一憂
 
deep learning library coyoteの開発(CNN編)
deep learning library coyoteの開発(CNN編)deep learning library coyoteの開発(CNN編)
deep learning library coyoteの開発(CNN編)
 
recurrent models of visual attentionメモ
recurrent models of visual attentionメモrecurrent models of visual attentionメモ
recurrent models of visual attentionメモ
 
LBFGSの実装
LBFGSの実装LBFGSの実装
LBFGSの実装
 
Fokker–Planck equation and DPD simulations
Fokker–Planck equation and DPD simulationsFokker–Planck equation and DPD simulations
Fokker–Planck equation and DPD simulations
 
DSP開発におけるSpark MLlibの活用
DSP開発におけるSpark MLlibの活用DSP開発におけるSpark MLlibの活用
DSP開発におけるSpark MLlibの活用
 
How nosql fundamentally changed machine learning?
How nosql fundamentally changed machine  learning?How nosql fundamentally changed machine  learning?
How nosql fundamentally changed machine learning?
 

情強アルゴリズムDIMSUM