[Graphs] [Clique tree inference] [What do you say?] [Building a lexicon from emails] [Calling Matlab from Java] [Useful utilities]
if you use my code or find problems with it,
i'd appreciate you sending me an email about it.
Graphs
Standard graph operations implemented in Matlab.
one of the inputs is a file with variable names. if you don't want to use
this for manual verification, just comment the code that requires "flag" and
"gnames" or "num2cname".
a greedy implementation of triagulation. also requires the following
files:
choose_node.m,
new_edges.m,
induced_cluster.m,
add_edges.m,
remap.m,
rmnode.m
calc_weight.m
get_realpos.m
Clique tree inference
Based on one of the clearest papers I've ever read! If you need to implement
any kind of inference, this is the paper to read up on:
Huang
and Darwiche (1994). Inference in Belief Networks: A Procedural Guide.
The following code implements the steps identified in their paper to build the
secondary structure.
Some more code to make things more operational.
checks equation (2) is true in the built structure, or after every update.
checks equation (3) is true in the built structure.
here's how to convert a dbn's dag into a canonical dbn's dag, while retaining
only variables that are canonical by definition. be aware that the dag has
"shifted" so the dag indices for the variables in the original dbn no longer
corresponding to those in the original dag.
give it a vector of the indices (in the new dag) and make sure those variables
form a clique.
if you built a join tree after making it canonical, you'll need to convert the
variables back to the original indices.
uses the following:
msgpass.m
please note: msgpass.m simply sends one message between X and Y through R,
using the following data structure specific files (not included here):
mp_addout.m (marginalizes out a set of variables),
mk_init_mp0.m,
mp_div.m,
mp_mult.m.
What do you say?
This one is kind of cute. I wanted to write a program that generates sentences
based on words that I use often. So this is kind of what it does, although
you've got to tell it specific the syntax of the sentence you'd want to
generate.
Take a look at the readme file for more details.
Code needed from the section building a lexicon from emails.
uses trained trigrams to generate sentences.
random, no stats considered.
utility for cleaning up and segmenting an arpa file.
Building a lexicon from emails
Some code for taking a text inbox and formatting it nicely. After that, split
the text into separate files according their lexical categories. (Built-in
lexicon is limited. Should expand this for real!)
Take a look at the readme file for more details.
Calling Matlab from Java
If you ever need to call Matlab from Java, here's the trick. Use the Java
class developed by Kamin at MatlabControl.html.
If you follow all his instructions, you should be able to get the two to work
together. I had more problems because Matlab doesn't understand focus and I
needed to be able to get my Java stand-alone working the same way it would
with Matlab hooked up to it. So I used Kamin's class to make a MatlabJava
server, and made my Java stand-alone a client. That way, I could bypass the
whole focus problem because my stand-alone program doesn't need to communicate
with Matlab at all. Here is the code.
whatever Matlab scripts you need to run, put them inside processInput(). the two scripts in the code are testEE.m and testDM.m with their expected syntax. don't worry about what these two scripts do, just get them to do some disp() statements at first to get the overall infrastructure going.
having said that, you'll also find that an additional file cp.txt is required when testDM is called. this is the file that stores the output of the work from testDM inside Matlab, so that Java can parse it and make use of the output. this means that inside testDM.m, in additional to the computation, you will need to make sure that it does something like: save 'cp.txt' -ascii RESULT.
Useful utilities
Some useful files...
text mode for grabbing files to your directory. i found this useful whenever
the gui programs didn't work or took too many human steps. if you have the
links, just stick them into a file and let this script run overnight.
changing the extensions of multiple files at once. this one does .ps to .txt.
you can modify it to suit your needs.
takes a list of appointments and beeps
when the time is up.
simple (not optimized!) value iteration code for MDPs.