topic classifier, take 3

Thomas Michael Hagen <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <[email protected]>
here's my third attempt at a newspaper article topic classifier (19
categories plus uncertain and out):

:try-to-classify: (:article:)
{
    {
	isolate (:stats:)
	classify <osbf microgroom> [:article:] \
		(bus.cfc cli.cfc con.cfc cul.cfc dom.cfc \
		eco.cfc edu.cfc ene.cfc ent.cfc env.cfc \
		for.cfc hea.cfc loc.cfc pol.cfc sci.cfc \
		spo.cfc tec.cfc tra.cfc wor.cfc | unc.cfc out.cfc) (:stats:)
	match (:: :class-conc:) [:stats:] /(...)\.cfc/
	{ #classify succeeded, checking pR:
	    match (:: :pR:) [:stats:] /Best match.*: (.*)  \nTotal/
	    output /pR::*:pR:. /
	    eval /:@::*:pR: > 30:/ #play around with this number
	    output /Classify succeeded as ':*:class-conc:'\n/
	    return
	} #pR wasn't high enough; asking the user for input:
	isolate (:conc-file:) /:*:class-conc:.cfc/
	isolate (:interaction:) /:*:class-conc::*:article::*:stats:/
	call /:interact:/ [:*:interaction:] #asking the user for the right category
	isolate (:user-feedback-conc-file:) /:*:user-feedback:.cfc/
	isolate (:count:) /12/
	{ # entering the training loop
	    learn <osbf microgroom> (:*:user-feedback-conc-file:) [:article:]
	    output /Learned as :*:user-feedback-conc-file:\n/
	    #reclassifying to check improvement:
	    isolate (:stats2:)
	    classify <osbf microgroom> [:article:]	\
		    (bus.cfc cli.cfc con.cfc cul.cfc dom.cfc \
		    eco.cfc edu.cfc ene.cfc ent.cfc env.cfc \
		    for.cfc hea.cfc loc.cfc pol.cfc sci.cfc \
		    spo.cfc tec.cfc tra.cfc wor.cfc | unc.cfc out.cfc) (:stats2:)
	    isolate (:pR2:)
	    match (:: :pR2:) [:stats2:] /Best match.*: (.*)  \nTotal/
	    isolate (:improvement:)
	    eval (:improvement:) /:@:(:*:pR2: - :*:pR:):/
	    output /imp::*:improvement:\n/
	    {
		eval /:@::*:improvement: > 3:/
		eval /:@::*:pR2: > 10:/ #play around with this number too
		output /Improvement high enough, and new threshold met; NO further
action taken\n/
		return
	    } # imp wasn't high enough, and new threshold wasn't met
	    isolate (:refute-args:) /:*:user-feedback-conc-file::*:article:/
	    #call /:refute:/ [:*:refute-args:] #this refutes the article from
ALL the other categories
	    eval (:count:) /:@::*:count: - 1:/
	    output /decremented::*:count:\n/
	    eval /:@::*:count: > 0:/
	    liaf
	    output /Improvement never increased enough\n/
	} #exiting the loop because pR never improved enough
    } # try-to-classify failed (category is unc or out)
    # my ad-hoc learning function (simply looks at the url to find keywords):
    call /:try-to-learn:/ [:*:article:]
    { # did try-to-learn fail?:
	match [:learn-conc:] /unc/
	output /Could not confidently classify the piece\n/
	return
    } # try-to-learn succeeded
    output /Never succeeded in confidently classifying the piece as
':*:user-feedback:', but Try-To-Learn succeeded as ':*:learn-conc:'
after Try-To-Classify FAILED as ':*:class-conc:'\n/ #this means that
the program trusts the newspapers' urls more than the user input. hm.
    return
}

apart from this, i am seeing, even after having run try-to-learn for
quite a while, that try-to-classify 'succeeds' very confidently in
classifying everything as technology, even though i can clearly see
that it belongs to sports.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.