{"id":22537868,"url":"https://github.com/khaledashrafh/k-means-clustering","last_synced_at":"2025-03-28T06:42:37.147Z","repository":{"id":85810119,"uuid":"535214137","full_name":"KhaledAshrafH/K-Means-Clustering","owner":"KhaledAshrafH","description":"This program implements the K-means clustering algorithm using OpenMP APIs. The K-means algorithm is a popular method of vector quantization that aims to partition n observations into k clusters. Each observation is assigned to the cluster with the nearest mean, serving as a prototype of the cluster.","archived":false,"fork":false,"pushed_at":"2023-08-23T13:59:25.000Z","size":57,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T07:28:17.894Z","etag":null,"topics":["euclidean-distances","gcc-complier","high-performance-computing","k-means-algorithm","k-means-clustering","open-mp","openmp","parallel-processing"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KhaledAshrafH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-11T06:47:11.000Z","updated_at":"2024-05-23T21:43:04.000Z","dependencies_parsed_at":"2025-02-02T07:37:05.677Z","dependency_job_id":null,"html_url":"https://github.com/KhaledAshrafH/K-Means-Clustering","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledAshrafH%2FK-Means-Clustering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledAshrafH%2FK-Means-Clustering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledAshrafH%2FK-Means-Clustering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledAshrafH%2FK-Means-Clustering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KhaledAshrafH","download_url":"https://codeload.github.com/KhaledAshrafH/K-Means-Clustering/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984558,"owners_count":20704794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["euclidean-distances","gcc-complier","high-performance-computing","k-means-algorithm","k-means-clustering","open-mp","openmp","parallel-processing"],"created_at":"2024-12-07T11:09:02.767Z","updated_at":"2025-03-28T06:42:37.141Z","avatar_url":"https://github.com/KhaledAshrafH.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K-Means Clustering Algorithm\n\nThis program implements the K-means clustering algorithm using OpenMP APIs. The K-means algorithm is a popular method of vector quantization that aims to partition n observations into k clusters. Each observation is assigned to the cluster with the nearest mean, serving as a prototype of the cluster.\n\n## Application and Use Cases\n\nThe K-means algorithm finds applications in various domains, including:\n\n- **Market Segmentation**: Identifying distinct groups of customers based on their purchasing behavior and preferences.\n- **Document Clustering**: Grouping similar documents together based on their content to aid in information retrieval and text mining.\n- **Image Segmentation**: Dividing an image into meaningful regions or objects based on color, texture, or other visual features.\n- **Image Compression**: Reducing the size of an image by representing it using a smaller number of cluster centroids.\n\n## Algorithm Overview\n\nThe K-means algorithm follows these steps:\n\n1. **Specify the number of clusters, K**: Determine the desired number of clusters to partition the data.\n2. **Initialize centroids**: Randomly select K data points as the initial cluster centroids.\n3. **Iterate until convergence**:\n   - **Assign data points to clusters**: Calculate the distance between each data point and the cluster centroids. Assign each data point to the cluster with the closest centroid.\n   - **Update cluster centroids**: Recalculate the centroids by taking the average of all data points assigned to each cluster.\n   - **Check for convergence**: Repeat the above steps until the centroids no longer change significantly or a maximum number of iterations is reached.\n\n## Distance Calculation\n\nThe Euclidean distance formula is used to calculate the distance between a data point and its closest centroid. Given two points (x1, y1) and (x2, y2), the Euclidean distance is computed as:\n```\ndistance = sqrt((x1 - x2)^2 + (y1 - y2)^2)\n```\n\n## Requirements\n\nTo run the program, the following requirements should be met:\n\n1. **Known number of data points**: The number of data points to be clustered should be known in advance.\n2. **Data points in 2 dimensions**: The data points should be represented as (x, y) coordinates in a 2-dimensional space.\n3. **OpenMP APIs only**: The program should use only OpenMP APIs for parallel computing and not MPI APIs.\n4. **Read data points from a file**: The program should read the data points from a file named \"points.txt\" within the C script. The format of the file should have each data point on a separate line.\n5. **Program output**: The program should display the clusters and their corresponding data points in the following format:\n```\n  Cluster 1:\n  (x1, y1)\n  (x2, y2)\n  ...\n```\n\n6. **Number of threads**: The number of threads used should be equal to the number of clusters specified when running the program.\n7. **Stopping criteria**: The program should allow flexibility in choosing the maximum number of iterations or a threshold for the centroid difference error to determine convergence.\n\n## Usage\n\nFollow these steps to use the program:\n\n1. **Compile the program**: Use a C compiler that supports OpenMP to compile the program.\n2. **Prepare the data file**: Create a file named \"points.txt\" and populate it with the data points to be clustered. Each data point should be on a separate line, with the x and y coordinates separated by a space or comma.\n3. **Run the program**: Execute the compiled program.\n4. **Observe the output**: The program will display the clusters and their corresponding data points in the console.\n\nNote: Ensure that the number of clusters specified when running the program matches the desired number of clusters for partitioning the data.\n\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.\n\n\n## Authors\n\n- [Khaled Ashraf Hanafy Mahmoud - 20190186](https://github.com/KhaledAshrafH).\n- [Ahmed Sayed Hassan Youssef - 20190034](https://github.com/AhmedSayed117).\n- [Samah Moustafa Hussien Mahmoud - 20190248](https://github.com/Samah-20190248).\n\n## License\n\nThis program is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledashrafh%2Fk-means-clustering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhaledashrafh%2Fk-means-clustering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledashrafh%2Fk-means-clustering/lists"}