Skip to main content

Item Affinity Service

Item Affinity Service

Introduction

The Affinity Service API provides a powerful tool for analyzing item relationships and generating association rules based on transaction data. By leveraging association rule mining techniques, the API enables users to uncover meaningful associations and dependencies between items, allowing for effective fraudulent items suggestion market basket analysis, recommendation systems, and data-driven insights.

Key Concepts

  • Association Rules: Association rules are widely used in data mining and recommenders systems to discover interesting relationships or patterns among items in large datasets. They describe the co-occurrence patterns of items in transactions and help uncover associations and dependencies between them.

  • Support: Support measures the frequency or occurrence of an itemset in a dataset. It indicates how often a specific combination of items appears together in transactions.

  • Confidence: Confidence measures the conditional probability that an item B is purchased when item A is purchased. It is calculated as the ratio of the support of the itemset containing both A and B to the support of the itemset containing only A.

  • Lift: Lift measures the strength of association between two items A and B. It compares the observed support of the itemset containing both A and B to the expected support if A and B were independent. A lift value greater than 1 indicates a positive association, while a value less than 1 indicates a negative association.

  • Leverage: Leverage computes the difference between the observed frequency of A and C appearing together and the frequency that would be expected if A and C were independent. A leverage value of 0 indicates independence.

  • Conviction: Conviction is a measure of the strength of the association between items. It indicates the degree of dependency between the antecedent and consequent of a rule. High conviction values suggest a strong association, while low values indicate a weak association.

  • Zhang's Metric: Zhang's metric is a statistical measure used to evaluate the interestingness of association rules. It combines multiple factors such as support, confidence, and lift to determine the significance and relevance of a rule.

  • Cosine: The value of cosine (A → B) is close to 1 indicates more transactions containing item A also contains item B, and vice versa. Similarly, the value of cosine (A → B) is close to 0 indicates more transactions contain item A without containing item B, and vice versa.

  • Interestingness: Interestingness refers to the degree to which an association rule is considered valuable or surprising. It takes into account various factors such as support, confidence, and novelty of the rule.

Base URL

The base URL for the Item Affinity Service API is https://hii-ita-affinity-service.retailsvc.com.

API Endpoints

1. Get Correlated Items

  • Endpoint: /api/v1/get-correlated-items
  • Method: POST
  • Description: gets correlated items based on the provided transaction items.
  • Request Parameters:
    • 'basketItems' (array): An array of items that customer has in his basket.
  • Response:
    • 'correlatedItems' (array): An array of recommended items associated with the antecedent itemset.

Examples and Use Cases

The Item Affinity Service API's association rules functionality can be applied in various use cases, including:

  • Suggest Fraudulent Items: By analyzing association rules, the API can provide a list of items that can be in the customer's basket and didnt scan during his shopping trip. Those items in the suggested list are strongly correlated to the Items he has in in his basket.

  • Product Recommendations: By analyzing association rules, the API can provide personalized product recommendations to users based on their browsing or purchasing history. For example, if a user has added a smartphone to their cart, the API can leverage association rules to suggest complementary items such as phone cases or screen protectors.

  • Market Basket Analysis: The Affinity Service API can enable market basket analysis by identifying frequently co-occurring items in transactions. This information can help retailers optimize their product placement, design targeted promotions, and understand customer buying patterns.

  • Cross-Selling and Upselling: By analyzing association rules, the API can identify items that are commonly purchased together. This knowledge can be leveraged to implement cross-selling and upselling strategies. For example, when a customer adds a shirt to their cart, the API can recommend matching pants or accessories.

Authentication and Authorization

To access the Item Affinity Service API, users must include an access token in the Authorization header. The access token can be obtained by authenticating with the OCMS service. Only authorized users with valid API keys are granted access to the API endpoints.

Error Handling

The API follows standard error handling practices and returns appropriate HTTP status codes and error messages for different scenarios. Refer to the API documentation for a comprehensive list of error codes and their meanings.

Security Considerations

  • The API employs encryption (HTTPS) to ensure secure communication and data transfer.
  • Input validation is implemented to prevent malicious or invalid data from compromising the system.
  • Access controls and user roles are enforced to restrict unauthorized access to sensitive data and functionalities.

Conclusion

The concept documentation provides a comprehensive overview of the Affinity Service API's association rules functionality. It covers the key concepts related to association rules, API endpoints, examples and use cases, as well as security considerations.