Skip to main content

Itemset Mining

downloads

latest release supported python versions package status license

travis build status docs build status coverage status

Implements itemset mining algorithms.

Algorithms

High-utility itemset mining (HUIM)

HUIM generalizes the problem of frequent itemset mining (FIM) by considering item values and weights. A popular application of HUIM is to discover all sets of items purchased together by customers that yield a high profit for the retailer. In such a case, item values would show not just that a load of bread is in a basket, but how many there are; and weights would include the profit from a loaf of bread.

More technically, HUIM requires transactions in the transactions "database" to have internal utilities (i.e. item values) associated with each item in each transaction and a "database" of external utilities for each item (i.e. weights).

Algorithm Class How to Cite
Two-Phase* itemset_mining.two_phase_huim.TwoPhase Link

* Includes max length support

Roadmap (high to low priority):

  • Address low-correlation HUIs with one of bond, all-confidence, or affinity. Itemsets that are high utility, but where the items aren't correlated can be misleading for making marketing decisions. E.g. if an itemset of a TV and a pen is a HUI, it's likely just because the TV is expensive, not because it's an interesting pattern.
  • Add average utility measure support, for easier, more intuitive minutil
  • Support discount strategies via a discount strategy table and upgraded external utilities table.
  • Add top-k HUI support.
  • Support identifying periodic high utility itemsets. This allows detection of purchase patterns among high-utility itemsets to allow cross-promotions to customers who buy sets of items periodically.
  • Support items' on-shelf time. Ignmoring on-shelf time will biat toward items that have more shelf time, since they have more chance to generate higher utility.
  • Allow incremental transaction updates without rerunning everything.
  • Support concise HUI itemsets, specifically closed form. This allows the algorithm to be more efficient, only showing longer itemsets, which may be the most interesting ones (correlation issues aside).

Installation:

pip install itemset-mining

Example:

    >>> from operator import attrgetter
    >>> from itemset_mining.two_phase_huim import TwoPhase
    >>> transactions = [
    ...     [("Coke 12oz", 6), ("Chips", 2), ("Dip", 1)],
    ...     [("Coke 12oz", 1)],
    ...     [("Coke 12oz", 2), ("Chips", 1), ("Filet Mignon 1lb", 1)],
    ...     [("Chips", 1)],
    ...     [("Chips", 2)],
    ...     [("Coke 12oz", 6), ("Chips", 1)]
    ... ]
    >>> # ARP for each item
    >>> external_utilities = {
    ...     "Coke 12oz": 1.29,
    ...     "Chips": 2.99,
    ...     "Dip": 3.49,
    ...     "Filet Mignon 1lb": 22.99
    ... }
    >>> # Minimum dollar value generated by an itemset we care about across all transactions
    >>> minutil = 20.00

    >>> hui = TwoPhase(transactions, external_utilities, minutil)
    >>> result = hui.get_hui()
    >>> sorted(result, key=attrgetter('itemset_utility'), reverse=True)
    ... # doctest: +NORMALIZE_WHITESPACE
    [HUIRecord(items=('Chips', 'Coke 12oz'), itemset_utility=30.02),
     HUIRecord(items=('Chips', 'Coke 12oz', 'Filet Mignon 1lb'), itemset_utility=28.56),
     HUIRecord(items=('Chips', 'Filet Mignon 1lb'), itemset_utility=25.979999999999997),
     HUIRecord(items=('Coke 12oz', 'Filet Mignon 1lb'), itemset_utility=25.57),
     HUIRecord(items=('Filet Mignon 1lb',), itemset_utility=22.99),
     HUIRecord(items=('Chips',), itemset_utility=20.93)]

Metadata

Release files for itemset-mining 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for itemset-mining 0.2.2
File Size Uploaded
itemset_mining-0.2.2.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for itemset-mining 0.2.2
File Interpreter ABI Platform
itemset_mining-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / itemset_mining-0.2.2.tar.gz

Download URL itemset_mining-0.2.2.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7b0c5830ad89bea7f368473a77a0b403f3fb98e202f5b87caf6049fc89c82b69
BLAKE2b-256 checksum
How to use checksums
91a43f9cc0dad26117869fbbd7a672e79f2b902f1326ebf34cfed6f0b3449762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / itemset_mining-0.2.2-py3-none-any.whl

Download URL itemset_mining-0.2.2-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c74e8d4f2666097b208f5edda33d83b1797fdc005a0b243885aaa4ac46c0cad8
BLAKE2b-256 checksum
How to use checksums
5c5bde33c0a8c118c3b06f086ac78b1e0a3cc316ae83389da70637b59cc22c01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

1 release file

0.2.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page