Skip to content

arianmo477/spectral_clustring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Instruction.txt: How to Run the Spectral Clustering Application


Introduction

This application demonstrates spectral clustering on different datasets using MATLAB 2024. The code includes interactive prompts for parameter selection and visualizes the clustering results.


Steps to Run the Application

  1. Launch MATLAB 2024: Ensure you are running MATLAB version 2024 to guarantee compatibility with the code.

  2. Load the Application: Save the provided code as a .m file (e.g., SpectralClusteringApp.m). Ensure all required dataset files (Circle.csv, Spiral.csv, Sphere.csv) are in the same directory as the script.

  3. Run the Code: Open the .m file in MATLAB, then click on the Run button or type SpectralClusteringApp in the MATLAB command window.

  4. Select a Dataset: The program will prompt you to choose one of the following datasets:

    • Circle.csv
    • Spiral.csv
    • Sphere.csv
      Use the menu dialog to select your desired dataset.
  5. Set Parameters:

    • k (k-nearest neighbors): Enter the number of nearest neighbors (e.g., 10, 20, 40).
    • Laplacian Choice: Select the type of Laplacian matrix:
      • L: Standard Laplacian
      • L_norm: Normalized Laplacian
    • Number of Eigenvalues: Enter the number of eigenvalues to compute (e.g., 3, 5, etc.).
  6. View Sparsity Pattern: The adjacency matrix's sparsity pattern is displayed in a plot for verification.

  7. Eigenvalue Plot: After computing eigenvalues, the program plots them for analysis. Use this plot to identify the eigengap and determine the optimal number of clusters.

    • Tip: When prompted, enter the number of clusters based on the largest gap between consecutive eigenvalues.
  8. Clustering Results: The script performs clustering using three methods:

    • k-means
    • DBSCAN
    • Hierarchical Clustering
  9. Visualize Results: The program displays:

    • Clusters in 2D or 3D depending on the dataset.
    • Sparsity patterns of adjacency matrices.
    • Eigenvalue distributions.
  10. Evaluate Silhouette Scores: The program computes and displays silhouette scores for each clustering method. These scores indicate how well-separated the clusters are.

  11. Evaluate Adjusted Rand Index (ARI): If you select the Spiral.csv dataset, the ARI metric evaluates clustering accuracy against true labels.


Customizing the Clustering

  • You can try different values of k, eigenvalues, and the number of clusters to see their effects on the results.
  • Experiment with the DBSCAN epsilon parameter using the k-Distance graph generated by the code.

Note

  • The datasets should be properly formatted with coordinates (and labels for Spiral.csv).
  • Make sure MATLAB has the required permissions to access the datasets.

About

Computational clustering project implementing spectral clustering with Laplacian matrices, eigengap analysis, and performance evaluation using silhouette and ARI metrics.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages