Skip to content

Latest commit

 

History

History
383 lines (268 loc) · 6.59 KB

Store.md

File metadata and controls

383 lines (268 loc) · 6.59 KB

TFSimilarity.indexer.Store

Helper class that provides a standard way to create an ABC using

Inherits From: ABC

inheritance.

Methods

add

View source

add(
    embedding: <a href="../../TFSimilarity/callbacks/FloatTensor.md">TFSimilarity.callbacks.FloatTensor```
</a>,
    label: Optional[int] = None,
    data: Optional[<a href="../../TFSimilarity/callbacks/Tensor.md">TFSimilarity.callbacks.Tensor```
</a>] = None
) -> int

Add an Embedding record to the key value store.

Args
embedding Embedding predicted by the model.
label Class numerical id. Defaults to None.
data Data associated with the embedding. Defaults to None.
Returns
Associated record id.

batch_add

View source

batch_add(
    embeddings: Sequence[<a href="../../TFSimilarity/callbacks/FloatTensor.md">TFSimilarity.callbacks.FloatTensor```
</a>],
    labels: Optional[Sequence[int]] = None,
    data: Optional[Sequence[Tensor]] = None
) -> List[int]

Add a set of embedding records to the key value store.

Args
embeddings Embeddings predicted by the model.
labels Class numerical ids. Defaults to None.
data Data associated with the embeddings. Defaults to None.

See:

add() for what a record contains.

Returns
List of associated record id.

batch_get

View source

batch_get(
    idxs: Sequence[int]
) -> Tuple[List[FloatTensor], List[Optional[int]], List[Optional[Tensor]]]

Get embedding records from the key value store.

Args
idxs ids of the records to fetch.
Returns
List of records associated with the requested ids.

get

View source

get(
    idx: int
) -> Tuple[FloatTensor, Optional[int], Optional[Tensor]]

Get an embedding record from the key value store.

Args
idx Id of the record to fetch.
Returns
record associated with the requested id.

load

View source

load(
    path: str
) -> int

Load index on disk

Args
path where to store the data
Returns
Number of records reloaded.

save

View source

save(
    path: str, compression: bool = True
) -> None

Serializes index on disk.

Args
path Directory where to store the data.
compression Compress index data. Defaults to True.

size

View source

size() -> int

Number of record in the key value store.

to_data_frame

View source

to_data_frame(
    num_records: int = 0
) -> <a href="../../TFSimilarity/indexer/PandasDataFrame.md">TFSimilarity.indexer.PandasDataFrame```
</a>

Export data as a Pandas dataframe.

Args
num_records Number of records to export to the dataframe. Defaults to 0 (unlimited).
Returns
pd.DataFrame a pandas dataframe.