{"id":20812481,"url":"https://github.com/chandkund/customer-segmentation-using-k-means-clustering","last_synced_at":"2026-04-10T04:41:19.449Z","repository":{"id":253448511,"uuid":"843535577","full_name":"chandkund/CUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING","owner":"chandkund","description":"Implemented K-Means Clustering to segment customers based on purchasing behavior, enabling targeted marketing strategies. Analyzed data, optimized clusters using the Elbow Method, and derived insights to enhance customer engagement and retention.","archived":false,"fork":false,"pushed_at":"2024-08-16T18:44:27.000Z","size":129,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T14:53:41.772Z","etag":null,"topics":["data-science","kmeans-clustering","machine-learning","matplotlib","numpy","pandas","python","seaborn","sklearn"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/chandkund.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-08-16T18:21:42.000Z","updated_at":"2024-08-16T20:23:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"a98969c4-f7e0-48f4-b2d0-a0581fa1c766","html_url":"https://github.com/chandkund/CUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING","commit_stats":null,"previous_names":["chandkund/customer-segmentation-using-k-means-clustering"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandkund%2FCUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandkund%2FCUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandkund%2FCUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandkund%2FCUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chandkund","download_url":"https://codeload.github.com/chandkund/CUSTOMER-SEGMENTATION-USING-K-MEANS-CLUSTERING/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243158972,"owners_count":20245669,"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":["data-science","kmeans-clustering","machine-learning","matplotlib","numpy","pandas","python","seaborn","sklearn"],"created_at":"2024-11-17T20:54:43.078Z","updated_at":"2025-12-27T07:32:57.687Z","avatar_url":"https://github.com/chandkund.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUSTOMER SEGMENTATION USING K-MEANS CLUSTERING\n\n## Project Overview\n\nThis project focuses on customer segmentation using the K-Means Clustering algorithm. By clustering customers based on their purchasing behaviors and demographics, businesses can tailor their marketing strategies and improve customer engagement.\n\n## Table of Contents\n\n- [Project Overview](#project-overview)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Code Explanation](#code-explanation)\n- [Model Evaluation](#model-evaluation)\n- [License](#license)\n\n## Installation\n\nTo run this project, you will need Python along with the following libraries:\n\n- `pandas`\n- `numpy`\n- `matplotlib`\n- `seaborn`\n- `scikit-learn`\n\nInstall the required packages using `pip`:\n\n    pip install pandas numpy matplotlib seaborn scikit-learn\n\nClone the repository:\n\n    git clone https://github.com/chandkund/customer-segmentation-using-k-means-clustering.git\n    cd customer-segmentation-using-k-means-clustering\n\n## Usage\n\n- Prepare the Dataset:\n  Place your dataset (e.g., `mall_customers.csv`) in the project directory or adjust the file path in the code.\n\n- Run the Code:\n  Execute the Python scripts to perform data preprocessing, clustering, and visualization.\n\n      python script.py\n\n## Code Explanation\n\n- **Import Relevant Libraries**:\n\n    ```python\n    import pandas as pd\n    import numpy as np\n    import matplotlib.pyplot as plt\n    import seaborn as sns\n    from sklearn.preprocessing import MinMaxScaler\n    from sklearn.cluster import KMeans\n    ```\n\n- **Load and Preprocess Data**:\n\n    ```python\n    raw_data = pd.read_csv(\"path/to/your/dataset.csv\")\n    df = raw_data.copy()\n    ```\n\n- **Visualize Data Before Normalization**:\n\n    ```python\n    sns.scatterplot(x='Annual Income (k$)', y='Spending Score (1-100)', data=df)\n    plt.show()\n    ```\n\n- **Normalize the Data**:\n\n    ```python\n    cols = ['Annual Income (k$)', 'Spending Score (1-100)']\n    scaled = MinMaxScaler()\n    df[cols] = pd.DataFrame(scaled.fit_transform(df[cols]), columns=cols)\n    sns.scatterplot(x='Annual Income (k$)', y='Spending Score (1-100)', data=df)\n    plt.show()\n    ```\n\n- **Determine Optimal Number of Clusters**:\n\n    ```python\n    Wcss = []\n    for i in range(1, 12):\n        kmeans = KMeans(n_clusters=i, random_state=0)\n        kmeans.fit(df[cols])\n        Wcss.append(kmeans.inertia_)\n\n    plt.plot(range(1, 12), Wcss)\n    plt.title(\"The Elbow Method\")\n    plt.xlabel(\"Number of Clusters\")\n    plt.ylabel(\"Wcss Values\")\n    plt.show()\n    ```\n\n- **Train the K-Means Model**:\n\n    ```python\n    optimal_clusters = 5\n    kmeans_model = KMeans(n_clusters=optimal_clusters, random_state=0)\n    df['cluster'] = kmeans_model.predict(df[cols])\n    ```\n\n- **Visualize Clusters**:\n\n    ```python\n    plt.scatter(df['Annual Income (k$)'], df['Spending Score (1-100)'], c=df['cluster'], cmap='rainbow')\n    plt.title(\"Clusters of Customers\")\n    plt.xlabel(\"Annual Income (k$)\")\n    plt.ylabel(\"Spending Score (1-100)\")\n    plt.show()\n    ```\n\n## Model Evaluation\n\nEvaluate the clustering results by analyzing the characteristics of each cluster and the distribution of data points within each cluster.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandkund%2Fcustomer-segmentation-using-k-means-clustering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchandkund%2Fcustomer-segmentation-using-k-means-clustering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandkund%2Fcustomer-segmentation-using-k-means-clustering/lists"}