<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Please Scoop Me!</title>
	<atom:link href="http://pleasescoopme.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pleasescoopme.com</link>
	<description>Jonathan&#039;s Research Blog</description>
	<lastBuildDate>Mon, 08 Mar 2010 17:45:55 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='pleasescoopme.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/9b6c8d810609417e89ab6cb1082e3677?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Please Scoop Me!</title>
		<link>http://pleasescoopme.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pleasescoopme.com/osd.xml" title="Please Scoop Me!" />
	<atom:link rel='hub' href='http://pleasescoopme.com/?pushpress=hub'/>
		<item>
		<title>R LDA package updated to version 1.2 and an ideal-point model for political blogs</title>
		<link>http://pleasescoopme.com/2010/03/08/r-lda-package-updated-to-version-1-2-and-an-ideal-point-model-for-political-blogs/</link>
		<comments>http://pleasescoopme.com/2010/03/08/r-lda-package-updated-to-version-1-2-and-an-ideal-point-model-for-political-blogs/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 17:45:55 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=488</guid>
		<description><![CDATA[I&#8217;ve been on a bit of a R tear lately.  Today you should see a new version of the R lda package.  This version has lots of fixes including a working mmsb demo with the latest version of ggplot2, corrected RTM code, improved likelihood reporting, better documentation, and much more.  Grab it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=488&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been on a bit of a R tear lately.  Today you should see a new version of the R lda package.  This version has lots of fixes including a working mmsb demo with the latest version of ggplot2, corrected RTM code, improved likelihood reporting, better documentation, and much more.  Grab it from <a href="http://cran.r-project.org/web/packages/lda/">CRAN</a> today!  Special thanks to the following people for bug reports/feature requests (sorry if I forgot anyone):</p>
<ul>
<li>Edo Airoldi
<li>Jordan Boyd-Graber
<li>Khalid El-Arini
<li>Roger Levy
<li>Solomon Messing
<li>Joerg Reichardt
</ul>
<p>One of the new features is a method to make sLDA predictions on response variables conditioned on documents.  In the demo accompanying the package, I fit an sLDA model to a corpus of political blogs tagged as being either liberal or conservative.  With this fitted model, I can now use the new predict method to predict the political bent of each of the blogs within a continuous space.  The density plot of these predictions is given below, broken down by the the original conservative/liberal label (color of shading).</p>
<p><a href="http://slycoder.files.wordpress.com/2010/02/slda-predict.png"><img src="http://slycoder.files.wordpress.com/2010/02/slda-predict.png?w=500&#038;h=500" alt="" title="An ideal point model for political blogs" width="500" height="500" class="aligncenter size-full wp-image-489" /></a></p>
<p>I like how there&#8217;s some bimodality for each contingency &#8212; a moderate group and a more extreme group.  The model also predicts a heavy tail of super-conservative blogs.  There is a real notable bump down by -3.   I dunno if this represents reality; it&#8217;s probably worthwhile to do more extensive model checking.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/488/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=488&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2010/03/08/r-lda-package-updated-to-version-1-2-and-an-ideal-point-model-for-political-blogs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/02/slda-predict.png" medium="image">
			<media:title type="html">An ideal point model for political blogs</media:title>
		</media:content>
	</item>
		<item>
		<title>jjplot: Yet another plotting library for R</title>
		<link>http://pleasescoopme.com/2010/03/07/jjplot-yet-another-plotting-library-for-r/</link>
		<comments>http://pleasescoopme.com/2010/03/07/jjplot-yet-another-plotting-library-for-r/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 09:30:25 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=496</guid>
		<description><![CDATA[Those of you who follow this blog know that making (somewhat) pretty plots is an abiding interest of mine.  Many of the plots I&#8217;ve made in the past were done using the great ggplot2 package.  But recently Eytan Bakshy and I have been tinkering with our own plotting library, jjplot, as a playground [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=496&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Those of you who follow this blog know that making (somewhat) pretty plots is an abiding interest of mine.  Many of the plots I&#8217;ve made in the past were done using the great ggplot2 package.  But recently <a href="http://www-personal.umich.edu/~ebakshy/ebakshy/Home.html">Eytan Bakshy</a> and I have been tinkering with our own plotting library, jjplot, as a playground for various ideas we&#8217;ve had.   As the name indicates, it is heavily inspired by hadley&#8217;s library.  Our library doesn&#8217;t do quite as much as ggplot2, and ours is liable to be much buggier.  But it&#8217;s still fun to play with.  Here are some examples of what jjplot can do:</p>
<ul>
<li> Bar plots with fills controlled by the values.<br />
<code><br />
df &lt;- data.frame(x = 1:50, y = rnorm(50))<br />
jjplot(x, y, data = df, fill = y, jjplot.bar(col = &quot;black&quot;))<br />
</code><br />
<a href="http://slycoder.files.wordpress.com/2010/03/jjplot_test001.png"><img src="http://slycoder.files.wordpress.com/2010/03/jjplot_test001.png?w=480&#038;h=480" alt="" title="jjplot_test001" width="480" height="480" class="aligncenter size-full wp-image-497" /></a></p>
<li> Boxplots.<br />
<code><br />
df &lt;- data.frame(state = rownames(state.x77), region = state.region, state.x77)<br />
jjplot(region, Income, data = df, fill = region, jjplot.group(jjplot.quantile(), by = region), jjplot.box())<br />
</code><br />
<a href="http://slycoder.files.wordpress.com/2010/03/jjplot_test003.png"><img src="http://slycoder.files.wordpress.com/2010/03/jjplot_test003.png?w=480&#038;h=480" alt="" title="jjplot_test003" width="480" height="480" class="aligncenter size-full wp-image-498" /></a></p>
<li> Scatter plot, colored by factor, with alpha blending.  This also demonstrates how statistics can be used to visualize different aspects of the data simultaneously.<br />
<code><br />
df &lt;- data.frame(x = rnorm(10000) + (1:4) * 1, f = factor(c(&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;)))<br />
df$y &lt;- c(-6, -2, 2, 4) * df$x + rnorm(10000)<br />
jjplot(x + 2, y, data = df, alpha = 0.10, color = f, jjplot.point(), jjplot.group(jjplot.fit(), by = f), jjplot.abline(), jjplot.fun.y(mean), jjplot.hline(lty = &quot;dashed&quot;))<br />
</code><br />
<a href="http://slycoder.files.wordpress.com/2010/03/jjplot_test008.png"><img src="http://slycoder.files.wordpress.com/2010/03/jjplot_test008.png?w=480&#038;h=480" alt="" title="jjplot_test008" width="480" height="480" class="aligncenter size-full wp-image-499" /></a></p>
<li> An example of log scales and the CCDF statistic.<br />
<code><br />
df &lt;- data.frame(x=rlnorm(1000,2,2.5))<br />
jjplot(x, data = df, jjplot.ccdf(density=TRUE), jjplot.point(), log=&#39;xy&#39;)<br />
</code><br />
<a href="http://slycoder.files.wordpress.com/2010/03/jjplot_test009.png"><img src="http://slycoder.files.wordpress.com/2010/03/jjplot_test009.png?w=480&#038;h=480" alt="" title="jjplot_test009" width="480" height="480" class="aligncenter size-full wp-image-500" /></a>
</ul>
<p>Lots more demos and documentation are <a href="http://code.google.com/p/jjplot/">here</a>.  To install visit <a href="http://jjplot.googlecode.com/files/jjplot_1.0.tar.gz">http://jjplot.googlecode.com/files/jjplot_1.0.tar.gz</a> and install the downloaded package using<br />
<code><br />
R CMD INSTALL jjplot_1.0.tar.gz<br />
</code><br />
We&#8217;re eager to hear your feedback!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/496/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=496&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2010/03/07/jjplot-yet-another-plotting-library-for-r/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/03/jjplot_test001.png" medium="image">
			<media:title type="html">jjplot_test001</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/03/jjplot_test003.png" medium="image">
			<media:title type="html">jjplot_test003</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/03/jjplot_test008.png" medium="image">
			<media:title type="html">jjplot_test008</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/03/jjplot_test009.png" medium="image">
			<media:title type="html">jjplot_test009</media:title>
		</media:content>
	</item>
		<item>
		<title>Axl Rose by any other name&#8230;</title>
		<link>http://pleasescoopme.com/2010/01/24/axl-rose-by-any-other-name/</link>
		<comments>http://pleasescoopme.com/2010/01/24/axl-rose-by-any-other-name/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 23:22:04 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=474</guid>
		<description><![CDATA[In a post a while ago, I wondered how much info about the band one could glean just by looking at the name.  I mean, shouldn&#8217;t it be obvious that a band named &#8220;Trauma&#8221; should be heavy metal?
This was the genesis of a collaboration between me and Matt Hoffman.   We wanted to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=474&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://pleasescoopme.com/2009/02/22/whats-in-a-name/">a post a while ago</a>, I wondered how much info about the band one could glean just by looking at the name.  I mean, shouldn&#8217;t it be obvious that a band named &#8220;Trauma&#8221; should be heavy metal?</p>
<p>This was the genesis of a collaboration between me and <a href="http://www.cs.princeton.edu/~mdhoffma/">Matt Hoffman</a>.   We wanted to see if you could improve genre prediction using the names of the bands.  Unfortunately, neither of us had enough time to really get this project going, but I thought I&#8217;d share what results we did get in hopes that someone else will pick up the torch. </p>
<p>To start off, we need a large training set of band/genre mappings.  We opted for the DBPedia Infobox mine that you can find at <a href="http://infochimps.org/">infochimps</a>.  (For those who don&#8217;t know, they&#8217;ve done some awesome data mining to grab all the structured info from Wikipedia infoboxes).  I did some cleaning up and have put up the list of <a href="https://docs.google.com/a/topicmodels.net/leaf?id=0B_m9_LMHnK7dNmQ3ODk3OTYtNjExYi00N2JlLWE2NGItYTk5ZDU1M2EwYjg2&amp;sort=name&amp;layout=list&amp;num=50">artists</a> and <a href="https://docs.google.com/a/topicmodels.net/leaf?id=0B_m9_LMHnK7dMDg1ZmFjM2QtNWI4OC00YTM2LTkwMjQtYmZlOGYxOTdjMjJm&amp;sort=name&amp;layout=list&amp;num=50">genres</a> (the artist in each line of the first file is associated with the genres on the corresponding line of the second file).</p>
<p>You might have noticed that Wikipedia is pretty crazy when it comes to genre definitions (because god forbid we confuse Melodic Death Metal and Power Metal).  This craziness makes it hard to map the artists to any canonicalized genre set (such as CAL-500).  I tried a bunch of techniques to do this canonicalization (including doing my own crawl of Wikipedia with all sorts of heuristics).  None of it worked very well for mapping genres to a canonicalized set, but it did let me make a <a href='http://slycoder.files.wordpress.com/2010/01/meow.pdf'>really cool graph of connections between genres</a>.  Eventually, we came to the conclusion that we needed human judgments.  We got mechanical turkers to label Wikipedia genres with CAL-500 genres.  Those results are <a href="https://spreadsheets.google.com/ccc?key=0Avm9_LMHnK7ddGJDS18tWUJPbTkwY2h1Y3BBT3R5bGc&amp;hl=fr">here.</a>  </p>
<p>With that training set in place, I decided to explore the data to see if there truly were correlations between substrings of artist names and genres.   The plot below shows the prevalence in each genre of artists containing &#8220;death&#8221; (red) or &#8220;boyz&#8221; (blue) in their name.   The green dots show the overall distribution of genres among artists in Wikipedia.  </p>
<p><a href="http://slycoder.files.wordpress.com/2010/01/genre_plot.png"><img src="http://slycoder.files.wordpress.com/2010/01/genre_plot.png?w=500&#038;h=500" alt="" title="genre_plot" width="500" height="500" class="aligncenter size-full wp-image-479" /></a></p>
<p>The graph shows that bands containing &#8220;death&#8221; in their name are much more likely to be Rock, Alternative, Metal/Hard Rock,  or Alternative.  Conversely, they are less likely to be Jazz, Hip-Hop, or Soul.  In contrast, bands containing &#8220;boyz&#8221; in their name are overwhelmingly Hip-Hop.  This confirmed my intuition and seemed promising to me, so we went ahead and developed a classifier for the CAL-500 data set.  The techniques we tried were:</p>
<ul>
<li><b>names (corrLDA)</b>- the <a href="http://www.cs.princeton.edu/~blei/papers/BleiLafferty2006.pdf">correlated topic model</a> fit to the Wikipedia data.  Predictions use only names.
<li><b>names (NB)</b> &#8211; naive Bayes fit to the Wikipedia data.  Predictions use only names.
<li><b>names (LR)</b> &#8211; logistic regression fit to the Wikipedia data.  Predictions use only names.
<li><b>baseline</b> &#8211; Predictions use the baseline frequency of genres on Wikipedia.  Predictions do not use any information about the instances.
<li><b>svm</b> &#8211; SVM fit using MFCC features.  Predictions use both names and audio.
<li><b>svm + names (corrLDA)</b> &#8211; SVM fit using MFCC features plus the results of names (corrLDA).  Predictions use both names and audio.
<li><b>svm + names (NB)</b>- SVM fit using MFCC features plus the results of names (NB).  Predictions use both names and audio.
<li><b>svm + names (LR)</b>- SVM fit using MFCC features plus the results of names (LR).  Predictions use both names and audio.
</ul>
<p>The plot below shows the precision-recall for each of these techniques.   As you can see, it&#8217;s not very promising.  The SVM will outclass any technique which uses the name along; otherwise all of the name techniques look about the same.  It looks like we might get a small bump by combining SVM with names (LR) but it&#8217;s hard to tell.<br />
<a href="http://slycoder.files.wordpress.com/2010/01/pr-all.png"><img src="http://slycoder.files.wordpress.com/2010/01/pr-all.png?w=500&#038;h=350" alt="" title="pr.all" width="500" height="350" class="aligncenter size-full wp-image-480" /></a><br />
But precision-recall may not be the right metric.  After all, pop and rock are so frequent that you will probably predict pop for every single item in the test set before you even make any other prediction.  Something which is perhaps more meaningful is to look at the rank of the correct labels on a per-test-instance level; the lower the rank, the better the model is at making predictions.   Boxplots of the ranks are given below.<br />
<a href="http://slycoder.files.wordpress.com/2010/01/rank-all.png"><img src="http://slycoder.files.wordpress.com/2010/01/rank-all.png?w=500&#038;h=350" alt="" title="rank.all" width="500" height="350" class="aligncenter size-full wp-image-481" /></a><br />
We see slightly different patterns when we look at the ranks.   Without using any audio data, the naive Bayes technique performs best and manages to get a non-trivial bump beyond the baseline.   When audio is included, the names add something, but not much.  Interestingly, the names (LR) technique which looked like it might help us at precision-recall actually does a bit worse when you look at the rank.   On the other hand, SVM + names (corrLDA) has the same median as SVM, but manages to do a better job at some of the difficult-to-predict cases, leading to a smaller interquartile range. </p>
<p>In sum, names give us something &#8212; unfortunately, it&#8217;s not a whole lot.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/474/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=474&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2010/01/24/axl-rose-by-any-other-name/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/01/genre_plot.png" medium="image">
			<media:title type="html">genre_plot</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/01/pr-all.png" medium="image">
			<media:title type="html">pr.all</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/01/rank-all.png" medium="image">
			<media:title type="html">rank.all</media:title>
		</media:content>
	</item>
		<item>
		<title>The cost of a sample</title>
		<link>http://pleasescoopme.com/2010/01/23/the-cost-of-a-sample/</link>
		<comments>http://pleasescoopme.com/2010/01/23/the-cost-of-a-sample/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 23:03:49 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=441</guid>
		<description><![CDATA[I once heard it on good authority that Gelman says you usually don&#8217;t need more than 12 samples.  Well, as a result of a discussion with Sam Gershman (sorry Sam for not answering the actual question you asked!), I wondered if that was true; that is, if under reasonable assumptions it might be better [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=441&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I once heard it on <a href="http://www.cfa.harvard.edu/~kmandel/">good authority</a> that <a href="http://www.stat.columbia.edu/~gelman/blog/">Gelman</a> says you usually don&#8217;t need more than 12 samples.  Well, as a result of a discussion with <a href="http://www.princeton.edu/~sjgershm/">Sam Gershman</a> (sorry Sam for not answering the actual question you asked!), I wondered if that was true; that is, if under reasonable assumptions it might be better to take a small number of samples.  Caveat: there&#8217;s probably lots of work on this already, but where would the fun be in that?</p>
<p>Ok, let&#8217;s assume that your goal is to estimate <img src='http://l.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_%7Bz+%5Csim+p%28z+%7C+x%29%7D%5Bf%28z%29%5D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\mathbb{E}_{z \sim p(z | x)}[f(z)]' title='\mathbb{E}_{z \sim p(z | x)}[f(z)]' class='latex' />, where <img src='http://l.wordpress.com/latex.php?latex=p%28z+%7C+x%29&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='p(z | x)' title='p(z | x)' class='latex' /> represents some distribution on hidden variables over which you are trying to compute a function, <img src='http://l.wordpress.com/latex.php?latex=f&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='f' title='f' class='latex' />.   For the usual reasons, it&#8217;s intractable to compute this exactly, so you&#8217;re going to use a sampler.  Let&#8217;s assume</p>
<ul>
<li><b>that your sampler has mixed and that you&#8217;re getting independent samples</b> (that condition alone should give you fair warning that what I&#8217;m about to say is of little practical value);
<li><img src='http://l.wordpress.com/latex.php?latex=f&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='f' title='f' class='latex' /> is bounded (say between 0 and 1);
<li> to obtain <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='n' title='n' class='latex' /> samples from the sampler costs some amount, say <img src='http://l.wordpress.com/latex.php?latex=R%28n%29&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='R(n)' title='R(n)' class='latex' />.
</ul>
<p>More samples are usually better, because they&#8217;ll give you a better representation of the true distribution, i.e. <img src='http://l.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_%7Bz+%5Csim+%5Chat%7Bp_n%7D%28z+%7C+x%29%7D%5Bf%28z%29%5D+%5Crightarrow+%5Cmathbb%7BE%7D_%7Bz+%5Csim+p%28z+%7C+x%29%7D%5Bf%28z%29%5D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\mathbb{E}_{z \sim \hat{p_n}(z | x)}[f(z)] \rightarrow \mathbb{E}_{z \sim p(z | x)}[f(z)]' title='\mathbb{E}_{z \sim \hat{p_n}(z | x)}[f(z)] \rightarrow \mathbb{E}_{z \sim p(z | x)}[f(z)]' class='latex' />, where <img src='http://l.wordpress.com/latex.php?latex=%5Chat%7Bp_n%7D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\hat{p_n}' title='\hat{p_n}' class='latex' /> is the distribution obtained by using <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='n' title='n' class='latex' /> samples.  Unfortunately, more samples come at a cost here, so you don&#8217;t want too many.  How should you tradeoff then?</p>
<p>We can define a loss by <img src='http://l.wordpress.com/latex.php?latex=%5Cell+%3D+R%28n%29+%2B+%7C%5Cmathbb%7BE%7D_%7Bz+%5Csim+%5Chat%7Bp_n%7D%28z+%7C+x%29%7D%5Bf%28z%29%5D+-+%5Cmathbb%7BE%7D_%7Bz+%5Csim+p%28z+%7C+x%29%7D%5Bf%28z%29%5D%7C&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\ell = R(n) + |\mathbb{E}_{z \sim \hat{p_n}(z | x)}[f(z)] - \mathbb{E}_{z \sim p(z | x)}[f(z)]|' title='\ell = R(n) + |\mathbb{E}_{z \sim \hat{p_n}(z | x)}[f(z)] - \mathbb{E}_{z \sim p(z | x)}[f(z)]|' class='latex' />, that is, how far off our sampled estimate is from the truth, plus the cost of obtaining those samples.  Using Hoeffding, we can bound the loss <img src='http://l.wordpress.com/latex.php?latex=%5Cell+%3C+R%28n%29+%2B+%5Cepsilon&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\ell &lt; R(n) + \epsilon' title='\ell &lt; R(n) + \epsilon' class='latex' /> with probability <img src='http://l.wordpress.com/latex.php?latex=1+-+2+%5Cexp%28+-2+n+%5Cepsilon%5E2%29&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='1 - 2 \exp( -2 n \epsilon^2)' title='1 - 2 \exp( -2 n \epsilon^2)' class='latex' />.  This expression gives you something to think about when you&#39;re trying to decide how many samples to take &#8212; more samples loosen the bound but increase its probability.  </p>
<p>If your cost is linear, <img src='http://l.wordpress.com/latex.php?latex=R%28n%29+%3D+a+n&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='R(n) = a n' title='R(n) = a n' class='latex' />, you might want to choose<br />
something like <img src='http://l.wordpress.com/latex.php?latex=n+%3D+%5Cfrac%7B%5Cepsilon%7D%7Ba%7D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='n = \frac{\epsilon}{a}' title='n = \frac{\epsilon}{a}' class='latex' />, which gives you a loss of <img src='http://l.wordpress.com/latex.php?latex=%5Cell+%3C+2+%5Cepsilon&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\ell &lt; 2 \epsilon' title='\ell &lt; 2 \epsilon' class='latex' /> with probability <img src='http://l.wordpress.com/latex.php?latex=1+-+2+%5Cexp%28-2+%5Cepsilon%5E3+%2F+a%29&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='1 - 2 \exp(-2 \epsilon^3 / a)' title='1 - 2 \exp(-2 \epsilon^3 / a)' class='latex' />.  </p>
<p>The plot below shows what might happen if you make such a choice.  Here, I&#39;ve let the posterior be an equiprobable binomial distribution.  The function I&#39;m computing is the identity <img src='http://l.wordpress.com/latex.php?latex=f%28z%29+%3D+z&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='f(z) = z' title='f(z) = z' class='latex' />.  The curves show the loss, <img src='http://l.wordpress.com/latex.php?latex=%5Cell&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\ell' title='\ell' class='latex' /> for various  choices of the cost parameter <img src='http://l.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='a' title='a' class='latex' /> as a function of the number of samples.   The dots show the chosen values of <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='n' title='n' class='latex' /> for each value of <img src='http://l.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='a' title='a' class='latex' />; the horizontal lines show the 80% loss bound for these choices.</p>
<p><a href="http://slycoder.files.wordpress.com/2010/01/costly-sampling1.png"><img src="http://slycoder.files.wordpress.com/2010/01/costly-sampling1.png?w=500&#038;h=285" alt="" title="The cost of sampling" width="500" height="285" class="aligncenter size-full wp-image-442" /></a></p>
<p>Turns out for some reasonable values, you really should stick to about 12 samples.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/441/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=441&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2010/01/23/the-cost-of-a-sample/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2010/01/costly-sampling1.png" medium="image">
			<media:title type="html">The cost of sampling</media:title>
		</media:content>
	</item>
		<item>
		<title>How diverse is Facebook?</title>
		<link>http://pleasescoopme.com/2009/12/17/how-diverse-is-facebook/</link>
		<comments>http://pleasescoopme.com/2009/12/17/how-diverse-is-facebook/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 17:53:32 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=436</guid>
		<description><![CDATA[I&#8217;ve been doing some work on the topic, along with Lars, Cameron, and Itamar.  Read more at http://www.facebook.com/note.php?note_id=205925658858

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=436&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some work on the topic, along with Lars, Cameron, and Itamar.  Read more at <a href="http://www.facebook.com/note.php?note_id=205925658858">http://www.facebook.com/note.php?note_id=205925658858</a></p>
<p><a href="http://slycoder.files.wordpress.com/2009/12/photo-1.jpeg"><img src="http://slycoder.files.wordpress.com/2009/12/photo-1.jpeg?w=500&#038;h=355" alt="" title="photo-1" width="500" height="355" class="aligncenter size-full wp-image-438" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/436/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=436&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2009/12/17/how-diverse-is-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2009/12/photo-1.jpeg" medium="image">
			<media:title type="html">photo-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Come to our NIPS talk!</title>
		<link>http://pleasescoopme.com/2009/12/09/come-to-our-nips-talk/</link>
		<comments>http://pleasescoopme.com/2009/12/09/come-to-our-nips-talk/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 23:41:08 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=432</guid>
		<description><![CDATA[For those of you in Vancouver right now, here&#8217;s a shameless plug for our NIPS talk on interpreting topic models, which is happening at 4:10.  Hope to see you there.  And to whet your apetite, here&#8217;s a picture:

To find out what it means, come to the talk!  And don&#8217;t forget the workshop [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=432&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>For those of you in Vancouver right now, here&#8217;s a shameless plug for our NIPS talk on interpreting topic models, which is happening at <b>4:10</b>.  Hope to see you there.  And to whet your apetite, here&#8217;s a picture:<br />
<a href="http://slycoder.files.wordpress.com/2009/12/position_scatter.png"><img src="http://slycoder.files.wordpress.com/2009/12/position_scatter.png?w=500&#038;h=350" alt="" title="position_scatter" width="500" height="350" class="aligncenter size-full wp-image-433" /></a><br />
To find out what it means, come to the talk!  And don&#8217;t forget the <a href="http://nips2009.topicmodels.net">workshop</a> on Friday =).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/432/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/432/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/432/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/432/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/432/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/432/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/432/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/432/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/432/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/432/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=432&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2009/12/09/come-to-our-nips-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2009/12/position_scatter.png" medium="image">
			<media:title type="html">position_scatter</media:title>
		</media:content>
	</item>
		<item>
		<title>Data for some topic model tasseography</title>
		<link>http://pleasescoopme.com/2009/11/17/data-for-some-topic-model-tasseography/</link>
		<comments>http://pleasescoopme.com/2009/11/17/data-for-some-topic-model-tasseography/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 19:40:17 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=418</guid>
		<description><![CDATA[Thanks to all of you who&#8217;ve expressed interest in and support for our recent paper Reading Tea Leaves: How Humans Interpret Topic Models, which was co-authored with Jordan Boyd-Graber, Sean Gerrish, Chong Wang, and David Blei.  Many people (myself included) either implicitly or explicitly assume that topic models can find meaningful latent spaces with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=418&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Thanks to all of you who&#8217;ve expressed interest in and support for our recent paper <a href="http://nips.cc/Conferences/2009/Program/event.php?ID=1812">Reading Tea Leaves: How Humans Interpret Topic Models</a>, which was co-authored with <a href="http://umiacs.umd.edu/~jbg/">Jordan Boyd-Graber</a>, <a href="http://www.seangerrish.com/index.htm">Sean Gerrish</a>, <a href="http://www.cs.princeton.edu/~chongw/">Chong Wang</a>, and <a href="http://www.cs.princeton.edu/~blei/">David Blei</a>.  Many people (myself included) either implicitly or explicitly assume that topic models can find meaningful latent spaces with semantically coherent topics.  The goal of this paper was to put this assumption to the test by gathering lots of human responses to some tasks we devised.  We got some surprising and interesting results &#8212; held-out likelihood is often not a good proxy interpretability.  You&#8217;ll have to read the paper for the details, but I&#8217;ll just leave you with a teaser plot below.</p>
<p><a href="http://slycoder.files.wordpress.com/2009/11/big_scatter.png"><img src="http://slycoder.files.wordpress.com/2009/11/big_scatter.png?w=500&#038;h=250" alt="" title="big_scatter" width="500" height="250" class="aligncenter size-full wp-image-426" /></a></p>
<p>Furthermore, Jordan has worked hard prepping some of our data for public release.   You can find that stuff <a href="http://topics.cs.princeton.edu/rtl/rtl_data.tar.gz">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/418/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=418&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2009/11/17/data-for-some-topic-model-tasseography/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2009/11/big_scatter.png" medium="image">
			<media:title type="html">big_scatter</media:title>
		</media:content>
	</item>
		<item>
		<title>LDA 1.1 is now on CRAN</title>
		<link>http://pleasescoopme.com/2009/10/01/lda-1-1-is-now-on-cran/</link>
		<comments>http://pleasescoopme.com/2009/10/01/lda-1-1-is-now-on-cran/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 04:04:29 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=407</guid>
		<description><![CDATA[Your favorite package for running topic models in R has been updated!  This one not only has bugfixes and more utility functions, it also has two new models:

The Networks Uncovered by Bayesian Inference (NUBBI) model which discovers connections between entities in free text (run demo(nubbi), note that because of licensing reasons, I could not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=407&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Your favorite package for running topic models in R has been updated!  This one not only has bugfixes and more utility functions, it also has two new models:</p>
<ul>
<li>The <a href="http://www.cs.princeton.edu/~blei/papers/ChangBoyd-GraberBlei2009.pdf">Networks Uncovered by Bayesian Inference (NUBBI)</a> model which discovers connections between entities in free text (run <code>demo(nubbi)</code>, note that because of licensing reasons, I could not include the data for this demo in the package);<br />
<a href="http://slycoder.files.wordpress.com/2009/09/demo-nubbi.png"><img src="http://slycoder.files.wordpress.com/2009/09/demo-nubbi.png?w=500&#038;h=350" alt="demo(nubbi)" title="demo(nubbi)" width="500" height="350" class="aligncenter size-full wp-image-408" /></a></p>
<li>the <a href="http://www.cs.princeton.edu/~blei/papers/ChangBlei2009.pdf">Relational Topic Model (RTM)</a> for discovering patterns which account for both document content and connections between documents (run <code>demo(rtm)</code>).<br />
<a href="http://slycoder.files.wordpress.com/2009/09/demo-rtm.png"><img src="http://slycoder.files.wordpress.com/2009/09/demo-rtm.png?w=500&#038;h=350" alt="demo(rtm)" title="demo(rtm)" width="500" height="350" class="aligncenter size-full wp-image-409" /></a>
</ul>
<p>And because it&#8217;s on CRAN, everyone (including windows users) can install by simply executing <code>install.packages("lda")</code>.  Please install, play with it, and let me know if you find any bugs.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/407/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=407&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2009/10/01/lda-1-1-is-now-on-cran/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2009/09/demo-nubbi.png" medium="image">
			<media:title type="html">demo(nubbi)</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2009/09/demo-rtm.png" medium="image">
			<media:title type="html">demo(rtm)</media:title>
		</media:content>
	</item>
		<item>
		<title>When is first-order better than second-order?</title>
		<link>http://pleasescoopme.com/2009/09/03/when-is-first-order-better-than-second-order/</link>
		<comments>http://pleasescoopme.com/2009/09/03/when-is-first-order-better-than-second-order/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 23:58:56 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slycoder.wordpress.com/?p=319</guid>
		<description><![CDATA[Dave and I were recently talking about Asuncion et al.&#8217;s wonderful recent paper &#8220;On Smoothing and Inference for Topic Models.&#8221;  One thing that caught our eye was the CVB0 inference method for topic models, which is described as a first-order approximation of the collapsed variational Bayes approach.  The odd thing is that this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=319&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cs.princeton.edu/~blei">Dave</a> and I were recently talking about Asuncion et al.&#8217;s wonderful recent paper &#8220;<a href="http://www.cs.mcgill.ca/~uai2009/papers/UAI2009_0243_1a80458f5db72411c0c1e392f7dbbc48.pdf">On Smoothing and Inference for Topic Models</a>.&#8221;  One thing that caught our eye was the CVB0 inference method for topic models, which is described as a first-order approximation of the collapsed variational Bayes approach.  The odd thing is that this first-order approximation performs better than other, more &#8220;principled&#8221; approaches.  I want to try to understand why.  Here&#8217;s my current less-than-satisfactory stab:</p>
<p>Let me just lay out the problem.  Suppose I want to approximate the marginal posterior over topic assignments <img src='http://l.wordpress.com/latex.php?latex=z_i&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='z_i' title='z_i' class='latex' /> in a topic model given the observed words <img src='http://l.wordpress.com/latex.php?latex=w&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='w' title='w' class='latex' />, <img src='http://l.wordpress.com/latex.php?latex=p%28z_i+%7C+w%29.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='p(z_i | w).' title='p(z_i | w).' class='latex' />  We can expand this probability using an expectation,</p>
<p style="text-align:center;">
<img src='http://l.wordpress.com/latex.php?latex=p%28z_i+%7C+w%29+%3D+%5Cmathbb%7BE%7D_%7Bp%28z_%7B-i%7D+%7C+w%29%7D%5Bp%28z_i+%7C+z_%7B-i%7D%2C+w%29%5D.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='p(z_i | w) = \mathbb{E}_{p(z_{-i} | w)}[p(z_i | z_{-i}, w)].' title='p(z_i | w) = \mathbb{E}_{p(z_{-i} | w)}[p(z_i | z_{-i}, w)].' class='latex' />
</p>
<p>We can&#8217;t compute the expectation analytically, so we must turn to an approximate inference technique.  One technique is to run a Gibbs sampler whence we get <img src='http://l.wordpress.com/latex.php?latex=S&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='S' title='S' class='latex' /> samples from the joint posterior over topic assignments <img src='http://l.wordpress.com/latex.php?latex=z%5E%7B%281%29%7D%2C+z%5E%7B%282%29%7D%2C+%5Cldots%2C+z%5E%7B%28S%29%7D.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='z^{(1)}, z^{(2)}, \ldots, z^{(S)}.' title='z^{(1)}, z^{(2)}, \ldots, z^{(S)}.' class='latex' />   Then using these samples we approximate the expectation,</p>
<p style="text-align:center;">
<img src='http://l.wordpress.com/latex.php?latex=p%28z_i+%7C+w%29+%5Capprox+%5Cfrac%7B1%7D%7BS%7D%5Csum_s+p%28z_i+%7C+z%5E%7B%28s%29%7D_%7B-i%7D%29.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='p(z_i | w) \approx \frac{1}{S}\sum_s p(z_i | z^{(s)}_{-i}).' title='p(z_i | w) \approx \frac{1}{S}\sum_s p(z_i | z^{(s)}_{-i}).' class='latex' />
</p>
<p>In the case of LDA, this conditional probability is proportional to </p>
<p style="text-align:center;">
<img src='http://l.wordpress.com/latex.php?latex=p%28z_i+%7C+z%5E%7B%28s%29%7D_%7B-i%7D%29+%5Cpropto+%5Cfrac%7BN%5E%7B%5Clnot+i%7D_%7Bwk%7D+%2B+%5Ceta%7D%7BN%5E%7B%5Clnot+i%7D_k+%2B+V+%5Ceta%7D+%28N%5E%7B%5Clnot+i%7D_%7Bdk%7D+%2B+%5Calpha%29%2C&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='p(z_i | z^{(s)}_{-i}) \propto \frac{N^{\lnot i}_{wk} + \eta}{N^{\lnot i}_k + V \eta} (N^{\lnot i}_{dk} + \alpha),' title='p(z_i | z^{(s)}_{-i}) \propto \frac{N^{\lnot i}_{wk} + \eta}{N^{\lnot i}_k + V \eta} (N^{\lnot i}_{dk} + \alpha),' class='latex' />
</p>
<p>where </p>
<ul>
<li><img src='http://l.wordpress.com/latex.php?latex=%5Calpha&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\alpha' title='\alpha' class='latex' /> is the Dirichlet hyperparameter for topic proportion vectors;</li>
<li><img src='http://l.wordpress.com/latex.php?latex=%5Ceta&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\eta' title='\eta' class='latex' /> is the Dirichlet hyperparameter for the topic multinomials;</li>
<li> <img src='http://l.wordpress.com/latex.php?latex=N%5E%7B%5Clnot+i%7D_%7Bwk%7D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='N^{\lnot i}_{wk}' title='N^{\lnot i}_{wk}' class='latex' /> is the number of times topic <img src='http://l.wordpress.com/latex.php?latex=k&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='k' title='k' class='latex' /> has been assigned to word <img src='http://l.wordpress.com/latex.php?latex=w&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='w' title='w' class='latex' />;
<li> <img src='http://l.wordpress.com/latex.php?latex=N%5E%7B%5Clnot+i%7D_%7Bk%7D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='N^{\lnot i}_{k}' title='N^{\lnot i}_{k}' class='latex' /> is the number of times topic <img src='http://l.wordpress.com/latex.php?latex=k&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='k' title='k' class='latex' /> has been assigned overall;
<li> <img src='http://l.wordpress.com/latex.php?latex=N%5E%7B%5Clnot+i%7D_%7Bdk%7D&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='N^{\lnot i}_{dk}' title='N^{\lnot i}_{dk}' class='latex' /> is the number of times topic <img src='http://l.wordpress.com/latex.php?latex=k&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='k' title='k' class='latex' /> has been assigned in document <img src='http://l.wordpress.com/latex.php?latex=d.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='d.' title='d.' class='latex' />
</ul>
<p>Note that the above counts do not include the current value of <img src='http://l.wordpress.com/latex.php?latex=z_i&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='z_i' title='z_i' class='latex' /> (hence the superscript).  </p>
<p>Instead of the Gibbs sampling approach, we could also approximate the expectation by taking a first order approximation (which we denote <img src='http://l.wordpress.com/latex.php?latex=%5Cgamma_i&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\gamma_i' title='\gamma_i' class='latex' />),</p>
<p style="text-align:center;">
<img src='http://l.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D%5Bp%28z_i+%7C+z_%7B-i%7D%29%5D+%5Capprox+%5Cgamma_i+%5Cpropto+%5Cfrac%7B%5Cmathbb%7BE%7D%5BN%5E%7B%5Clnot+i%7D_%7Bwk%7D%5D+%2B+%5Ceta%7D%7B%5Cmathbb%7BE%7D%5BN%5E%7B%5Clnot+i%7D_k%5D+%2B+V+%5Ceta%7D+%28%5Cmathbb%7BE%7D%5BN%5E%7B%5Clnot+i%7D_%7Bdk%7D%5D+%2B+%5Calpha%29%2C&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\mathbb{E}[p(z_i | z_{-i})] \approx \gamma_i \propto \frac{\mathbb{E}[N^{\lnot i}_{wk}] + \eta}{\mathbb{E}[N^{\lnot i}_k] + V \eta} (\mathbb{E}[N^{\lnot i}_{dk}] + \alpha),' title='\mathbb{E}[p(z_i | z_{-i})] \approx \gamma_i \propto \frac{\mathbb{E}[N^{\lnot i}_{wk}] + \eta}{\mathbb{E}[N^{\lnot i}_k] + V \eta} (\mathbb{E}[N^{\lnot i}_{dk}] + \alpha),' class='latex' />
</p>
<p>where the expectations are taken with respect to <img src='http://l.wordpress.com/latex.php?latex=p%28z_%7B-i%7D+%7C+w%29.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='p(z_{-i} | w).' title='p(z_{-i} | w).' class='latex' />   Because the terms in the expectations are simple sums, they can be computed solely as functions of <img src='http://l.wordpress.com/latex.php?latex=%5Cgamma&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\gamma' title='\gamma' class='latex' />.  For example, </p>
<p style="text-align:center;">
   <img src='http://l.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D%5BN%5E%7B%5Clnot+i%7D_k%5D+%3D+%5Cmathbb%7BE%7D%5B%5Csum_%7Bj+%5Cne+i%7D+z_%7Bjk%7D%5D+%3D+%5Csum_%7Bj+%5Cne+i%7D+%5Cmathbb%7BE%7D%5Bz_%7Bjk%7D%5D+%3D+%5Csum_%7Bj+%5Cne+i%7D+p%28z_j%29+%5Capprox+%5Csum_%7Bj+%5Cne+i%7D+%5Cgamma_j.&#038;bg=ffffff&#038;fg=444444&#038;s=0' alt='\mathbb{E}[N^{\lnot i}_k] = \mathbb{E}[\sum_{j \ne i} z_{jk}] = \sum_{j \ne i} \mathbb{E}[z_{jk}] = \sum_{j \ne i} p(z_j) \approx \sum_{j \ne i} \gamma_j.' title='\mathbb{E}[N^{\lnot i}_k] = \mathbb{E}[\sum_{j \ne i} z_{jk}] = \sum_{j \ne i} \mathbb{E}[z_{jk}] = \sum_{j \ne i} p(z_j) \approx \sum_{j \ne i} \gamma_j.' class='latex' />
</p>
<p>Thus, the solution to this approximation is exactly the CVB0 technique described in the paper.  Note that I never directly introduced the concept of a variational distribution!  CVB0 is simply a first-order approximation to the true expectations;  in contrast, the second-order CVB approximation is an approximation of the <i>variational</i> expectations.  So maybe that&#8217;s the answer to the puzzle: sometimes a first-order approximation to the true value is better than a second-order approximation to a surrogate objective.  </p>
<p>Does anyone have any other explanations?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/319/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=319&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2009/09/03/when-is-first-order-better-than-second-order/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>R LDA package minor update: 1.0.1</title>
		<link>http://pleasescoopme.com/2009/09/02/r-lda-package-minor-update-1-0-1/</link>
		<comments>http://pleasescoopme.com/2009/09/02/r-lda-package-minor-update-1-0-1/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 06:07:26 +0000</pubDate>
		<dc:creator>slycoder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pleasescoopme.com/?p=375</guid>
		<description><![CDATA[Dave gently reminded me that properly assessing convergence of our models is important and that just running a sampler for N iterations is unsatisfactory.  I agree wholeheartedly.  As a first step, the collapsed Gibbs sampler in the R LDA package can now optionally report the log likelihood (to within a constant).  For [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=375&subd=slycoder&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Dave gently reminded me that properly assessing convergence of our models is important and that just running a sampler for N iterations is unsatisfactory.  I agree wholeheartedly.  As a first step, the collapsed Gibbs sampler in the R LDA package can now optionally report the log likelihood (to within a constant).  For example, we can rerun the model fit in <code>demo(lda)</code> but with an extra flag set:<br />
<code>
<pre>
result &lt;- lda.collapsed.gibbs.sampler(cora.documents,
                                      K,  ## Num clusters
                                      cora.vocab,
                                      25,  ## Num iterations
                                      0.1,
                                      0.1,
                                      compute.log.likelihood=TRUE)
</pre>
<p></code></p>
<p>Using the now-available variable <code>result$log.likelihoods</code>, we can plot the progress of the sampler versus iteration:</p>
<p><a href="http://slycoder.files.wordpress.com/2009/09/convergence.png"><img src="http://slycoder.files.wordpress.com/2009/09/convergence.png?w=500&#038;h=350" alt="log likelihood as a function of iteration" title="log likelihood as a function of iteration" width="500" height="350" class="aligncenter size-full wp-image-377" /></a></p>
<p>Grab it while it&#8217;s hot: <a href="http://www.cs.princeton.edu/~jcone/lda_1.0.1.tar.gz">http://www.cs.princeton.edu/~jcone/lda_1.0.1.tar.gz</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/slycoder.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/slycoder.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/slycoder.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/slycoder.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/slycoder.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/slycoder.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/slycoder.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/slycoder.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/slycoder.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/slycoder.wordpress.com/375/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pleasescoopme.com&blog=5562246&post=375&subd=slycoder&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://pleasescoopme.com/2009/09/02/r-lda-package-minor-update-1-0-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/472fd1b0a3858a5ccfb0cc27411079e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">slycoder</media:title>
		</media:content>

		<media:content url="http://slycoder.files.wordpress.com/2009/09/convergence.png" medium="image">
			<media:title type="html">log likelihood as a function of iteration</media:title>
		</media:content>
	</item>
	</channel>
</rss>