plot_neighbors {LSAfun}R Documentation

2D- or 3D-Plot of neighbors

Description

2D- or 3D-Approximation of the neighborhood of a given word/sentence

Usage

plot_neighbors(x,n,connect.lines="all",start.lines=T,
   method="PCA",dims=3,axes=F,box=F,cex=1,legend=T, size = c(800,800),
   alpha="graded",alpha.grade = 1, col="rainbow",tvectors=tvectors,...)

Arguments

x

a character vector of length(x) = 1 or a numeric of length=ncol(tvectors) vector with same dimensionality as LSA space

n

the number of neighbors to be computed

dims

the dimensionality of the plot; set either dims = 2 or dims = 3

method

the method to be applied; either a Principal Component Analysis (method="PCA") or a Multidimensional Scaling (method="MDS")

connect.lines

(3d plot only) the number of closest associate words each word is connected with via line. Setting connect.lines="all" (default) will draw all connecting lines and will automatically apply alpha="graded"; it will furthermore override the start.lines argument

start.lines

(3d plot only) whether lines shall be drawn between x and all the neighbors

axes

(3d plot only) whether axes shall be included in the plot

box

(3d plot only) whether a box shall be drawn around the plot

cex

(2d Plot only) A numerical value giving the amount by which plotting text should be magnified relative to the default.

legend

(3d plot only) whether a legend shall be drawn illustrating the color scheme of the connect.lines. The legend is inserted as a background bitmap to the plot using bgplot3d. Therefore, they do not resize very gracefully (see the bgplot3d documentation for more information).

size

(3d plot only) A numeric vector with two elements, the first specifying the width and the second specifying the height of the plot device.

tvectors

the semantic space in which the computation is to be done (a numeric matrix where every row is a word vector)

alpha

(3d plot only) a vector of one or two numerics between 0 and 1 specifying the luminance of start.lines (first entry) and connect.lines (second entry). Specifying only one numeric will pass this value to both kinds of lines. With setting alpha="graded", the luminance of every line will be adjusted to the cosine between the two words it connects.

alpha.grade

(3d plot only) Only relevant if alpha="graded". Specify a numeric value for alpha.grade to scale the luminance of all start.lines and connect.lines up (alpha.grade > 1) or down (alpha.grade < 1) by that factor.

col

(3d plot only) a vector of one or two characters specifying the color of start.lines (first entry) and connect.lines (second entry). Specifying only one colour will pass this colour to both kinds of lines. With setting col ="rainbow" (default), the colour of every line will be adjusted to the cosine between the two words it connects, according to the rainbow palette. Other available color palettes for this purpose are heat.colors, terrain.colors, topo.colors, and cm.colors (see rainbow). Additionally, you can customize any color scale of your choice by providing an input specifying more than two colors

(for example col = c("black","blue","red")).

...

additional arguments which will be passed to plot3d (in a three-dimensional plot only)

Details

Attempts to create an image of the semantic neighborhood (based on cosine similarity) to a given word, sentence/ document, or vector. An attempt is made to depict this subpart of the LSA space in a two- or three-dimensional plot.

To achieve this, either a Principal Component Analysis (PCA) or a Multidimensional Scaling (MDS) is computed to preserve the interconnections between all the words in this neighborhod as good as possible. Therefore, it is important to note that the image created from this function is only the best two- or three-dimensional approximation to the true LSA space subpart.

For creating pretty plots showing the similarity structure within this neighborhood best, set connect.lines="all" and col="rainbow"

Value

For three-dimensional plots:see plot3d: this function is called for the side effect of drawing the plot; a vector of object IDs is returned

plot_neighbors also gives the coordinate vectors of the words in the plot as a data frame

Author(s)

Fritz Guenther, Taylor Fedechko

References

Landauer, T.K., & Dumais, S.T. (1997). A solution to Plato's problem: The Latent Semantic Analysis theory of acquisition, induction and representation of knowledge. Psychological Review, 104, 211-240.

Mardia, K.V., Kent, J.T., & Bibby, J.M. (1979). Multivariate Analysis, London: Academic Press.

See Also

cosine, neighbors, multicos, plot_wordlist, plot3d, princomp

Examples

data(wonderland)

## Standard Plot
plot_neighbors("cheshire",n=20,tvectors=wonderland)  

## Pretty Plot
plot_neighbors("cheshire",n=20,tvectors=wonderland,
                connect.lines="all",col="rainbow")  



plot_neighbors(compose("mad","hatter",tvectors=wonderland),
                n=20, connect.lines=2,tvectors=wonderland)

[Package LSAfun version 0.7.1 Index]