A simple SVD + LSI implementation in Ruby, based on gradient descent. Useful if you have a *small* matrix with missing values.
Pull request Compare This branch is even with echen:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Latent Semantic Indexing Example

To use the latent semantic indexing feature, create an array of documents, and pass it to the Svd.lsi method. To print out the document and word features, call the print method. Here is an example (taken from the Deerwater et al. paper):

require_relative './svd'

documents = [
  "human interface computer",
  "survey user computer system response time",
  "EPS user interface system",
  "system human EPS",
  "user time response",
  "trees graph",
  "trees graph minors",
  "survey graph minors"]

s = Svd.lsi(documents)
s.print("rows.txt", "cols.txt", "log.txt")

We can then read the features into R:

d = read.table("rows.txt")
colnames(d) = c("name", "x", "y")
qplot(x, y, data = d, label = name, size = 3, geom = "text")

Row Vectors