1 an approximation- based data structure for similarity search r. weber, s. blott hermes, 1998...

33
1 An Approximation- An Approximation- Based Based Data Structure Data Structure for Similarity for Similarity Search Search R. Weber, S. Blott R. Weber, S. Blott Hermes, 1998 Hermes, 1998 Sistemi Informativi per le Decisioni Sistemi Informativi per le Decisioni Diego Cera – Michele Degli Esposti – Diego Cera – Michele Degli Esposti – Letizia Falcone Letizia Falcone

Upload: dafne-mura

Post on 02-May-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

11

An Approximation-An Approximation-BasedBasedData StructureData Structurefor Similarity Searchfor Similarity Search

R. Weber, S. BlottR. Weber, S. Blott

Hermes, 1998Hermes, 1998

Sistemi Informativi per le DecisioniSistemi Informativi per le DecisioniDiego Cera – Michele Degli Esposti – Letizia Diego Cera – Michele Degli Esposti – Letizia

FalconeFalcone

Page 2: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 22

Dall’R-tree al VA-FileDall’R-tree al VA-FileI metodi di data-partitioning degradano all’aumentare delle dimensioni dello spazio vettoriale.

Soluzione: Vector-Approximation FILE

Cos’è?

Perché lo usiamo?

È un file che contiene un’approssimazione compatta e geometrica di ciascun vettore.Usualmente le approssimazioni occupano solo il 10-20% dello spazio occupato dai vettori stessi.

Il vantaggio principale riguarda le buone prestazioni all’aumentare della dimensionalità.Si può dimostrare che gli algoritmi basati sul VA-file sono più performanti, rispetto ai metodi di data-partitioning, di almeno un ordine di grandezza.

Page 3: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 33

Costruzione VA-File Costruzione VA-File (1)(1)

11 0.9 0.10.9 0.1 11 0011 00

22 0.7 0.10.7 0.1 10 0010 00

33 0.2 0.10.2 0.1 00 0000 00

44 0.7 0.30.7 0.3 10 1010 10

55 0.3 0.20.3 0.2 01 0101 01

66 0.1 0.40.1 0.4 00 0100 01

77 0.6 0.60.6 0.6 10 1010 10

88 0.4 0.50.4 0.5 01 1001 10

99 0.9 0.80.9 0.8 11 1111 11

1010 0.4 0.90.4 0.9 01 1101 11

1111 0.2 070.2 07 00 1100 11

00 01 10 11

00

01

10

11

123

45

6

7

8

91011

Page 4: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 44

00 01 10 11

00

01

10

11

liqj

mj[ri,y]

mj[ri,y+1]

ui

ri,y

Costruzione VA-File (2)

ui = upper bound del vettore ili = lower bound del vettore i

mj[ri,x] mj[ri,x+1]ri,x

Page 5: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 55

00 01 10 11

00

01

10

11

li = 0

mj[ri,y]

uiqj = ri,y

Costruzione VA-File (3)

qj = ri,xmj[ri,x]

Page 6: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 66

VA- Simple Search VA- Simple Search AlgorithmAlgorithm

DefinizioneVariabili Generali

ChiamataFunzione

InitCandidate

Ciclo FOR

ans: vettore dei k risultatidst: vettore delle distanze dei k risultatia: vettore di Approssimazione dei puntop: vettore reale del puntoq: vettore queryN: numero dei punti ili: lower bound di i: raggio di ricerca

:= InitCandidate();

FUNC InitCandidate(): REAL;VAR j: INT; FOR j:= 1 TO k DO dst[j]:= MAXREAL RETURN MAXREAL;END-FUNC InitCandidate;

FOR i:= 1 TO N DO li:= GetBounds(ai,q); IF li< THEN := Candidate(Lp(pi,q), i); END-FOR;

FUNC Candidate(:REAL;i:INT): REAL; IF <dst[k] THEN dst[k]:= ; ans[k]:= i; SortOnDst(ans, dst, k); RETURN dst[k]; END-FUNC Candidate;

Page 7: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 77

Algoritmo VA-SSAAlgoritmo VA-SSADefinizione

Variabili Generali

ChiamataFunzione

InitCandidate

Ciclo FOR

ans: vettore dei k risultatidst: vettore delle distanze dei k risultatia: vettore di Approssimazione dei puntop: vettore reale del puntoq: vettore queryN: numero dei punti ili: lower bound di i: raggio di ricerca

:= InitCandidate();

FUNC InitCandidate(): REAL;VAR j: INT; FOR j:= 1 TO k DO dst[j]:= MAXREAL RETURN MAXREAL;END-FUNC InitCandidate;

Inizializza le distanze dei k vettori risultato

alla massima distanza possibile

FOR i:= 1 TO N DO li:= GetBounds(ai,q); IF li< THEN := Candidate(Lp(pi,q), i); END-FOR;

FUNC Candidate(:REAL;i:INT): REAL; IF <dst[k] THEN dst[k]:= ; ans[k]:= i; SortOnDst(ans, dst, k); RETURN dst[k]; END-FUNC Candidate;

Page 8: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 88

Algoritmo VA-SSAAlgoritmo VA-SSADefinizione

Variabili Generali

ChiamataFunzione

InitCandidate

Ciclo FOR

ans: vettore dei k risultatidst: vettore delle distanze dei k risultatia: vettore di Approssimazione dei puntop: vettore reale del puntoq: vettore queryN: numero dei punti ili: lower bound di i: raggio di ricerca

:= InitCandidate();

FUNC InitCandidate(): REAL;VAR j: INT; FOR j:= 1 TO k DO dst[j]:= MAXREAL RETURN MAXREAL;END-FUNC InitCandidate;

Inizializza le distanze dei k vettori risultato

alla massima distanza possibile

FOR i:= 1 TO N DO li:= GetBounds(ai,q); IF li< THEN := Candidate(Lp(pi,q), i); END-FOR;

Restituisce il lower bound relativo ad

ogni punto

FUNC Candidate(:REAL;i:INT): REAL; IF <dst[k] THEN dst[k]:= ; ans[k]:= i; SortOnDst(ans, dst, k); RETURN dst[k]; END-FUNC Candidate;

Page 9: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 99

Algoritmo VA-SSAAlgoritmo VA-SSADefinizione

Variabili Generali

ChiamataFunzione

InitCandidate

Ciclo FOR

ans: vettore dei k risultatidst: vettore delle distanze dei k risultatia: vettore di Approssimazione dei puntop: vettore reale del puntoq: vettore queryN: numero dei punti ili: lower bound di i: raggio di ricerca

:= InitCandidate();

FUNC InitCandidate(): REAL;VAR j: INT; FOR j:= 1 TO k DO dst[j]:= MAXREAL RETURN MAXREAL;END-FUNC InitCandidate;

Inizializza le distanze dei k vettori risultato

alla massima distanza possibile

FOR i:= 1 TO N DO li:= GetBounds(ai,q); IF li< THEN := Candidate(Lp(pi,q), i); END-FOR;

Restituisce il lower bound relativo ad

ogni punto

FUNC Candidate(:REAL;i:INT): REAL; IF <dst[k] THEN dst[k]:= ; ans[k]:= i; SortOnDst(ans, dst, k); RETURN dst[k]; END-FUNC Candidate;

Inserimento del punto i al posto del

k-esimo se dst[i] < dst[k]

Page 10: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1010

Algoritmo VA-SSAAlgoritmo VA-SSADefinizione

Variabili Generali

ChiamataFunzione

InitCandidate

Ciclo FOR

ans: vettore dei k risultatidst: vettore delle distanze dei k risultatia: vettore di Approssimazione dei puntop: vettore reale del puntoq: vettore queryN: numero dei punti ili: lower bound di i: raggio di ricerca

:= InitCandidate();

FUNC InitCandidate(): REAL;VAR j: INT; FOR j:= 1 TO k DO dst[j]:= MAXREAL RETURN MAXREAL;END-FUNC InitCandidate;

Inizializza le distanze dei k vettori risultato

alla massima distanza possibile

FOR i:= 1 TO N DO li:= GetBounds(ai,q); IF li< THEN := Candidate(Lp(pi,q), i); END-FOR;

Restituisce il lower bound relativo ad

ogni punto

FUNC Candidate(:REAL;i:INT): REAL; IF <dst[k] THEN dst[k]:= ; ans[k]:= i; SortOnDst(ans, dst, k); RETURN dst[k]; END-FUNC Candidate;

Ordina i k “punti risultato”

per distanza crescente

Inserimento del punto i al posto del

k-esimo se dst[i] < dst[k]

Page 11: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1111

VA-SSAVA-SSA

00 01 10 11

00

01

10

11

q

MAXREAL

1

l1 <Lp1

< Dst[3]

a1

2

a2

l2

Lp2 <Dst[3]

3l3 <

Lp3< Dst[3]

<

a3

Dst[1Dst[1]]

=MR=MR

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=MR=MR

Hp:k=3Dst[1Dst[1]]

=MR=MR

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=L=Lp1p1

Dst[1Dst[1]]

=L=Lp1p1

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

= = MRMR

Dst[1Dst[1]]

=L=Lp1p1

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

= L= Lp2p2

Dst[1Dst[1]]

= L= Lp2p2

Dst[2Dst[2]]

= L= Lp1p1

Dst[3Dst[3]]

= = MRMR

Dst[1Dst[1]]

= L= Lp2p2

Dst[2Dst[2]]

= L= Lp1p1

Dst[3Dst[3]]

= L= Lp3p3

Dst[1Dst[1]]

= L= Lp3p3

Dst[2Dst[2]]

=L=Lp2p2

Dst[3Dst[3]]

=L=Lp1p1

Lp1

Page 12: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1212

VA-SSAVA-SSA

00 01 10 11

00

01

10

11

q

1a1

Lp1

2

a2

3 a3

Hp:k=3Dst[1Dst[1]]

= L= Lp3p3

Dst[2Dst[2]]

=L=Lp2p2

Dst[3Dst[3]]

=L=Lp1p1

4

l4

Lp4< Dst[3]

Dst[1Dst[1]]

= L= Lp3p3

Dst[2Dst[2]]

=L=Lp2p2

Dst[3Dst[3]]

=L=Lp4p4

Dst[1Dst[1]]

= L= Lp3p3

Dst[2]Dst[2]

=L=Lp4p4

Dst[3Dst[3]]

= L= Lp2p2

Lp2

a4

Page 13: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1313

VA-SSAVA-SSA

00 01 10 11

00

01

10

11

q

1a1

2

a2

3 a3

Hp:k=3

4

Dst[1Dst[1]]

= L= Lp3p3

Dst[2Dst[2]]

=L=Lp4p4

Dst[3Dst[3]]

= L= Lp2p2

Lp2

a4

5

a5

l5

6a6

l6<

>

Lp6 < Dst[3]

Dst[1Dst[1]]

= L= Lp3p3

Dst[2Dst[2]]

=L=Lp4p4

Dst[3Dst[3]]

= L= Lp6p6

Dst[1Dst[1]]

= L= Lp3p3

Dst[2Dst[2]]

= L= Lp6p6

Dst[3Dst[3]]

=L=Lp4p4

Lp4

Punti più vicini: 3, 6, 4

Page 14: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1414

VA - Near Optimal VA - Near Optimal AlgorithmAlgorithm

DefinizioniVariabili Generali

N: numero dei punti iraggio di ricercali: lower bound dell’i-esimo puntoui: upper bound dell’i-esimo punto

Heap: Pila “a priorità” ad li crescenti

ChiamataInitCandidate

Ciclo FOR

ChiamataInitCandidate e

definizione PopHeap

Ciclo WHILE

:= InitCandidate();

FOR i:= 1 TO N DO li, ui:= GetBounds(ai,q); IF li <= THEN := Candidate(ui, i); InsertHeap (Heap, li, i); END-FOR;:= InitCandidate();li, i:= PopHeap (Heap, li, i);

FASE1

FASE2

WHILE li < DO := Candidate(Lp(pi,q), i); li, i:= PopHeap (Heap, li, i);END-WHILE;

Page 15: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1515

Algoritmo VA-NOAAlgoritmo VA-NOADefinizioni

Variabili Generali

N: numero dei punti iraggio di ricercali: lower bound dell’i-esimo puntoui: upper bound dell’i-esimo punto

Heap: Coda “a priorità” ad li crescenti

ChiamataInitCandidate

Ciclo FOR

ChiamataInitCandidate e

definizione PopHeap

Ciclo WHILE

:= InitCandidate();

FOR i:= 1 TO N DO li, ui:= GetBounds(ai,q); IF li <= THEN := Candidate(ui, i); InsertHeap (Heap, li, i); END-FOR;

Calcola e restituisce le distanze dalla query rispetto agli UPPER

BOUND, non ai punti

:= InitCandidate();li, i:= PopHeap (Heap, li, i);

FASE1

FASE2

WHILE li < DO := Candidate(Lp(pi,q), i); li, i:= PopHeap (Heap, li, i);END-WHILE;

Page 16: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1616

Algoritmo VA-NOAAlgoritmo VA-NOADefinizioni

Variabili Generali

N: numero dei punti iraggio di ricercali: lower bound dell’i-esimo puntoui: upper bound dell’i-esimo punto

Heap: Coda “a priorità” ad li crescenti

ChiamataInitCandidate

Ciclo FOR

ChiamataInitCandidate e

definizione PopHeap

Ciclo WHILE

:= InitCandidate();

FOR i:= 1 TO N DO li, ui:= GetBounds(ai,q); IF li <= THEN := Candidate(ui, i); InsertHeap (Heap, li, i); END-FOR;

Calcola e restituisce le distanze dalla query rispetto agli UPPER

BOUND, non ai punti

Inserisce nella coda Heap ordinando in

funzione del LOWER BOUND

:= InitCandidate();li, i:= PopHeap (Heap, li, i);

FASE1

FASE2

WHILE li < DO := Candidate(Lp(pi,q), i); li, i:= PopHeap (Heap, li, i);END-WHILE;

Page 17: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1717

Algoritmo VA-NOAAlgoritmo VA-NOADefinizioni

Variabili Generali

N: numero dei punti iraggio di ricercali: lower bound dell’i-esimo puntoui: upper bound dell’i-esimo punto

Heap: Coda “a priorità” ad li crescenti

ChiamataInitCandidate

Ciclo FOR

ChiamataInitCandidate e

definizione PopHeap

Ciclo WHILE

:= InitCandidate();

FOR i:= 1 TO N DO li, ui:= GetBounds(ai,q); IF li <= THEN := Candidate(ui, i); InsertHeap (Heap, li, i); END-FOR;

Calcola e restituisce le distanze dalla query rispetto agli UPPER

BOUND, non ai punti

Inserisce nella coda Heap ordinando in

funzione del LOWER BOUND

:= InitCandidate();li, i:= PopHeap (Heap, li, i);

FASE1

FASE2

WHILE li < DO := Candidate(Lp(pi,q), i); li, i:= PopHeap (Heap, li, i);END-WHILE;

Calcola e restituisce le

distanze tra la query e i punti

Page 18: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1818

Algoritmo VA-NOAAlgoritmo VA-NOADefinizioni

Variabili Generali

N: numero dei punti iraggio di ricercali: lower bound dell’i-esimo puntoui: upper bound dell’i-esimo punto

Heap: Coda “a priorità” ad li crescenti

ChiamataInitCandidate

Ciclo FOR

ChiamataInitCandidate e

definizione PopHeap

Ciclo WHILE

:= InitCandidate();

FOR i:= 1 TO N DO li, ui:= GetBounds(ai,q); IF li <= THEN := Candidate(ui, i); InsertHeap (Heap, li, i); END-FOR;

Calcola e restituisce le distanze dalla query rispetto agli UPPER

BOUND, non ai punti

Inserisce nella coda Heap ordinando in

funzione del LOWER BOUND

:= InitCandidate();li, i:= PopHeap (Heap, li, i);

FASE1

FASE2

WHILE li < DO := Candidate(Lp(pi,q), i); li, i:= PopHeap (Heap, li, i);END-WHILE;

Calcola e restituisce le

distanze tra la query e i punti

Estrae dalla coda Heap in funzione

del LOWER BOUND più vicino

alla query

Page 19: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 1919

VA-NOA (Fase 1)VA-NOA (Fase 1)

00 01 10 11

00

01

10

11

q

MAXREAL

1

l1 <u1

< Dst[3]

a1

2

a2

l2

u2 <Dst[3]

3l3 <

u3< Dst[3]<

a3

Dst[1Dst[1]]

=MR=MR

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=MR=MR

Hp:k=3Dst[1Dst[1]]

=MR=MR

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=u=u11

Dst[1Dst[1]]

=u=u11

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

= = MRMR

Dst[1Dst[1]]

=u=u11

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

= u= u22

Dst[1Dst[1]]

= u= u22

Dst[2Dst[2]]

= u= u11

Dst[3Dst[3]]

= = MRMR

Dst[1Dst[1]]

= u= u22

Dst[2Dst[2]]

= u= u11

Dst[3Dst[3]]

= u= u33

Dst[1Dst[1]]

= u= u22

Dst[2Dst[2]]

=u=u33

Dst[3Dst[3]]

=u=u11

u1

Heap ll11ll22 ll11ll33 ll22 ll11

Page 20: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2020

VA-NOA (Fase 1)VA-NOA (Fase 1)

00 01 10 11

00

01

10

11

q

1a1

u1

2

a2

3 a3

Hp:k=3Dst[1Dst[1]]

= u= u22

Dst[2Dst[2]]

=u=u33

Dst[3Dst[3]]

=u=u11

4

l4 = 0

u4 < Dst[3]

Dst[1Dst[1]]

= u= u22

Dst[2Dst[2]]

=u=u33

Dst[3Dst[3]]

=u=u44

Dst[1Dst[1]]

= u= u44

Dst[2]Dst[2]

=u=u22

Dst[3Dst[3]]

= u= u33

u3

a4

Heap ll33 ll22 ll11ll44 ll33 ll22 ll11

Page 21: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2121

VA-NOA (Fase 1)VA-NOA (Fase 1)

00 01 10 11

00

01

10

11

q

1a1

2

a2

3 a3

Hp:k=3

4

Dst[1Dst[1]]

= u= u44

Dst[2Dst[2]]

=u=u22

Dst[3Dst[3]]

= u= u33

u3

a4

5

a5

l5

6a6

l6<

<

u6 < Dst[3]

Dst[1Dst[1]]

= u= u44

Dst[2Dst[2]]

= u= u22

Dst[3Dst[3]]

= u= u66

Dst[1Dst[1]]

= u= u44

Dst[2Dst[2]]

= u= u66

Dst[3Dst[3]]

= u= u22 u2

u5 > Dst[3]

Heap ll44 ll33 ll22 ll11ll44 ll33 ll22 ll11 ll55ll44 ll33 ll66 ll22 ll11 ll55

Page 22: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2222

VA-NOA (Fase 2)VA-NOA (Fase 2)

00 01 10 11

00

01

10

11

q

MAXREAL

1

2

3

l4

Dst[1Dst[1]]

=MR=MR

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=MR=MR

Hp:k=3

Heap ll44 ll33 ll66 ll22 ll11 ll55

4

5

6

Dst[1Dst[1]]

=MR=MR

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=L=Lp4p4

Dst[1Dst[1]]

=L=Lp4p4

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

= = MRMR

ll44 ll33 ll66 ll22 ll11 ll55

Page 23: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2323

VA-NOA (Fase 2)VA-NOA (Fase 2)

00 01 10 11

00

01

10

11

q

MAXREAL

1

2

3l3 <

Dst[1Dst[1]]

=L=Lp4p4

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=MR=MR

Hp:k=3

Heap ll33 ll66 ll22 ll11 ll55

4

5

6

Dst[1Dst[1]]

=L=Lp4p4

Dst[2Dst[2]]

=MR=MR

Dst[3Dst[3]]

=L=Lp3p3

Dst[1Dst[1]]

=L=Lp3p3

Dst[2Dst[2]]

=L=Lp4p4

Dst[3Dst[3]]

= = MRMR

ll33 ll66 ll22 ll11 ll55

Page 24: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2424

VA-NOA (Fase 2)VA-NOA (Fase 2)

00 01 10 11

00

01

10

11

q

MAXREAL

1

2

3

l6<

Dst[1Dst[1]]

=L=Lp3p3

Dst[2Dst[2]]

=L=Lp4p4

Dst[3Dst[3]]

=MR=MR

Hp:k=3

Heap ll66 ll22 ll11 ll55

4

5

6

Dst[1Dst[1]]

=L=Lp3p3

Dst[2Dst[2]]

=L=Lp4p4

Dst[3Dst[3]]

=L=Lp6p6

Dst[1Dst[1]]

=L=Lp3p3

Dst[2Dst[2]]

=L=Lp6p6

Dst[3Dst[3]]

= L= Lp4p4

ll66 ll22 ll11 ll55

Lp4

Page 25: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2525

VA-NOA (Fase 2)VA-NOA (Fase 2)

00 01 10 11

00

01

10

11

q

1

2

3

l2 <

Hp:k=3

Heap ll22 ll11 ll55

4

5

6

ll22 ll11 ll55

Lp4

Lp2 >Dst[3]

Dst[1Dst[1]]

=L=Lp3p3

Dst[2Dst[2]]

=L=Lp6p6

Dst[3Dst[3]]

= L= Lp4p4

Page 26: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2626

VA-NOA (Fase 2)VA-NOA (Fase 2)

00 01 10 11

00

01

10

11

q

1

2

3

l1>

Hp:k=3

Heap ll11 ll55

4

5

6

ll11 ll55

Lp4

Dst[1Dst[1]]

=L=Lp3p3

Dst[2Dst[2]]

=L=Lp6p6

Dst[3Dst[3]]

= L= Lp4p4

Punti più vicini: 3, 6, 4

Page 27: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2727

Confronto VA-File ed R-TreeConfronto VA-File ed R-Tree

+ Algoritmi basati su VA-File non richiedono la Algoritmi basati su VA-File non richiedono la costruzione di alcun alberocostruzione di alcun albero

- Algoritmi VA-File visitano sicuramente tutti i punti Algoritmi VA-File visitano sicuramente tutti i punti . . .. . .

+ . . . Però ogni lettura è computazionalmente . . . Però ogni lettura è computazionalmente meno costosameno costosa

+ Algoritmi per i VA-File calcolano le distanze solo Algoritmi per i VA-File calcolano le distanze solo per i candidatiper i candidati

= Algoritmi sui VA-File migliorano Algoritmi sui VA-File migliorano all’aumentare delle dimensioni mentre gli all’aumentare delle dimensioni mentre gli R-Tree peggioranoR-Tree peggiorano

Page 28: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2828

Confronto VA-File ed R-Tree Confronto VA-File ed R-Tree (1)(1)

(a): Tempo di CPU relativo al database immagine

(b): Tempo di esecuzione (wall-clock time) relativo al database immagine

Page 29: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 2929

Confronto VA-File ed R-Tree Confronto VA-File ed R-Tree (4)(4)

(a): Selettività dei blocchi in funzione del numero delle dimensioni.

(b): Numero totale dei blocchi visitati in funzione del numero di dimensioni.

Data Set REALE

Page 30: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 3030

Confronto tra VA-SSA e VA-Confronto tra VA-SSA e VA-NOANOA

VA-NOA visita due volte i punti nella pila . . VA-NOA visita due volte i punti nella pila . . ..

. . . ma nella prima fase calcola solo gli . . . ma nella prima fase calcola solo gli upper boundupper bound

Difatti VA-NOA calcola LDifatti VA-NOA calcola Lpp, la distanza , la distanza pesata, su un numero ridotto di candidatipesata, su un numero ridotto di candidati

In pratica: In pratica: – VA-SSA è di complessità O(N)VA-SSA è di complessità O(N)

– VA-NOA è di complessità O(NVA-NOA è di complessità O(N22loglog22NN11))

Page 31: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 3131

Confronto tra VA-SSA e VA-Confronto tra VA-SSA e VA-NOANOA

(a): Selettività vettoriale per il VA-File in funzione della grandezza del database.

(b): Selettività dei blocchi in funzione della dimensionalità.

Page 32: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

15/03/200615/03/2006An Approximation-Based Data Structure for Similarity An Approximation-Based Data Structure for Similarity

SearchSearch 3232

BibliografiaBibliografia

““An Approximation-Based Data Structure An Approximation-Based Data Structure for Similarity Search”for Similarity Search” – R. Weber, S. Blott – R. Weber, S. Blott

Hermes TR, 1998Hermes TR, 1998 ““Algorithms” Algorithms” – R. Sedgewick– R. Sedgewick

Addison-Wesley Publishing Company, 1983Addison-Wesley Publishing Company, 1983

Page 33: 1 An Approximation- Based Data Structure for Similarity Search R. Weber, S. Blott Hermes, 1998 Sistemi Informativi per le Decisioni Diego Cera – Michele

3333

Grazie per Grazie per l’attenzione!!l’attenzione!!

Diego CeraDiego Cera

Michele Degli EspostiMichele Degli Esposti

Letizia FalconeLetizia Falcone