This repository contains a Python script for a basic recommendation system. The system analyzes historical shopping data to calculate angles between items, and it provides recommendations based on the angles between items in a given shopping cart.
- This function calculates the angle (in degrees) between two vectors
xandy.
- Reads the first line from the "history.txt" file and returns the content as a list.
- Processes the first line data from the "history.txt" file, extracting the number of customers, items, and transactions.
- Reads the entire "history.txt" file and returns its content as a list.
- Processes individual transaction data, creating a dictionary where itemIDs are keys, and the corresponding customers who bought those items create vectors.
- Calculates the angles between all pairs of items based on the vectors created for each item.
- Reads the "queries.txt" file and returns its content as a list.
- Calculates the total number of positive entries in the dataset.
- Calculates the average angle between items.
- Prints the total number of positive entries, average angle between items, and provides item recommendations for each shopping cart specified in the "queries.txt" file.
-
Ensure you have the "history.txt" and "queries.txt" files in the same directory as the script.
-
Run the script.
-
View the output, which includes the total number of positive entries, average angle between items, and item recommendations for each shopping cart.
📝Note: Make sure the input data files follow the expected format for accurate results.