<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Text Classification for Sentiment Analysis &#8211; Precision and Recall</title>
	<atom:link href="http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/feed/" rel="self" type="application/rss+xml" />
	<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
	<description>Weotta be Hacking</description>
	<lastBuildDate>Sun, 05 Feb 2012 22:47:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
		<item>
		<title>By: Schillermika</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-918</link>
		<dc:creator>Schillermika</dc:creator>
		<pubDate>Fri, 21 Oct 2011 18:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-918</guid>
		<description>Why didn&#039;t I see that?...thnx! Really good blog, btw. I&#039;ve learned more practical stuff  on here and through your book than anywhere else. </description>
		<content:encoded><![CDATA[<p>Why didn&#8217;t I see that?&#8230;thnx! Really good blog, btw. I&#8217;ve learned more practical stuff  on here and through your book than anywhere else.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Perkins</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-917</link>
		<dc:creator>Jacob Perkins</dc:creator>
		<pubDate>Fri, 21 Oct 2011 15:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-917</guid>
		<description>Here&#039;s your problem: random.shuffle(featuresets)
If you do this before splitting the train_feats &amp; test_feats, then of course you&#039;ll be getting different results, because the training features are different each time.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s your problem: random.shuffle(featuresets)<br />
If you do this before splitting the train_feats &amp; test_feats, then of course you&#8217;ll be getting different results, because the training features are different each time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Schillermika</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-916</link>
		<dc:creator>Schillermika</dc:creator>
		<pubDate>Fri, 21 Oct 2011 05:46:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-916</guid>
		<description>What do you mean by change the fraction? ...don&#039;t really see any bugs that might be causing this either. Here&#039;s the code I&#039;m running. Sorry if it gets all jumbled looking. 


 import nltkimport collectionsimport randomimport nltk.metricsfrom nltk.corpus.reader import PlaintextCorpusReaderfrom nltk.corpus.util import LazyCorpusLoaderdirty_teen_corpus = LazyCorpusLoader(&#039;cookbook&#039;, PlaintextCorpusReader, [&#039;dirty_teen.txt&#039;])clean_teen_corpus = LazyCorpusLoader(&#039;cookbook&#039;, PlaintextCorpusReader, [&#039;clean_teen.txt&#039;])raw_dataset = ([(sentence, &quot;Dirty&quot;) for sentence in dirty_teen_corpus.sents()] +           [(sentence, &quot;Clean&quot;) for sentence in clean_teen_corpus.sents()])def sexy_text(sentence):    return dict([(word.lower(), True) for word in sentence])featuresets = [(sexy_text(sentence), label) for (sentence, label) in raw_dataset]random.shuffle(featuresets)train_feats, test_feats = featuresets[:270], featuresets[270:]classifier = nltk.NaiveBayesClassifier.train(train_feats)refsets = collections.defaultdict(set)testsets = collections.defaultdict(set)for i, (feats, label) in enumerate(test_feats):	refsets[label].add(i)	observed = classifier.classify(feats)	testsets[observed].add(i)print &#039;Accuracy:&#039;, nltk.classify.accuracy(classifier, test_feats)print &quot;dirty precision:&quot;, nltk.metrics.precision(refsets[&quot;Dirty&quot;], testsets[&quot;Dirty&quot;])print &quot;dirty recall:&quot;, nltk.metrics.recall(refsets[&quot;Dirty&quot;], testsets[&quot;Dirty&quot;])print &quot;clean precision:&quot;, nltk.metrics.precision(refsets[&quot;Clean&quot;], testsets[&quot;Clean&quot;])print &quot;clean recall:&quot;, nltk.metrics.recall(refsets[&quot;Clean&quot;], testsets[&quot;Clean&quot;])print classifier.show_most_informative_features(15)</description>
		<content:encoded><![CDATA[<p>What do you mean by change the fraction? &#8230;don&#8217;t really see any bugs that might be causing this either. Here&#8217;s the code I&#8217;m running. Sorry if it gets all jumbled looking. </p>
<p> import nltkimport collectionsimport randomimport nltk.metricsfrom nltk.corpus.reader import PlaintextCorpusReaderfrom nltk.corpus.util import LazyCorpusLoaderdirty_teen_corpus = LazyCorpusLoader(&#8216;cookbook&#8217;, PlaintextCorpusReader, ['dirty_teen.txt'])clean_teen_corpus = LazyCorpusLoader(&#8216;cookbook&#8217;, PlaintextCorpusReader, ['clean_teen.txt'])raw_dataset = ([(sentence, "Dirty") for sentence in dirty_teen_corpus.sents()] +           [(sentence, "Clean") for sentence in clean_teen_corpus.sents()])def sexy_text(sentence):    return dict([(word.lower(), True) for word in sentence])featuresets = [(sexy_text(sentence), label) for (sentence, label) in raw_dataset]random.shuffle(featuresets)train_feats, test_feats = featuresets[:270], featuresets[270:]classifier = nltk.NaiveBayesClassifier.train(train_feats)refsets = collections.defaultdict(set)testsets = collections.defaultdict(set)for i, (feats, label) in enumerate(test_feats):	refsets[label].add(i)	observed = classifier.classify(feats)	testsets[observed].add(i)print &#8216;Accuracy:&#8217;, nltk.classify.accuracy(classifier, test_feats)print &#8220;dirty precision:&#8221;, nltk.metrics.precision(refsets["Dirty"], testsets["Dirty"])print &#8220;dirty recall:&#8221;, nltk.metrics.recall(refsets["Dirty"], testsets["Dirty"])print &#8220;clean precision:&#8221;, nltk.metrics.precision(refsets["Clean"], testsets["Clean"])print &#8220;clean recall:&#8221;, nltk.metrics.recall(refsets["Clean"], testsets["Clean"])print classifier.show_most_informative_features(15)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Perkins</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-915</link>
		<dc:creator>Jacob Perkins</dc:creator>
		<pubDate>Thu, 20 Oct 2011 14:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-915</guid>
		<description>The only reason this would be happening is if the training set is changing. Maybe you changed the fraction? Or there&#039;s some randomness being introduced somewhere?</description>
		<content:encoded><![CDATA[<p>The only reason this would be happening is if the training set is changing. Maybe you changed the fraction? Or there&#8217;s some randomness being introduced somewhere?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Schillermika</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-914</link>
		<dc:creator>Schillermika</dc:creator>
		<pubDate>Thu, 20 Oct 2011 04:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-914</guid>
		<description>Hi,

I&#039;m classifying text as either vulgar or clean. I ran the metrics on the data several times and got slightly different results each time. For example, notice that every score has changed slightly from the first to the second evaluation even though it&#039;s the exact same data. Any idea why this might be? 

Accuracy: 0.875968992248
dirty precision: 0.965517241379
dirty recall: 0.8
clean precision: 0.802816901408
clean recall: 0.966101694915
Most Informative Features
                       ! = True            Dirty : Clean  =     19.8 : 1.0
                       . = None            Dirty : Clean  =      9.2 : 1.0
                     ass = True            Dirty : Clean  =      6.8 : 1.0
                    even = True            Clean : Dirty  =      6.1 : 1.0
                    feel = True            Clean : Dirty  =      5.7 : 1.0
               something = True            Clean : Dirty  =      5.3 : 1.0
                    your = True            Dirty : Clean  =      5.2 : 1.0
                     had = True            Dirty : Clean  =      5.2 : 1.0
                   would = True            Clean : Dirty  =      4.7 : 1.0
                   being = True            Clean : Dirty  =      4.5 : 1.0

Accuracy: 0.744186046512dirty precision: 1.0dirty recall: 0.521739130435clean precision: 0.645161290323clean recall: 1.0Most Informative Features                       ! = True            Dirty : Clean  =     19.5 : 1.0                      be = True            Clean : Dirty  =      8.7 : 1.0                     don = True            Clean : Dirty  =      7.9 : 1.0                     get = True            Clean : Dirty  =      6.2 : 1.0                     not = True            Clean : Dirty  =      6.2 : 1.0               something = True            Clean : Dirty  =      6.2 : 1.0                    this = True            Clean : Dirty  =      6.2 : 1.0                      by = True            Clean : Dirty  =      6.2 : 1.0                   would = True            Clean : Dirty  =      6.2 : 1.0                   never = True            Clean : Dirty  =      6.2 : 1.0                     off = True            Dirty : Clean  =      6.1 : 1.0                   being = True            Clean : Dirty  =      5.4 : 1.0                     did = True            Clean : Dirty  =      5.4 : 1.0                    feel = True            Clean : Dirty  =      5.2 : 1.0                       . = None            Dirty : Clean  =      5.2 : 1.0</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;m classifying text as either vulgar or clean. I ran the metrics on the data several times and got slightly different results each time. For example, notice that every score has changed slightly from the first to the second evaluation even though it&#8217;s the exact same data. Any idea why this might be? </p>
<p>Accuracy: 0.875968992248<br />
dirty precision: 0.965517241379<br />
dirty recall: 0.8<br />
clean precision: 0.802816901408<br />
clean recall: 0.966101694915<br />
Most Informative Features<br />
                       ! = True            Dirty : Clean  =     19.8 : 1.0<br />
                       . = None            Dirty : Clean  =      9.2 : 1.0<br />
                     ass = True            Dirty : Clean  =      6.8 : 1.0<br />
                    even = True            Clean : Dirty  =      6.1 : 1.0<br />
                    feel = True            Clean : Dirty  =      5.7 : 1.0<br />
               something = True            Clean : Dirty  =      5.3 : 1.0<br />
                    your = True            Dirty : Clean  =      5.2 : 1.0<br />
                     had = True            Dirty : Clean  =      5.2 : 1.0<br />
                   would = True            Clean : Dirty  =      4.7 : 1.0<br />
                   being = True            Clean : Dirty  =      4.5 : 1.0</p>
<p>Accuracy: 0.744186046512dirty precision: 1.0dirty recall: 0.521739130435clean precision: 0.645161290323clean recall: 1.0Most Informative Features                       ! = True            Dirty : Clean  =     19.5 : 1.0                      be = True            Clean : Dirty  =      8.7 : 1.0                     don = True            Clean : Dirty  =      7.9 : 1.0                     get = True            Clean : Dirty  =      6.2 : 1.0                     not = True            Clean : Dirty  =      6.2 : 1.0               something = True            Clean : Dirty  =      6.2 : 1.0                    this = True            Clean : Dirty  =      6.2 : 1.0                      by = True            Clean : Dirty  =      6.2 : 1.0                   would = True            Clean : Dirty  =      6.2 : 1.0                   never = True            Clean : Dirty  =      6.2 : 1.0                     off = True            Dirty : Clean  =      6.1 : 1.0                   being = True            Clean : Dirty  =      5.4 : 1.0                     did = True            Clean : Dirty  =      5.4 : 1.0                    feel = True            Clean : Dirty  =      5.2 : 1.0                       . = None            Dirty : Clean  =      5.2 : 1.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Perkins</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-822</link>
		<dc:creator>Jacob Perkins</dc:creator>
		<pubDate>Sun, 03 Apr 2011 14:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-822</guid>
		<description>So what I think is going on is that words with None have been seen in one of the categories, but not the other, and so not seeing them becomes an indicator of the category to choose. For example, &quot;really = None  pos : neg = 3.7 : 1.0&quot; would mean that if &quot;really&quot; is not in a featureset, it&#039;s more likely to be positive (since the classifier only saw it in negative training examples).</description>
		<content:encoded><![CDATA[<p>So what I think is going on is that words with None have been seen in one of the categories, but not the other, and so not seeing them becomes an indicator of the category to choose. For example, &#8220;really = None  pos : neg = 3.7 : 1.0&#8243; would mean that if &#8220;really&#8221; is not in a featureset, it&#8217;s more likely to be positive (since the classifier only saw it in negative training examples).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-821</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Sat, 02 Apr 2011 19:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-821</guid>
		<description>Wow, what a quick response, Jacob! Thanks!

1) Yes, it&#039;s pretty simple. Just reduce a lot your training and test sets. In the classifier shown here (http://streamhacker.com/2010/05/10/text-classification-sentiment-analysis-naive-bayes-classifier/) just add these below line #9.

negids = negids[:10]
posids = posids[:10]

We&#039;re reducing our sets to 10 files for each label. Obviously this is not what we want in a real environment and this doesn&#039;t happen by training a relatively large corpus, but it just caught my attention to have &#039;None&#039; values for words that appear both in the training and test sets. Shouldn&#039;t all be True?

2) Great! I have to make a similar implementation using the Spanish language so it&#039;s time for me to compile a neutral corpus :)</description>
		<content:encoded><![CDATA[<p>Wow, what a quick response, Jacob! Thanks!</p>
<p>1) Yes, it&#8217;s pretty simple. Just reduce a lot your training and test sets. In the classifier shown here (<a href="http://streamhacker.com/2010/05/10/text-classification-sentiment-analysis-naive-bayes-classifier/" rel="nofollow">http://streamhacker.com/2010/05/10/text-classification-sentiment-analysis-naive-bayes-classifier/</a>) just add these below line #9.</p>
<p>negids = negids[:10]<br />
posids = posids[:10]</p>
<p>We&#8217;re reducing our sets to 10 files for each label. Obviously this is not what we want in a real environment and this doesn&#8217;t happen by training a relatively large corpus, but it just caught my attention to have &#8216;None&#8217; values for words that appear both in the training and test sets. Shouldn&#8217;t all be True?</p>
<p>2) Great! I have to make a similar implementation using the Spanish language so it&#8217;s time for me to compile a neutral corpus <img src='http://streamhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Perkins</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-820</link>
		<dc:creator>Jacob Perkins</dc:creator>
		<pubDate>Sat, 02 Apr 2011 16:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-820</guid>
		<description>Hi Sam,

1) I haven&#039;t seen None before, but it doesn&#039;t sound it should be there. Could you post the output, and maybe the code you use to train?

2) Exactly, and I outlined the method in http://streamhacker.com/2011/01/05/hierarchical-classification/</description>
		<content:encoded><![CDATA[<p>Hi Sam,</p>
<p>1) I haven&#8217;t seen None before, but it doesn&#8217;t sound it should be there. Could you post the output, and maybe the code you use to train?</p>
<p>2) Exactly, and I outlined the method in <a href="http://streamhacker.com/2011/01/05/hierarchical-classification/" rel="nofollow">http://streamhacker.com/2011/01/05/hierarchical-classification/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-819</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Sat, 02 Apr 2011 16:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-819</guid>
		<description>Hi Jacob! Thank you for your brilliant tutorials, they are really helpful =)
I have couple of questions. 

1) When training the classifier with smaller corpus sometimes the most informative features function shows words with the value &#039;None&#039;. According to NLTK&#039;s documentation: &quot;The feature value &#039;None&#039; is reserved for unseen feature values&quot; but using your example I get None values for words which are in both training and test sets. Why? I don&#039;t get it.

2) To implement neutrality you just used another classifier with the subjectivity dataset, right?

Thanks in advance!!</description>
		<content:encoded><![CDATA[<p>Hi Jacob! Thank you for your brilliant tutorials, they are really helpful =)<br />
I have couple of questions. </p>
<p>1) When training the classifier with smaller corpus sometimes the most informative features function shows words with the value &#8216;None&#8217;. According to NLTK&#8217;s documentation: &#8220;The feature value &#8216;None&#8217; is reserved for unseen feature values&#8221; but using your example I get None values for words which are in both training and test sets. Why? I don&#8217;t get it.</p>
<p>2) To implement neutrality you just used another classifier with the subjectivity dataset, right?</p>
<p>Thanks in advance!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Perkins</title>
		<link>http://streamhacker.com/2010/05/17/text-classification-sentiment-analysis-precision-recall/comment-page-1/#comment-792</link>
		<dc:creator>Jacob Perkins</dc:creator>
		<pubDate>Fri, 28 Jan 2011 14:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://streamhacker.com/?p=1201#comment-792</guid>
		<description>Thanks. What libraries are you thinking of? I just use NLTK to train objects using my tools at http://github.com/japerk/nltk-trainer.</description>
		<content:encoded><![CDATA[<p>Thanks. What libraries are you thinking of? I just use NLTK to train objects using my tools at <a href="http://github.com/japerk/nltk-trainer" rel="nofollow">http://github.com/japerk/nltk-trainer</a>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

