# Overview¶

The kiez library is intended to make hubness reduction methods easily usable for the purpose of entity alignment via (knowledge graph) embeddings.

The central class of kiez serves to bundle all necessary steps to obtain nearest neighbors from source to target entities, given their embeddings:

```
from kiez import Kiez
import numpy as np
# create example data
rng = np.random.RandomState(0)
source = rng.rand(100,50)
target = rng.rand(100,50)
# fit and get neighbors
k_inst = Kiez()
k_inst.fit(source, target)
nn_dist, nn_ind = k_inst.kneighbors()
```

The main feature of kiez lies in the ability to use hubness reduction methods and approximate nearest neighbor (ANN) algorithms. This enables you to profit from the speed advantage of ANN algorithms, while achieving highly accurate nearest neighbor results:

```
from kiez import Kiez
import numpy as np
# create example data
rng = np.random.RandomState(0)
source = rng.rand(100,50)
target = rng.rand(100,50)
# prepare algorithm and hubness reduction
from kiez.neighbors import HNSW
hnsw = HNSW(n_candidates=10)
from kiez.hubness_reduction import CSLS
hr = CSLS()
# fit and get neighbors
k_inst = Kiez(n_neighbors=5, algorithm=hnsw, hubness=hr)
k_inst.fit(source, target)
nn_dist, nn_ind = k_inst.kneighbors()
```

You can install kiez via pip:

```
pip install kiez
```

If you have a GPU you can make kiez faster by installing faiss (if you do not already have it in your environment):

```
conda env create -n kiez-faiss python=3.10
conda activate kiez-faiss
conda install -c pytorch -c nvidia faiss-gpu=1.7.4 mkl=2021 blas=1.0=mkl
pip install autofaiss
pip install kiez
```

For more information see their installation instructions.

You can also get other specific libraries with e.g.:

```
pip install kiez[nmslib]
```

More info about installation can be found in Installation