{"id":22546294,"url":"https://github.com/camilajaviera91/clustering-first-approach","last_synced_at":"2026-04-13T22:33:40.644Z","repository":{"id":266322785,"uuid":"898023969","full_name":"CamilaJaviera91/clustering-first-approach","owner":"CamilaJaviera91","description":"This code will help to understand, in a simple way, how the clustering model works. To achieve this, we will input certain variables (strings and integers), then plot them to visualize and analyze how the values are positioned.","archived":false,"fork":false,"pushed_at":"2025-01-03T14:22:58.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T08:45:16.391Z","etag":null,"topics":["array","cluster","clustering","dictionaries","matplotlib","numpy","pandas","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CamilaJaviera91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-12-03T16:47:27.000Z","updated_at":"2025-02-17T21:11:19.000Z","dependencies_parsed_at":"2024-12-03T18:18:55.635Z","dependency_job_id":"db85728e-596c-45a5-8bb9-15dd53c0b4ef","html_url":"https://github.com/CamilaJaviera91/clustering-first-approach","commit_stats":null,"previous_names":["camilajaviera91/clustering-first-approach"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fclustering-first-approach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fclustering-first-approach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fclustering-first-approach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fclustering-first-approach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CamilaJaviera91","download_url":"https://codeload.github.com/CamilaJaviera91/clustering-first-approach/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245999321,"owners_count":20707554,"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":["array","cluster","clustering","dictionaries","matplotlib","numpy","pandas","python"],"created_at":"2024-12-07T15:06:49.714Z","updated_at":"2026-04-13T22:33:40.606Z","avatar_url":"https://github.com/CamilaJaviera91.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K-Means Clustering Project\n\nThis project demonstrates the implementation of a K-Means clustering algorithm to group data based on user-provided inputs. The clustering is visualized using a scatter plot with centroids highlighted. Below is a breakdown of the project files and instructions for use.\n\n## Files in the Project\n\n### 1. `cluster.py`\nThis script performs the K-Means clustering process, including:\n- Collecting data from the user.\n- Applying the K-Means algorithm to cluster the data.\n- Visualizing the clustering results.\n\n#### Key Functions and Features:\n- **`get_user_input`**: Prompts the user to select columns for clustering.\n- **K-Means Clustering**: Assigns data points to clusters and calculates centroids.\n- **Visualization**: Plots data points colored by cluster and displays centroids.\n\n### 2. `dataset.py`\nThis script provides the `collect_data` function to gather input data for clustering.\n\n#### Data Collection:\n- **Labels (`key1`)**: Names or labels for the data points (e.g., city names).\n- **Numeric Variables (`key2` and `key3`)**: Numeric values for clustering (e.g., sales figures).\n- Ensures all input lists have the same length before returning a structured dataset.\n\n## How to Run the Project\n\n1. **Prepare the Environment**:\n   - Install the required libraries:\n     ```bash\n     pip install pandas numpy matplotlib scikit-learn\n     ```\n\n2. **Run the Project**:\n   - Execute the `cluster.py` script to start the clustering process.\n     ```bash\n     python cluster.py\n     ```\n\n3. **Provide Inputs**:\n   - Enter labels (e.g., city names) and numeric data for clustering when prompted.\n   - Select columns for clustering from the dataset.\n\n4. **View Results**:\n   - A scatter plot will be displayed, showing clustered data points and centroids.\n   - Labels are annotated for clarity.\n\n## Example Usage\n\n### Input Example\n```plaintext\nCollecting data for cities, k2, and key3...\n--------------------------------\nEnter the name of the variable that you want to cluster: city\nEnter a city name (or type 'e' to finish): CityA\nEnter a city name (or type 'e' to finish): CityB\nEnter a city name (or type 'e' to finish): e\nEnter the name of the first variable that you want analyze: tomatoes\nEnter a tomatoes value (or type 'e' to finish): 120\nEnter a tomatoes value (or type 'e' to finish): 90\nEnter a tomatoes value (or type 'e' to finish): e\nEnter the name of the second variable that you want analyze: bread\nEnter a bread value (or type 'e' to finish): 60\nEnter a bread value (or type 'e' to finish): 70\nEnter a bread value (or type 'e' to finish): e\n```\n\n### Output\n- A scatter plot showing clusters of data points based on the provided numeric variables.\n- Centroids of the clusters highlighted with red markers.\n\n## Dependencies\n- Python 3.x\n- Libraries:\n  - `pandas`\n  - `numpy`\n  - `matplotlib`\n  - `scikit-learn`\n\n## Project Structure\n```\n.\n├── cluster.py          # Main script for clustering and visualization\n├── dataset.py          # Data collection script\n├── README.md           # Project documentation (this file)\n```\n\n## Notes\n- Ensure the data entered is consistent and numeric where required.\n- K-Means clustering assumes that data is numeric and uses Euclidean distance for clustering.\n- Modify the number of clusters (`n_clusters`) in the K-Means algorithm as needed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilajaviera91%2Fclustering-first-approach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamilajaviera91%2Fclustering-first-approach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilajaviera91%2Fclustering-first-approach/lists"}