亲和力分析:给定样本相似度分析的一种data mining方法,相似的应用如服务、广告、商品推荐、基因同源追溯等。
简单的规则可用“如果一个人买了产品X,那么他也可能买商品Y”来形容亲和力分析。
亲和力分析的度量尺度:
Support:支持度,rule在数据集中发生的次数,有时可以除以rule有效预测次数进行归一化
Confidence:可信度,rule在数据集中发生的次数/预测事件的次数
简单理解下:
rule: 买A→买B
Support=买了A同时买了B的次数
Confidence = 买了A同时买了B的次数/买了A的次数
Affinity analysis is a type of data mining that gives similarity between samples (objects). This could be the similarity between the following:
-
users on a website, in order to provide varied services or targeted advertising
-
items to sell to those users, in order to provide recommended movies or products
-
human genes, in order to find people that share the same ancestors
find simple rules of the form: If a person buys product X, then they are likely to purchase product Y
Rules of this type can be measured in many ways, of which we will focus on two: support and confidence.
- Support is the number of times that a rule occurs in a dataset, which is computed by simply counting the number of samples that the rule is valid for. It can sometimes be normalized by dividing by the total number of times the premise of the rule is valid, but we will simply count the total for this implementation.
- Confidence measures how accurate they are when they can be used. It can be computed by determining the percentage of times the rule applies when the premise applies. We first count how many times a rule applies in our dataset and divide it by the number of samples where the premise (the if statement) occurs.
例如采样矩阵:有5条样例,每条有5个特征分别代表买【bread, milk, cheese, apples, and bananas】
[
[ 0. 0. 1. 1. 1.]
[ 1. 1. 0. 1. 0.] [ 1. 0. 1. 1. 0.] [ 0. 0. 1. 1. 1.] [ 0. 1. 0. 0. 1.]
]
特征features = ["bread", "milk", "cheese", "apples", "bananas"]
例如买了apples则买banana的事件
规则发生的次数:rule_valid = 2
规则无效的次数:rule_invalid = 2
Support = rule_valid(3,4)= 2次 ,其中(3,4)代表矩阵中第4列=1同时第5列=1,apples则买banana的事件
预测事件发生次数:num_apple_purchases 买apples事件发生的次数为4
Confidence = rule_valid/num_apple_purchases = 50%