Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Clustering of all questions on gutefrage.net with Elasticsearch

Clustering of all questions on gutefrage.net with Elasticsearch

mstockerl

July 28, 2015
Tweet

Other Decks in Programming

Transcript

  1. The big picture: • Clustering algorithm: DBSCAN • NN-Search: Elasticsearch’s

    More-like-this Query • Metrics: Elasticsearch’s Aggregations 3
  2. 5 DBSCAN • Density-based clustering algorithm • Can find arbitrary

    cluster shapes • Does not need cluster count • Two parameters: • Epsilon: max distance to neighbors • minPoints: minimal number of points to form a cluster • Nice visualization: http://www.naftaliharris.com/blog/visualizing-dbscan-clustering/
  3. 23 More-Like-This Query • Find documents that are „like“ the

    query document • Approximative nearest neighbor search • Use only relevant terms in query document • Minimum percentage must match • A lot of parameter { "more_like_this" : { "fields" : ["title", "body"], "like_text" : "Warum muss man bei einer Zugfahrt als Erwachsener mehr zahlen als ein Kind?", "min_term_freq" : 1, "max_query_terms" : 12 } }
  4. 24 [warum, muss, man, bei, einer, zugfahrt, als, ewachsener, mehr,

    zahlen, als, ein, kind] Min Term Frequency: 1 (Default: 2) • Selects all terms for the query, which occur more often than `min_term_freq`
  5. 25 Max Doc Frequency: 50 000 (Default: Unbounded) • Ignores

    all terms, which occur too often in the index • One of the crucial parameters to tune! [warum, muss, man, bei, einer, zugfahrt, als, ewachsener, mehr, zahlen, als, ein, kind]
  6. 26 Max Query Terms: 12 (Default: 25) • Maximum number

    of terms in the query • Ordered by document frequency • For us: The fewer yielded better results [zugfahrt, ewachsener, zahlen, kind] [zugfahrt, ewachsener, kind, zahlen]
  7. 27 Minimum Should Match: 51% (Default: 30%) • How many

    terms must match • We want to find really `similar` documents [zugfahrt, ewachsener, kind, zahlen]
  8. 29 Score of MLT is not symmetric Query: sommerhitze getränk

    erfrischung Document: erfrischung unterwegs tipps not a neighbor here
  9. 30 Score of MLT is not symmetric Document: sommerhitze getränk

    erfrischung Query: erfrischung unterwegs it is a neighbor here
  10. 31 Min Score: 0.3 (Default: 0.0) • Minimal score of

    a candidate document to be considered for the result • We want to find really `similar` documents
  11. 32 Clustering Flow 1. Build Similarity Matrix with MLT -

    Query 2. Run DBSCAN 3. Append Child-Documents containing cluster Info 4. Aggregate information for visualization
  12. 34 Tags of the biggest cluster Profil/Profilbild tv-serie beauty Fifa

    jailbreak Apple Sprüche Whatsapp löschen Geschenk Studium Ernährung Smartphones abnehmen Langeweile Beruf Geschichte
  13. 35 Cluster: Profil • Kann man bei Facebook einstellen, dass

    ein Freund nicht alles von meinen Profil sehen kann? • Wie kann ich bei Soundcloud mein Profilbild ändern? • Wie kann ich mein Profilbild auf gutefrage.net ändern? • Wie ändert man bei Hotmail seine Sprache?
  14. 36 Cluster: Studium • Kann man Medizin mit Fachabi Sozialpädagogik

    studieren? • Wie kann man Allgemeinmedizin ohne benötigten Numerus Clausus studieren? • Wie schwer ist das Informatik-Studium und wie sehen die Berufschancen nach dem Studium aus? • Kann ich Architektur und Innenarchitektur gleichzeitig studieren?
  15. 37 Cluster: Mickie Krause • Kennt jemand dieses Lied von

    Mickie Krause? • Was ist der Originalsong des Liedes "Extreme" von Mickie Krause? • Welche Musikrichtung ist Mickie Krause? • Was kann man gegen krause Haare tun?
  16. 38 Cluster sizes 2 % 13 % 27 % 58

    % <= 4 <= 10 <= 50 > 50
  17. 39

  18. 40 Cluster sizes 2 % 13 % 27 % 58

    % <= 4 <= 10 <= 50 > 50
  19. 41 Cluster size <= 5 must not occur using DBSCAN!

    • Elasticsearch MLT-Query (Score): • is not symmetric • does not guarantee that triangle inequality holds • searches only in subspaces!
  20. 42 Example (max query terms: 2): [welches, getränk, bringt, im,

    moment, bei, dieser, sommerhitze, die, ultimative, erfrischung] [sommerhitze, erfrischung, getränk, ultimative] Will find: • Beste Erfrischung für unterwegs, welche Tipps und Tricks kennt ihr? But not: • Ist es bei heißem Wetter besser kalte oder warme Getränke zu trinken?
  21. 48 Learnings 1. Run Clustering not on Production System ;)

    2. Very fast (approximate) results with Elasticsearch 3. Think about your distance metric 4. Min score for clustering can be dangerous