distend: Compress or expand a vector space model along a vector.

View source: R/matrixFunctions.R

distendR Documentation

Compress or expand a vector space model along a vector.

Description

This is an experimental function that might be useful sometimes. 'Reject' flatly eliminates a particular dimension from a vectorspace, essentially squashing out a single dimension; 'distend' gives finer grained control, making it possible to stretch out or compress in the same space. High values of 'multiplier' make a given vector more prominent; 1 keeps the original matrix untransformed; values less than one compress distances along the vector; and 0 is the same as "reject," eliminating a vector entirely. Values less than zero will do some type of mirror-image universe thing, but probably aren't useful?

Usage

distend(matrix, vector, multiplier)

Arguments

matrix

A matrix or VectorSpaceModel

vector

A vector (or an object coercable to a vector, see project) of the same length as the VectorSpaceModel.

multiplier

A scaling factor. See below.

Value

A new matrix or VectorSpaceModel of the same dimensions as 'matrix', distended along the vector 'vector' by factor 'multiplier'.

See 'project' for more details and usage.

Examples

closest_to(demo_vectors,"sweet")

# Stretch out the vectorspace 4x longer along the gender direction.
more_sexist = distend(demo_vectors, ~ "man" + "he" - "she" -"woman", 4)

closest_to(more_sexist,"sweet")


bmschmidt/wordVectors documentation built on June 2, 2022, 3:53 p.m.