Affinity Analysis for Market Basket Recommendation (FP-Growth)

No algorithm description given

Affinity analysis is an analytical technique that aims to discover relationships between activities and preferences that pertain to specific individuals. Based on recorded information, after the analysis, future behaviour can be statistically predicted. For a general overview see http://en.wikipedia.org/wiki/Affinity_analysis . Specific applications include clickstream analysis and market basket analysis. One important area of application is market basket analysis, which has widespread use in planning promotions, designs and sales strategies. Market basket analysis is necessarily somewhat open-ended, but one of the more useful angles of attack is the extraction of association rules . This API uses this FP-Growth algorithm implementation from the Weka library. Input: [url, options] The program takes a DataAPI url to a file with one session per line. A session represents the entities that were bought/used/visited in a single recorded event. This could be the urls seen in a given browsing session or items bought in a single visit to a store. For example: bread milk eggs beer diapers bread bottled_water hot_dogs lemonade The items are not ordered and there is no customer identification. The items are separated by whitespace, and the only constraint on the format is that items must be uniquely identifiable by the string and the string may contain no white spaces. You can also use a CSV file instead, in which v alues can contain any character except comma : bread,milk,eggs beer,diapers bread,bottled water,hot dogs,lemonade You can customise the behaviour of the FP-Growth algorithm by supplying your own custom parameters: -I <max items> The maximum number of items to include in large items sets (and rules). (default = -1, i.e. no limit.) -N <require number of rules> The required number of rules. (default = 10) -T <0=confidence | 1=lift | 2=leverage | 3=Conviction> The metric by which to rank rules. (default = confidence) -C <minimum metric score of a rule> The minimum metric score of a rule. (default = 0.9) -U <upper bound for minimum support> Upper bound for minimum support. (default = 1.0) -M <lower bound for minimum support> The lower bound for the minimum support. (default = 0.1) -D <delta for minimum support> The delta by which the minimum support is decreased in each iteration. (default = 0.05) -S Find all rules that meet the lower bound on minimum support and the minimum metric constraint. Turning this mode on will disable the iterative support reduction procedure to find the specified number of rules. -transactions <comma separated list of attribute names> Only consider transactions that contain these items (default = no restriction) -rules <comma separated list of attribute names> Only print rules that contain these items. (default = no restriction) -use-or Use OR instead of AND for must contain list(s). Use in conjunction with -transactions and/or -rules Output An array of rules, where each rule contains: confidence : the proportion of the examples covered by the premise that are also covered by the consequence. Alternatively, this can be described as the probability that a rule is correct for a new transaction. lift : confidence divided by the proportion of all examples that are covered by the consequence. This is a measure of the importance of the association that is independent of support. leverage : the proportion of additional examples covered by both the premise and consequence above those expected if the premise and consequence were independent of each other. conviction : another measure of departure from independence. premise : the 'premise' part of the rule. consequence : the 'consequence' part of the rule. premiseSupport: the number of transactions (sessions) in the data set which contain the premise items. consequenceSupport the number of transactions (sessions) in the data set which contain the consequence items. In the context of Market Basket Analysis, the rules should be interpreted like this: i f a user buys an item in the premise item set, then the user will likely buy the item in the consequence item set too. The sample data set is taken from here .

Tags
(no tags)

Cost Breakdown

0 cr
royalty per call
1 cr
usage per second
avg duration

Cost Calculator

API call duration (sec)
×
API calls
=
Estimated cost
per calls
for large volume discounts
For additional details on how pricing works, see Algorithmia pricing.

Internet access

This algorithm has Internet access. This is necessary for algorithms that rely on external services, however it also implies that this algorithm is able to send your input data outside of the Algorithmia platform.


To understand more about how algorithm permissions work, see the permissions documentation.

1. Type your input

2. See the result

Running algorithm...

3. Use this algorithm

curl -X POST -d '{{input | formatInput:"curl"}}' -H 'Content-Type: application/json' -H 'Authorization: Simple YOUR_API_KEY' https://api.algorithmia.com/v1/algo/Aluxian/AffinityAnalysisFPGrowth/0.1.0
View cURL Docs
algo auth
# Enter API Key: YOUR_API_KEY
algo run algo://Aluxian/AffinityAnalysisFPGrowth/0.1.0 -d '{{input | formatInput:"cli"}}'
View CLI Docs
import com.algorithmia.*;
import com.algorithmia.algo.*;

String input = "{{input | formatInput:"java"}}";
AlgorithmiaClient client = Algorithmia.client("YOUR_API_KEY");
Algorithm algo = client.algo("algo://Aluxian/AffinityAnalysisFPGrowth/0.1.0");
AlgoResponse result = algo.pipeJson(input);
System.out.println(result.asJsonString());
View Java Docs
import com.algorithmia._
import com.algorithmia.algo._

val input = {{input | formatInput:"scala"}}
val client = Algorithmia.client("YOUR_API_KEY")
val algo = client.algo("algo://Aluxian/AffinityAnalysisFPGrowth/0.1.0")
val result = algo.pipeJson(input)
System.out.println(result.asJsonString)
View Scala Docs
var input = {{input | formatInput:"javascript"}};
Algorithmia.client("YOUR_API_KEY")
           .algo("algo://Aluxian/AffinityAnalysisFPGrowth/0.1.0")
           .pipe(input)
           .then(function(output) {
             console.log(output);
           });
View Javascript Docs
var input = {{input | formatInput:"javascript"}};
Algorithmia.client("YOUR_API_KEY")
           .algo("algo://Aluxian/AffinityAnalysisFPGrowth/0.1.0")
           .pipe(input)
           .then(function(response) {
             console.log(response.get());
           });
View NodeJS Docs
import Algorithmia

input = {{input | formatInput:"python"}}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('Aluxian/AffinityAnalysisFPGrowth/0.1.0')
print algo.pipe(input)
View Python Docs
library(algorithmia)

input <- {{input | formatInput:"r"}}
client <- getAlgorithmiaClient("YOUR_API_KEY")
algo <- client$algo("Aluxian/AffinityAnalysisFPGrowth/0.1.0")
result <- algo$pipe(input)$result
print(result)
View R Docs
require 'algorithmia'

input = {{input | formatInput:"ruby"}}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('Aluxian/AffinityAnalysisFPGrowth/0.1.0')
puts algo.pipe(input).result
View Ruby Docs
use algorithmia::*;

let input = {{input | formatInput:"rust"}};
let client = Algorithmia::client("YOUR_API_KEY");
let algo = client.algo('Aluxian/AffinityAnalysisFPGrowth/0.1.0');
let response = algo.pipe(input);
View Rust Docs
Discussion
  • {{comment.username}}