mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Clegg <>
Subject Calculating cosine similarity for vectors extracted from Lucene
Date Sun, 12 Jun 2011 00:29:37 GMT

I extracted the contents of a Lucene index like so:

bin/mahout lucene.vector --dir /path/to/index/ --output
/path/to/vectors --dictOut /path/to/dict --field text --idField id
--weight TFIDF --maxDFPercent 90 --minDF 10

And then I tried to get the cosine similarity between the docs like so:

bin/mahout rowsimilarity -i /path/to/vectors -o /path/to/25nn-matrix

But I got this:

java.lang.ClassCastException: cannot
be cast to
	at org.apache.mahout.math.hadoop.similarity.RowSimilarityJob$
	at org.apache.hadoop.mapred.MapTask.runNewMapper(
	at org.apache.hadoop.mapred.LocalJobRunner$

I assume this refers to the document ID or something -- since the
actual tf.idf scores will be doubles, right? Is there an easy way to
convert these on the fly, or do I need to write something to do it?

Also, another (somewhat unrelated) question... The -r param to
rowsimilarity specifies "Number of columns in the input matrix".
What's the recommended approach when you don't know this in advance?
Just set it much higher than you'll need (as I did above)?

Many thanks from a Mahout noob!


-- |

View raw message