Package: clustviz
ClustViz2D Clustering Algorithms VisualizationCheck outClustVizGUI, too!The aim ofClustVizis to visualize every step of each clustering algorithm, in the case of 2D input data.The following algorithms have been examined:OPTICSDBSCANHDBSCANSPECTRAL CLUSTERINGHIERARCHICAL AGGLOMERATIVE CLUSTERINGsingle linkagecomplete linkageaverage linkageWard's methodCUREBIRCHPAMCLARACLARANSCHAMELEONCHAMELEON2DENCLUEInstructionsDocumentation:click hereInstall withpipinstallclustvizTo run BIRCH algorithm, the open source visualization software Graphviz is required.
Install Graphviz from the official webpage (https://graphviz.gitlab.io/download/) or using HomeBrew, then
modify the PATH variable as follows (replace the string according to the path where you installed Graphviz):importos# on Windows usuallyos.environ["PATH"]+=os.pathsep+'C:/Program Files (x86)/Graphviz2.38/bin'# on MacOS usuallyos.environ["PATH"]+=os.pathsep+'/usr/local/bin'To run CHAMELEON and CHAMELEON2 algorithms, theMETISlibrary is required.
To install it on MacOS, execute the following commands (partially taken fromhere):# download the file using wget (do it from the website if you prefer)wgethttp://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz# uncompress itgunzipmetis-5.1.0.tar.gz# untar ittar-xvfmetis-5.1.0.tar# remove the tarrmmetis-5.1.0.tar# go inside the foldercdmetis-5.1.0# install it using makemakeconfigshared=1makeinstall# export the dllexportMETIS_DLL=/usr/local/lib/libmetis.dylibTo install METIS on Windows, go toconda-metisand follow the instructions.UsageLet's see a basic example using OPTICS:fromclustviz.opticsimportOPTICS,plot_clustfromsklearn.datasetsimportmake_blobs# create a random datasetX,y=make_blobs(n_samples=30,centers=4,n_features=2,cluster_std=1.8,random_state=42)# perform OPTICS algorithm, with plotting enabledClustDist,CoreDist=OPTICS(X,eps=2,minPTS=3,plot=True,plot_reach=True)# plot the final clustersplot_clust(X,ClustDist,CoreDist,eps=2,eps_db=1.9)For many other examples, take a look at the detailedclustviz_examplenotebook.Repository structureThe folderdata/DOCUMENTScontains all the official papers, powerpoint presentations and other PDFs regarding all the algorithms involved and clustering in general.The folderclustvizcontains the scripts necessary to run the clustering algorithms.The notebookdata/clustviz_example.ipynblets the user run every algorithm on 2D datasets; it contains a subsection for every algorithm, with the necessary modules and functions imported and some commented lines of code which can be uncommented to run the algorithms.The folderdocscontains the necessary files to build the documentation using Sphinx and ReadTheDocs.The foldertestscontains pytest tests.Credits for some algorithmsI did not start to write the scripts for each algorithm from scratch; in some cases I modified some Python libraries, in other cases I took some publicly available GitHub repositories and modified the scripts contained there. The following list provides all the sources used when I did not write all the code by myself:HDBSCANhttps://hdbscan.readthedocs.io/en/latest/SPECTRAL CLUSTERINGhttp://dx.doi.org/10.1007/s11222-007-9033-zBIRCHhttps://github.com/annoviko/pyclustering/blob/master/pyclustering/cluster/birch.pyPAMhttps://github.com/SachinKalsi/kmedoids/blob/master/KMedoids.pyCLARAhttps://github.com/akalino/Clustering/blob/master/clara.pyCLARANShttps://github.com/annoviko/pyclustering/blob/master/pyclustering/cluster/clarans.pyCHAMELEONhttps://github.com/Moonpuck/chameleon_clusterThe other algorithms have been implemented from scratch following the relative papers. Thanks to Darius (https://github.com/dariomonici),
the GUI Meister, for the help with PyQt5, used forClustVizGUI.Possible improvementsadd more clustering algorithmscomment every code block and improve code qualitypymetis doesnt work on Windows, but could be an option for MacOSadd highlights to docstrings using ``show aliases typehints using Sphinx (open issue)TravisCI pathif Travis CI doesn't trigger, it is probably because.travis.ymlisn't properly formatted. Useyamllintto correct itadd package updatefor the deployment phase: brew install ruby, brew install travisadded empty conftest.py in clustviz folder for tests in windows version