Skip to main content

Hubness reduced nearest neighbor search for entity alignment with knowledge graph embeddings

Project description

kiez logo

kiez

Actions Status Test coverage License BSD3 - Clause Code style: black

A Python library for hubness reduced nearest neighbor search for the task of entity alignment with knowledge graph embeddings. The term kiez is a german word that refers to a city neighborhood.

Hubness Reduction

Hubness is a phenomenon that arises in high-dimensional data and describes the fact that a couple of entities are nearest neighbors (NN) of many other entities, while a lot of entities are NN to no one. For entity alignment with knowledge graph embeddings we rely on NN search. Hubness therefore is detrimental to our matching results. This library is intended to make hubness reduction techniques available to data integration projects that rely on knowledge graph embeddings in their alignment process. Furthermore kiez optionally incorporates several approximate nearest neighbor (ANN) libraries, to pair the speed advantage of approximate neighbor search with increased accuracy of hubness reduction.

Installation

To install the base package without ANN libraries

pip install kiez

Usage

Simple nearest neighbor search for source entities in target space:

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()

Using ANN libraries and hubness reduction methods:

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()

License

kiez is licensed under the terms of the BSD-3-Clause license. Several files were modified from scikit-hubness, distributed under the same license. The respective files contain the following tag instead of the full license text.

    SPDX-License-Identifier: BSD-3-Clause

This enables machine processing of license information based on the SPDX License Identifiers that are here available: https://spdx.org/licenses/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiez-0.2.1.tar.gz (25.1 kB view hashes)

Uploaded Source

Built Distribution

kiez-0.2.1-py3-none-any.whl (36.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page