Giter Site home page Giter Site logo

pyfreqpm's Introduction

About

Frequent patterns are patterns which appear frequently within a dataset. A frequent itemset is one which is made up of one of these patterns, which is why frequent pattern mining is often alternately referred to as frequent itemset mining.

Frequent pattern mining is most easily explained by introducing market basket analysis (or affinity analysis), a typical usage for which it is well-known. Market basket analysis attempts to identify associations, or patterns, between the various items that have been chosen by a particular shopper and placed in their market basket, be it real or virtual, and assigns support and confidence measures for comparison. The value of this lies in cross-marketing and customer behavior analysis.

The generalization of market basket analysis is frequent pattern mining, and is actually quite similar to classification except that any attribute, or combination of attributes (and not just the class), can be predicted in association. As association does not require the pre-labeling of classes, it is a form of unsupervised learning. source

Framework

Alt Text

Algorithms

This frequent pattern mining framework implementing the following algorithms

  1. generic Apriori
  2. Apriori-TID
  3. Eclat
  4. FP-Growth

Usage

  1. Get a list if all transactions (previous orders) and a list of items being sold that are encountered in the dataset
from pyfreqpm import FreqPM
dataset = [['i1', 'i2'],
           ['i1', 'i3'],
           ['i1', 'i2']]
items = ['i1', 'i2', 'i3']
  1. Create an analyzer and provide algorithm to use and min_support, min_confidence, min_lift parameters.

Possible values for analyzer are apriori-gen, apriori-tid, eclat, fp-growth

test = FreqPM.model(analyzer='apriori-gen')
test.fit(dataset, items, min_support=0.1, min_confidence=0.5, min_lift=1.0)
  1. After creating a model a prediction may be made for a new basket based on mined association rules
test.predict(['i1'])
{'confidence': 0.6666666666666666, 'lift': 1.0, 'to': frozenset({'i2'})}

This prediction recommends item i2 for someone having i1 already in the shopping cart.

pyfreqpm's People

Contributors

smirnov-am avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.