March 24, 2021

Visualizing a network of bigrams

Network graphs can be used to visualize bigrams in text data.

Network graphs are constructed using

  • from: the node an edge is coming from
  • to: the note an edge is going towards
  • weight: A numeric value associated with each edge

The igraph R package

The igraph R package has a function that can convert a tidy data frame into a set of "from", "to" nodes with edges.

 > graph_from_data_frame()
 

Note that this function does not make a plot! This function makes the graph that can be plotted.

The authors discuss polishing the plot with arrows and words.

Markov chain

There is a reference in the book that a plot of a network graph is a visualization of a Markov chain. This model assumes there is only a one step dependence. This is what bigrams look at.

Advanced Book

Speech and Language Processing

This is a bit more advanced book.

In Chapter 3 there is a very nice presentation of n-grams

In Chapter 4 there is a very nice presentation of naive Bayes.