Giter Site home page Giter Site logo

alex-j-b / hac-text-clustering Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 7 KB

It's the HAC algorithm that Im using to sort newspaper articles by news. You can adapt it to pretty much any type of text.

Python 100.00%
clustering-algorithm text-clustering hac hierarchical-clustering kmeans kmeans-clustering kmeans-algorithm silhouette-score news newspaper

hac-text-clustering's Introduction

HAC-Text-Clustering

It is the HAC algorithm that Im using to sort newspaper articles by news. You can adapt it to pretty much any type of text.
HAC means "Hierarchical Agglomerative Clustering", it worked out better for me than KMeans.
It uses the silhouette score to find the best k.

Table of Contents

process_text.py

Tokenize and Stem data to get meaningful list of words for the clusterizer.

silhouette_best_k.py

Find the best k number of clusters based on the highest silhouette score.

main.py

Find the best k with silhouette score.
Apply AgglomerativeClustering with the best k.
Return clusters.

You might need to adapt few parameters to your type of dataset. Here are some changes that you can try :

process_text.py
Add more stopwords.
Replace or remove the stemmer.

silhouette_best_k.py
Change the Birch threshold
Change the silhouette_score metric

main.py
Change TfidfVectorizer max_df and/or min_df.
Try others AgglomerativeClustering affinity and linkage options.
Replace AgglomerativeClustering by KMeans.

Project Requirements

python 3 pip install requirements.txt (nltk, scikit_learn)

hac-text-clustering's People

Contributors

excite-world avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

shihua110

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.