Apriori algorithm.
Project description
Aprioripy: Apriori algorithm.
Apriori algorithm usage:
from apriopy import Apriopy
test_table = pd.DataFrame({
"items": ["1, 3, 4", "2, 3, 5", "1, 2, 3, 5", "2, 5"]
})
print("Test table")
print(test_table)
ap = Aprioripy(table=test_table)
print("\nFrequency table:")
print(ap.frequency_table)
ap.apriori(min_support=0.5)
for i in ap.association_tables.keys():
print("\nAssociation table " + i)
print(ap.association_tables[i])
test_table = pd.DataFrame(
[
{"1": 1, "2": 0, "3": 1, "4": 1, "5": 0},
{"1": 0, "2": 1, "3": 1, "4": 0, "5": 1},
{"1": 1, "2": 1, "3": 1, "4": 0, "5": 1},
{"1": 0, "2": 1, "3": 0, "4": 0, "5": 1}
]
)
print("\nTest table:")
print(test_table)
ap = Aprioripy(table=test_table, convert=False)
print("\nFrequency table:")
print(ap.frequency_table)
ap.apriori(min_support=0.5)
for i in ap.association_tables.keys():
print("\nAssociation table " + i)
print(ap.association_tables[i])
Output:
Test table
items
0 1, 3, 4
1 2, 3, 5
2 1, 2, 3, 5
3 2, 5
Frequency table:
item frequency
0 1 0.50
1 2 0.75
2 3 0.75
3 4 0.25
4 5 0.75
Association table L1
item frequency
0 1 0.50
1 2 0.75
2 3 0.75
4 5 0.75
Association table L2
itemset frequency
1 (1, 3) 0.50
4 (2, 3) 0.50
6 (2, 5) 0.75
8 (3, 5) 0.50
Association table L3
itemset frequency
7 (2, 3, 5) 0.5
Test table:
1 2 3 4 5
0 1 0 1 1 0
1 0 1 1 0 1
2 1 1 1 0 1
3 0 1 0 0 1
Frequency table:
item frequency
0 1 0.50
1 2 0.75
2 3 0.75
3 4 0.25
4 5 0.75
Association table L1
item frequency
0 1 0.50
1 2 0.75
2 3 0.75
4 5 0.75
Association table L2
itemset frequency
1 (1, 3) 0.50
4 (2, 3) 0.50
6 (2, 5) 0.75
8 (3, 5) 0.50
Association table L3
itemset frequency
7 (2, 3, 5) 0.5
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aprioripy-0.0.2.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file aprioripy-0.0.2.tar.gz
.
File metadata
- Download URL: aprioripy-0.0.2.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f14bcc0e9ef1d31b81cd55062057789754833d36f887ef9bf2151791a503980c |
|
MD5 | 50f6c689b1baebc6ec18d7549f14113b |
|
BLAKE2b-256 | d553a0e9c036278a972e139e685a643a7f0bf6e97001c3519dbfa008c9191664 |
File details
Details for the file aprioripy-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: aprioripy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d6078103dbb404e258513dcf5a5784671d23c6a5dec4a128f472f46840cf68e |
|
MD5 | d0de76adb280764366c4ff6518ac2807 |
|
BLAKE2b-256 | cbd97ff71b33b94262f19d6b43321b9135c33b3ff2aa77ebf958d24f28c064a9 |