whatlies.transformers.AddRandom
¶
This transformer adds random embeddings to the embeddingset.
Parameters
Name | Type | Description | Default |
---|---|---|---|
n |
the number of random vectors to add | 1 |
Usage:
from whatlies.language import SpacyLanguage
from whatlies.transformers import AddRandom
words = ["prince", "princess", "nurse", "doctor", "banker", "man", "woman",
"cousin", "neice", "king", "queen", "dude", "guy", "gal", "fire",
"dog", "cat", "mouse", "red", "blue", "green", "yellow", "water",
"person", "family", "brother", "sister"]
lang = SpacyLanguage("en_core_web_md")
emb = lang[words]
emb.transform(AddRandom(3)).plot_interactive_matrix('rand_0', 'rand_1', 'rand_2')
fit(self, embset)
¶
Show source code in transformers/_addrandom.py
38 39 40 |
|
Fit the transformer on the given EmbeddingSet
instance (if neccessary). This method should
set the is_fitted
flag to True
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
embset |
an EmbeddingSet instance used for fitting the transformer. |
required |
transform(self, embset)
¶
Show source code in transformers/_addrandom.py
42 43 44 45 46 47 48 49 50 51 52 |
|
Transform the given EmbeddingSet
instance.
Parameters
Name | Type | Description | Default |
---|---|---|---|
embset |
an EmbeddingSet instance to be transformed. |
required |