{"id":18075629,"url":"https://github.com/musty-ess/shopping-prediction-ai-using-machine-learning","last_synced_at":"2026-04-12T02:35:17.961Z","repository":{"id":257933966,"uuid":"872544703","full_name":"musty-ess/Shopping-Prediction-AI-Using-Machine-Learning","owner":"musty-ess","description":"This project is an AI model designed to predict whether customers on an online shopping website will complete a purchase. It uses machine learning, specifically a k-nearest neighbors (KNN) classifier, to analyze user behavior and predict their purchasing intent.","archived":false,"fork":false,"pushed_at":"2024-10-17T21:10:00.000Z","size":252,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T17:57:14.150Z","etag":null,"topics":["ai-prediction","classification-model","k-nearest-neighbors","knn-classifier","machine-learning","online-shopping","python","scikit-learn","sensitivity-specificity","user-behavior-prediction"],"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/musty-ess.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-10-14T16:10:02.000Z","updated_at":"2024-10-17T21:10:49.000Z","dependencies_parsed_at":"2024-12-19T02:23:09.569Z","dependency_job_id":"cd786256-3cd7-4469-8901-4ef24d26b7d9","html_url":"https://github.com/musty-ess/Shopping-Prediction-AI-Using-Machine-Learning","commit_stats":null,"previous_names":["musty-ess/shopping-prediction-ai-using-machine-learning"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musty-ess%2FShopping-Prediction-AI-Using-Machine-Learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musty-ess%2FShopping-Prediction-AI-Using-Machine-Learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musty-ess%2FShopping-Prediction-AI-Using-Machine-Learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musty-ess%2FShopping-Prediction-AI-Using-Machine-Learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/musty-ess","download_url":"https://codeload.github.com/musty-ess/Shopping-Prediction-AI-Using-Machine-Learning/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393542,"owners_count":20931809,"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":["ai-prediction","classification-model","k-nearest-neighbors","knn-classifier","machine-learning","online-shopping","python","scikit-learn","sensitivity-specificity","user-behavior-prediction"],"created_at":"2024-10-31T11:06:44.247Z","updated_at":"2026-04-12T02:35:17.896Z","avatar_url":"https://github.com/musty-ess.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shopping Prediction AI Using Machine Learning\n\n## Project Overview\n\nThis project is an AI model designed to predict whether customers on an online shopping website will complete a purchase. It uses machine learning, specifically a k-nearest neighbors (KNN) classifier, to analyze user behavior and predict their purchasing intent. The model could be used by online shopping websites to display targeted content, such as offering discounts to users who are less likely to make a purchase.\n\n## Features\n\nThe classifier uses various features from user sessions, such as:\n- Number of pages visited (administrative, informational, product-related pages)\n- Time spent on each page\n- Bounce rates, exit rates, and page values (from Google Analytics)\n- Special days (e.g., proximity to holidays like Valentine's Day)\n- User attributes (operating system, browser, traffic source, returning visitor status, weekend browsing)\n- And more...\n\nBased on this data, the classifier predicts whether a user will complete a purchase.\n\n## File Structure\n\n- `shopping.py`: Main script that loads data, trains the model, and evaluates predictions.\n- `shopping.csv`: Dataset containing session data of around 12,000 online users.\n\n## Key Functions Implemented\n\n### `load_data(filename)`\n- Loads the shopping data from `shopping.csv`.\n- Converts the features into a format suitable for the k-nearest neighbors algorithm.\n- Returns two lists: `evidence` (features for each user session) and `labels` (whether or not the user made a purchase).\n\n### `train_model(evidence, labels)`\n- Trains a KNN classifier (k = 1) using the provided `evidence` and `labels`.\n- Returns a trained model that can be used to predict whether a user will complete a purchase.\n\n### `evaluate(labels, predictions)`\n- Evaluates the performance of the model.\n- Returns two metrics:\n  - **Sensitivity**: True positive rate (correctly identified purchases).\n  - **Specificity**: True negative rate (correctly identified non-purchases).\n\n## Installation\n1. **clone the repo**: `git clone https://github.com/musty-ess/Shopping-Prediction-AI-Using-Machine-Learning.git`\n2. **Install necessary dependencies**: `pip install scikit-learn`\n\n## Usage\n\nTo run the program, use the following command: `python shopping.py shopping.csv`\n\nThe model will load the dataset, train on a portion of it, and then make predictions on the test set. The results, including the sensitivity and specificity, will be displayed in the terminal.\n\n## Sample Output\n\n```bash\npython shopping.py shopping.csv\nCorrect: 4088\nIncorrect: 844\nTrue Positive Rate: 41.02%\nTrue Negative Rate: 90.55%\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusty-ess%2Fshopping-prediction-ai-using-machine-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmusty-ess%2Fshopping-prediction-ai-using-machine-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusty-ess%2Fshopping-prediction-ai-using-machine-learning/lists"}