Cosine similarity between item descriptions using scikit-learn
<p>I am using python 2.7 and scikit-learn to find cosine similarity between item descriptions.</p>

<p>A have a <code>df</code>, for example: </p>

<pre><code>items    description

1fgg     abcd ty
2hhj     abc r 
3jkl     r df
</code></pre>

<p>I did following procedures: </p>

<p>1) tokenizing and stemming each <code>description</code></p>

<p>2) transform the corpus into vector space using <code>tf-idf</code></p>

<p>3) calculated <code>cosine distance</code> between each description text as a measure of similarity. <code>distance = 1 - cosinesimilarity(tfidf_matrix)</code></p>

<p>My goal is to have a similarity matrix of  <code>items</code> like this and answer the question like: "What is the similarity between the items <code>1ffg</code> and <code>2hhj</code> :</p>

<pre><code>        1fgg    2hhj    3jkl
1ffg    1.0     0.8     0.1
2hhj    0.8     1.0     0.0
3jkl    0.1     0.0     1.0 
</code></pre>

<p>How to get this result? Thank you for your time.</p>