局所性鋭敏型ハッシュ

局所性鋭敏型ハッシュ(きょくしょせいえいびんがたハッシュ、英語: locality sensitive hashing)とは高次元のデータを確率的な処理によって次元圧縮するための手法である。ハッシュの基本的な考え方は類似したデータが高確率で同じバケットに入るようにデータを整理するというものである。多くの場合においてこのバケットの数は入力されるデータサンプルの数よりもずっと小さくなる。

定義

局所性鋭敏型ハッシュを行うためのパラメータの集合をLSH族(Locality Sensitive Hashing Family)と呼ぶ。LSH族は距離空間 M = ( M , d ) {\displaystyle {\mathcal {M}}=(M,d)} と閾値 R > 0 {\displaystyle R>0} 、近似因子 c > 1 {\displaystyle c>1} によって定義される。LSH族[1][2]は2点 p , q M {\displaystyle p,q\in {\mathcal {M}}} について次の2つの性質、

  • d ( p , q ) R {\displaystyle d(p,q)\leq R} ならば h ( p ) = h ( q ) {\displaystyle h(p)=h(q)} となる確率は P 1 {\displaystyle P_{1}\,} 以上である。
  • d ( p , q ) c R {\displaystyle d(p,q)\geq cR} ならば h ( p ) = h ( q ) {\displaystyle h(p)=h(q)} となる確率は P 2 {\displaystyle P_{2}\,} 以下である。

を満たす関数 h : M S {\displaystyle h:{\mathcal {M}}\to S} により与えられる族であり, h {\displaystyle h} F {\displaystyle {\mathcal {F}}} から一様乱数にしたがって選択される。このとき d ( p , q ) {\displaystyle d(p,q)} は2点 p , q {\displaystyle p,q} の距離を表す関数であり、 P 1 > P 2 {\displaystyle P_{1}>P_{2}} となるよう設計する。このような族 F {\displaystyle {\mathcal {F}}} ( R , c R , P 1 , P 2 ) {\displaystyle (R,cR,P_{1},P_{2})} に鋭敏であるという。

これに準ずる定義として、領域 U {\displaystyle U} における類似度関数 ϕ : U × U [ 0 , 1 ] {\displaystyle \phi :U\times U\to [0,1]} によるものがある[3]。局所性鋭敏型ハッシュの性質は、ハッシュ関数の集合 H {\displaystyle H} と確率分布 D {\displaystyle D} により与えられる。あるハッシュ関数 h {\displaystyle h} は集合 H {\displaystyle H} から確率分布 D {\displaystyle D} により選ばれるが、 D {\displaystyle D} とは領域 U {\displaystyle U} に存在する2点 a , b {\displaystyle a,b} について、

P r h H [ h ( a ) = h ( b ) ] = ϕ ( a , b ) {\displaystyle Pr_{h\in H}[h(a)=h(b)]=\phi (a,b)}

を満たすような確率分布である。

手法

ハミング距離に基づく標本化

LSH族を構築するためのもっとも単純な手法はハミング距離に基づくものである。これは d {\displaystyle d} 次元のベクトル { 0 , 1 } d {\displaystyle \{0,1\}^{d}} に対して適応できる。この手法は d {\displaystyle d} 次元のベクトルについて i {\displaystyle i} 番目の座標値をハッシュ値として与えるような族 F {\displaystyle {\mathcal {F}}} により定義され、 F {\displaystyle {\mathcal {F}}} とは例えば F = { h : { 0 , 1 } d { 0 , 1 } h ( x ) = x i , i = 1... d } {\displaystyle {\mathcal {F}}=\{h:\{0,1\}^{d}\to \{0,1\}\mid h(x)=x_{i},i=1...d\}} のように与えられる。ここで F {\displaystyle {\mathcal {F}}} から h {\displaystyle h} を任意に選ぶということは、入力点から任意にビットを選択するということに他ならない。この時、族は次の性質を持つ。

P 1 = 1 R / d {\displaystyle P_{1}=1-R/d\,} , P 2 = 1 c R / d {\displaystyle P_{2}=1-cR/d\,}

安定分布に基づく手法

ハッシュ関数 h a , b ( υ ) : R d N {\displaystyle h_{\mathbf {a} ,b}({\boldsymbol {\upsilon }}):{\mathcal {R}}^{d}\to {\mathcal {N}}} d {\displaystyle d} 次元のベクトル v {\displaystyle v} を整数の集合に移すような関数であると定義する[4]。ハッシュ関数 h {\displaystyle h} は2つの乱数 a , b {\displaystyle a,b} によって定義される。ここで a {\displaystyle a} とは安定分布から独立に選ばれる乱数であり、 b {\displaystyle b} とは [ 0 , r ] {\displaystyle [0,r]} から一様に選ばれる実乱数である。 a {\displaystyle a} および b {\displaystyle b} が選ばれたとき、ハッシュ関数 h a , b {\displaystyle h_{\mathbf {a} ,b}}

h a , b ( υ ) = a υ + b r {\displaystyle h_{\mathbf {a} ,b}({\boldsymbol {\upsilon }})=\left\lfloor {\frac {\mathbf {a} \cdot {\boldsymbol {\upsilon }}+b}{r}}\right\rfloor }

のように与えられる。

この他にもデータをより適切に対応させるハッシュ関数が提案されている[5]。例えばk-平均法に基づくハッシュ関数などは大域的最適解を与えることが保証されていないものの実用的なハッシュ関数として知られている。

出典

[脚注の使い方]
  1. ^ Gionis, A.; Indyk, P., Motwani, R. (1999). , “Similarity Search in High Dimensions via Hashing”. Proceedings of the 25th Very Large Database (VLDB) Conference. http://people.csail.mit.edu/indyk/vldb99.ps ,. 
  2. ^ Indyk, Piotr.; Motwani, Rajeev. (1998). , “Approximate Nearest Neighbors: Towards Removing the Curse of Dimensionality.”. Proceedings of 30th Symposium on Theory of Computing. http://people.csail.mit.edu/indyk/nndraft.ps ,. 
  3. ^ Charikar, Moses S.. (2002). “Similarity Estimation Techniques from Rounding Algorithms”. Proceedings of the 34th Annual ACM Symposium on Theory of Computing 2002: (ACM 1–58113–495–9/02/0005)…. doi:10.1145/509907.509965. http://portal.acm.org/citation.cfm?id=509965 2007年12月21日閲覧。. 
  4. ^ Datar, M.; Immorlica, N., Indyk, P., Mirrokni, V.S. (2004). “Locality-Sensitive Hashing Scheme Based on p-Stable Distributions”. Proceedings of the Symposium on Computational Geometry. http://theory.csail.mit.edu/~mirrokni/pstable.ps. 
  5. ^ Pauleve, L.; Jegou, H., Amsaleg, L. (2010). “Locality sensitive hashing: A comparison of hash function types and querying mechanisms”. Pattern recognition Letters. http://hal.inria.fr/inria-00567191/en/. 

関連項目

  • 表示
  • 編集