<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rik Nijessen on Medium]]></title>
        <description><![CDATA[Stories by Rik Nijessen on Medium]]></description>
        <link>https://medium.com/@riknijessen?source=rss-c6f352501de2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bbtDTC7MEaddFVXeSqwlYw.jpeg</url>
            <title>Stories by Rik Nijessen on Medium</title>
            <link>https://medium.com/@riknijessen?source=rss-c6f352501de2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:41:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@riknijessen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automatic Topic Clustering Using Doc2Vec]]></title>
            <link>https://medium.com/data-science/automatic-topic-clustering-using-doc2vec-e1cea88449c?source=rss-c6f352501de2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1cea88449c</guid>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[doc2vec]]></category>
            <category><![CDATA[topic-modeling]]></category>
            <dc:creator><![CDATA[Rik Nijessen]]></dc:creator>
            <pubDate>Mon, 15 May 2017 16:29:04 GMT</pubDate>
            <atom:updated>2017-05-21T16:06:54.731Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“Imagine you are a manager of a big company and want to keep your customer data save. This means you have to be up to date with the current trends and threats in cybersecurity. However, the cybersecurity scene is going very fast, so staying up to date is hard.”.</em></p><p>This was the start of the pitch we did at the <a href="https://hackdelft.com/">HackDelft</a> hackathon last weekend. The goal of our project was to create a new way to present cybersecurity trends to managers. In this blog I will explain how we attacked this problem and which technology we used.</p><p>Currently, KPMG and Owlin (the sponsors of our case) have a <a href="https://cyber.kpmg.nl/#trends/">portal</a> which presents articles about cybersecurity topics ranked by importance. This is all nice, but to be able to understand the trends, you still have to go through a lot of articles. We therefore wanted to build a portal which could cluster recent articles into topics with a nice summary of that topic next to it. This way, you can see what is currently important at a glance.</p><p><a href="https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation">LDA</a> is a much used algorithm for topic discovery. However, in my experience LDA can spit out some hard to understand topic clusters. Another approach could be clustering based on <a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf">tf-idf</a> vectors, but because Word2Vec and Doc2Vec have shown to generate awesome results in the Natural Language Processing scene, we decided to try those, just for fun.</p><p>Word2Vec is an unsupervised algorithm developed by Google that tries to learn meaningful vector representations of words from a dataset of text. It does so based on the <em>distributional hypothesis,</em> which states that words that appear in the same context, probably have similar meaning.<br>You can do cool things with these word vectors, for example doing the following vector calculation: <em>King - Man + Woman</em> will give you a vector that is very close to the word vector of Queen. If you want to try these yourself, you can do so <a href="http://bionlp-www.utu.fi/wv_demo/">here</a>. Also, Google has made available a pretrained Word2Vec model <a href="https://drive.google.com/file/d/0B7XkCwpI5KDYNlNUTTlSS21pQmM/edit?usp=sharing">here</a>. Doc2Vec (also called Paragraph Vectors) is an extension of Word2Vec, which learns the meaning of documents instead of words.</p><p><a href="https://arxiv.org/pdf/1607.05368.pdf">This paper</a> shows that by training Word2Vec and Doc2Vec together, the vector of documents are placed near words describing the topic of those documents. This gave us the following idea: <em>what if we cluster documents, take the mean of those clusters and look at the words similar to the vector representation of those means? </em>Maybe this will give us some words describing the clusters.</p><p>We started by training Doc2Vec and Word2Vec together on the dataset, delivered by KPMG and Owlin, using the <a href="https://radimrehurek.com/gensim/">Gensim</a> Python library. This dataset contained around 100k news articles from the last 200 days. Because it contained a lot of duplicates, we had to remove those first. Furthermore, we also removed special characters and URLs and lowercased everything before training to remove noise.</p><p>After training we took news articles from the last 3 days and retrieved the vector representation of those using the trained Doc2Vec model. We then used the K-means algorithm (from the <a href="http://www.nltk.org/">nltk</a> python library) to cluster the vectors. Because similarity is usually measured using the <em>cosine distance, </em>we used cosine distance instead of euclidian distance.</p><p>This gave us some great results. Some examples of the clusters it generated are:</p><ul><li>Trump firing the FBI Director James Comey</li><li>The release of Samsung’s Z4 phone</li><li>The spreading ransomware WannaCry</li><li>Wannacry hitting a lot of hospitals</li><li>Microsoft releasing a patch for Windows XP</li></ul><p>What was interesting to see is that it placed articles about a keylogger in HP laptops in a cluster with articles about the release of Samsung’s smartphone. Maybe it learned that both companies are developing consumer hardware? Furthermore it produced multiple clusters about <a href="https://en.wikipedia.org/wiki/WannaCry_ransomware_attack"><em>WannaCry</em></a><em>: </em>one about it spreading, one about it hitting a lot of hospitals and one about Microsoft releasing a patch for it for Windows XP.</p><p>Unfortunately, our idea about using Word2Vec for summarising the clusters didn’t work out. It produced words which did not summarise the clusters at all. Instead, we tried a much simpler approach: we took all titles per cluster, removed stopwords and digits and counted the number of occurrences of each word. We then selected the 5 most occurring words per cluster as keywords for that cluster. This approach worked surprisingly well. <br>Some examples are:</p><ul><li>samsung, tizen, android, hp, z4</li><li>trump, comey, fbi, wikileaks, president</li><li>ransomware, attack, malware, wannacry, attacks</li><li>ransomware, attacks, countries, hospitals, hit</li><li>market, security, report, global, research</li></ul><p>In the end we have created a model that was able to cluster similar articles using Doc2Vec and generate keywords describing the content of those clusters in under 24 hours. We have released our code on Github <a href="https://github.com/olafmaas/hackdelft">here</a>, so you can play with it yourself. The clusters it generated during the weekend can be found in <a href="https://raw.githubusercontent.com/olafmaas/hackdelft/master/hackdelft/doc2vec/output.json">this</a> JSON file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1cea88449c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/automatic-topic-clustering-using-doc2vec-e1cea88449c">Automatic Topic Clustering Using Doc2Vec</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>