public
Description: A document vector search with flexible matrix transforms. Currently supports Latent semantic analysis and Term frequency - inverse document frequency
Home | Edit | New

Adding Matrix Transforms

I’m still working on making it easier to add matrix transforms. At the moment they are too embedded in the code. Until then if your are keen to add new transforms you can do the following:

All matrix transforms live in:

rsemantic/lib/semantic/transform/*

Add a new class for your transform here. It requires a single class method which is passed a matrix and it should return a matrix.

The matrix is a Linalg::DMatrix object.

It offers some nice builtin matrix transforms.

So as an example adding a PLSA transform our class would look like this:


module Semantic
  module Transform
    class PLSA

      self.transform(matrix)
        matrix
      end      

    end
  end
end

And then to use the transform we pass the class name in as a symbol when creating the search object.


search = Semantic::Search.new(documents, :transforms => [:PLSA])
Last edited by josephwilk, Sat Sep 27 06:07:21 -0700 2008
Home | Edit | New
Versions: