Presented by Isabel Drost-Fromm, Software Developer, Apache Software Foundation/Nokia Gate 5 GmbH at Lucene/Solr Revolution 2013 Dublin
Text classification automates the task of filing documents into pre-defined categories based on a set of example documents. The first step in automating classification is to transform the documents to feature vectors. Though this step is highly domain specific Apache Mahout provides you with a lot of easy to use tooling to help you get started, most of which relies heavily on Apache Lucene for analysis, tokenisation and filtering. This session shows how to use facetting to quickly get an understanding of the fields in your document. It will walk you through the steps necessary to convert your text documents into feature vectors that Mahout classifiers can use including a few anecdotes on drafting domain specific features.
Configure
2. Isabel Drost-Fromm
Software Engineer at Nokia Maps*
Member of the Apache Software Foundation
Co-Founder of Berlin Buzzwords and
Berlin Apache Hadoop GetTogether
Co-founder of Apache Mahout
*We are hiring, talk to me or mail careers@here.com
36. Binary bag of words
●
Imagine a n-dimensional space.
●
Each dimension = one possible word in texts.
●
Entry in vector is one, if word occurs in text.
●
Problem:
–
bi , j =
{
1 ∀ x i ∈d j
0 else
}
How to know all possible terms in unknown text?
37. Term Frequency
●
Imagine a n-dimensional space.
●
Each dimension = one possible word in texts.
●
Entry in vector equal to the words frequency.
bi , j =ni , j
●
Problem:
–
Common words dominate vectors.
38. TF with stop wording
●
Imagine a n-dimensional space.
●
Each dimension = one possible word in texts.
●
Filter stopwords.
●
Entry in vector equal to the words frequency.
●
Problem:
–
bi , j =ni , j
Common and uncommon words with same weight.
39. TF- IDF
●
Imagine a n-dimensional space.
●
Each dimension = one possible word in texts.
●
Filter stopwords.
●
Entry in vector equal to the weighted frequency.
●
Problem:
–
bi , j =ni , j ×log
∣D∣
∣{ d : t i ∈d }∣
Long texts get larger values.
40. Hashed feature vectors
●
Imagine a n-dimensional space.
●
Each word in texts = hashed to one dimension.
●
Entry in vector set to one, if word hashed to it.
50. Performance
●
Use same data for training and testing.
●
Problem:
–
Highly optimistic.
–
Model generalization unknown.
51. Performance
●
Use same data for training and testing.
DON'T
●
Problem:
–
Highly optimistic.
–
Model generalization unknown.
52. Performance
●
Use just a fraction for training.
●
Set some data aside for testing.
●
Problems:
–
Pessimistic predictor: Not all data used for training.
–
Result may depend on which data was set aside.
53. Performance
●
Partition your data into n fractions.
●
Each fraction set aside for testing in turn.
●
Problem:
–
Still a pessimistic predictor.
54. Performance
●
Use just a fraction for training.
●
Set some data aside for tuning and testing.
●
Problems:
–
Highly optimistic.
–
Parameters manually tuned to testing data.
55. Performance
●
Use just a fraction for training.
●
Set some data aside for tuning and testing.
DON'T
●
Problems:
–
Highly optimistic.
–
Parameters manually tuned to testing data.
56. Performance
●
Use just a fraction for training.
●
Set some data aside for tuning.
●
Set another set of data aside for testing.
●
Problems:
–
Pretty pessimistic as not all data is used.
–
May depend on which data was set aside.
73. Apache Hadoop-ready
Recommendations/
Collaborative filtering
kNN and matrix factorization
based Collaborative filtering
Classification/
Naïve Bayes, random forest
Frequent item sets/
(P)FPGrowth
Classification/
Logistic Regression/ SGD
Clustering/ Mean shift, k-Means,
Canopy, Dirichlet Process,
Co-Location search
Sequence learning/
HMM
Math libs/ Mahout collections
LDA
74. Libraries to have a look at:
Vowpal Wabbit Mallet
LibSvm
LibLinear
Libfm
Incanter
GraphLab
Skikits learn
Where to get more information:
“Mahout in Action” - Manning
“Taming Text” - Manning
“Machine Learning” - Andrew Ng
https://cwiki.apache.org/confluence/dis
play/MAHOUT/Books+Tutorials+and+T
alks
https://cwiki.apache.org/confluence/dis
play/MAHOUT/Reference+Reading
Image by pareeerica
http://www.flickr.com/photos/pareeerica/3711741298/
Frameworks worth mentioning:
Apache Mahout
Matlab/ Otave
Shogun
RapidI
Apache Giraph
R
Weka
MyMedialight
Get your hands dirty:
http://kaggle.com
https://cwiki.apache.org/confluence/dis
play/MAHOUT/Collections
Where to meet these people:
RecSys
NIPS
KDD
PKDD
ApacheCon
O'Reilly Strata
ICML
ECML
WSDM
JMLR
Berlin Buzzwords
75. Get started today with the right tools.
January 8, 2008 by dreizehn28
http://www.flickr.com/photos/1328/2176949559
76. Discuss ideas and problems online.
November 16, 2005 [phil h]
http://www.flickr.com/photos/hi-phi/64055296
77. Images taken at Berlin Buzzwords 2011/12/13 by
Philipp Kaden. See you there end of May 2014.
Discuss ideas and problems in person.
80. BerlinBuzzwords.de – End of May 2014 in Berlin/ Germany.
http://
Online – user/dev@mahout.apache.org, java-user@lucene.apache.org,
dev@lucene.apache.org
Interest in solving hard problems.
Being part of lively community.
Engineering best practices.
Bug reports, patches, features.
Documentation, code, examples.
Image by: Patrick McEvoy