dstk.hooks package#
Submodules#
dstk.hooks.hook_tools module#
Module providing the Hook class for wrapping callable methods with a strict single-argument interface.
The Hook class allows encapsulating any callable that accepts exactly one argument, enforcing this constraint at runtime. It supports invocation, argument validation, and renaming of the hook instance.
This module is useful for building extensible and modular modela where hooks act as customizable processing steps.
- class dstk.hooks.hook_tools.Hook(name: str, method: Callable[[P], R])[source]#
Bases:
Generic
[P
,R
]Represents a callable hook that wraps a single-argument function.
A Hook encapsulates a method that must accept exactly one argument, enabling modular processing steps or callbacks within workflows or pipelines.
- Parameters:
name (str) – A descriptive name for the hook.
method (Callable[[Any], Any]) – A callable that takes exactly one argument and performs some operation
Usage:
CustomHook = Hook("example_hook", some_function) result = CustomHook(data) # Calls some_function(data)
dstk.hooks.type_conversion module#
This module provides hooks and utilities for converting between different data types used in the processing model.
Currently, it includes a hook to convert trained word embedding models (Word2Vec or FastText) into pandas DataFrames, enabling easier manipulation and analysis of embeddings.
Additional conversion hooks can be added in the future to support other type transformations.
- dstk.hooks.type_conversion.model_to_dataframe(model: Word2Vec | _FastText) DataFrame [source]#
Converts a trained Word2Vec or FastText model into a DataFrame of word embeddings.
- Parameters:
model (NeuralModels) – A trained Word2Vec or FastText model.
- Returns:
A DataFrame containing the word embeddings and their associated labels.
- Return type:
DataFrame