开发者

Deriving rules about column dependencies on integer data?

I have lots of data like the following:

<A,B,C,D,E,F> ...

I am wond开发者_运维技巧ering if there is a way to determine the association between the different columns in the vector. This association is consistent in the entire data. For instance, one rule is

if (A changes by 1)
  B changes by 1

I want to be able to generate these rules automatically and if so, can someone please let me know if there are any libraries available to do this?


The technique you have described, though a use case, is usually known as Association Rules or Market Basket Analysis. (The latter term reflects the earliest applications of these algorithms, which was the study of consumer behavior in supermarkets--i.e., if a shopper buys a jar of peanut butter, how often do they buy a jar of honey?)

There is at least one Python library, Orange, which has an Association Rules module.

The Association Rules code is in the Orange module, orngAssoc.

Typically, you pass in your data and a 'threshold criterion' (that specify how strong the association must be between any two items in a given data row), and the algorithm returns a set of rules that exceed that threshold.

What is very interesting about the Orange A/R module is that it can alternatively return items sets--i.e., the data rows that satisfy those rule sets.

The documentation for Orange's A/R module is concise and straightforward, with several simple working code examples (i.e., that you can plug directly in to the A/R module).

I can strongly recommend this module--i've used it about a dozen times in the past few months. It's engine seems to be as good as any other implementation i've used (Orange implements Agrawal's dynamic induction algorithm, as well as a modified form of that Algorithm); the appeal of the Orange Association Rules module is that it is(in my opinion) far easier to use than others, and the results are returned in a form easier to interpret and often more useful (i.e., item sets)--again, compared to other implementations.


Since you tagged this language agnostic, I'm going to advocate the R Statistical Software environment, which has a myriad of tools that can describe relations between data.

For example, if your data is in a csv-like structure:

A,B
1,3
2,4
3,5

In R you could find the linear relationship between A and B with:

data <- read.csv("/path/to/file")
regression <- lm(A~B, data)

Which would provide you with a coefficient of 1 on B. There are many other ways of analyzing data with R, and if R is installed, it is fairly easy to write and execute scripts. I've found this introduction to R to be a great resource for learning how to use R as well as a great reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜