uy
Based on https://github.com/pbharrin/machinelearninginaction/blob/master/Ch12/fpGrowth.py
To install: pip install uy
Description
The uy package implements the FP-Growth algorithm for frequent itemset mining, avoiding the costly generation of candidate sets involved in algorithms like Apriori. This implementation includes functions to construct the FP-tree, update it, and mine the frequent itemsets from it. The package is designed to efficiently find frequent itemsets in a given dataset, which is crucial for tasks such as market basket analysis, association rule learning, and anomaly detection.
Main Components
- treeNode: A class representing a node in the FP-tree. Each node contains links to parent and child nodes, a count of occurrences, and methods to manage the node's data.
- createTree: A function to build the FP-tree from the dataset. It also constructs a header table that helps in tree traversal.
- updateTree: Used to add items to the FP-tree during its construction.
- mineTree: Once the FP-tree is constructed, this function is used to mine the frequent itemsets from the tree using the header table.
- loadSimpDat: A utility function to load a simple example dataset.
- createInitSet: Converts a list of transactions into a dictionary format expected by
createTree.
Usage Examples
Loading Data and Creating Initial Set
from uy import loadSimpDat, createInitSet
# Load example data
simpDat = loadSimpDat()
# Create initial set from data
initSet = createInitSet(simpDat)
Building the FP-Tree
from uy import createTree
# Minimum support
minSup = 3
# Create FP-tree and header table
myFPtree, myHeaderTab = createTree(initSet, minSup)
Mining Frequent Itemsets
from uy import mineTree
# List to hold the mined frequent itemsets
freqItems = []
# Mine the tree
mineTree(myFPtree, myHeaderTab, minSup, set([]), freqItems)
# Print the frequent itemsets
print(freqItems)
Documentation
Class: treeNode
- init(self, nameValue, numOccur, parentNode): Initialize a new tree node.
- inc(self, numOccur): Increment the count of occurrences for the node.
- disp(self, ind=1): Display the subtree rooted at this node.
- str(self, ind=1): Return a string representation of the subtree rooted at this node.
- repr(self, ind=1): Return the string representation for interactive environments.
Function: createTree
- createTree(dataSet, minSup=1): Create the FP-tree from the dataset. It returns the root of the FP-tree and the header table.
Function: updateTree
- updateTree(items, inTree, headerTable, count): Update the FP-tree with given items.
Function: mineTree
- mineTree(inTree, headerTable, minSup, preFix, freqItemList): Mine the FP-tree to find frequent itemsets that meet the minimum support.
Function: loadSimpDat
- loadSimpDat(): Load a simple hardcoded dataset for demonstration purposes.
Function: createInitSet
- createInitSet(dataSet): Convert dataset into a format suitable for the FP-tree construction.
By using these functions and classes, users can perform efficient frequent itemset mining in various datasets, which is a foundational technique in many data mining applications.
Metadata
Release files for uy 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| uy-0.0.6.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uy-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / uy-0.0.6.tar.gz
| Download URL | uy-0.0.6.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
549274eece44eef4f262c142d54bb8224401bdc055e29c92c34b0aba04c3afe4
|
|
BLAKE2b-256 checksum How to use checksums |
445a96c699d38c31598a404f00d41f7ccbc584bca99aa71da11607d3e1f83235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / uy-0.0.6-py3-none-any.whl
| Download URL | uy-0.0.6-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
503ff98b5f1f17de4de9c6eba4bdab409d26b21444f6b59a8a77d8c3a0290eff
|
|
BLAKE2b-256 checksum How to use checksums |
9c2699b48ea5a878acea89aa7b6f95e4049d5d7ebf5108a23135cc7710bcd07c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|