Skip to content

Commit 5ee5abb

Browse files
authored
Merge pull request #77 from zStupan/examples
Add rule example
2 parents 8073dda + 8983ef8 commit 5ee5abb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

examples/make_rule.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from niaarm import Dataset, Feature, Rule
2+
3+
# load the Abalone dataset
4+
data = Dataset("datasets/Abalone.csv")
5+
6+
# make the rule Shell weight([0.15, 0.35]) => Rings([5, 10])
7+
antecedent = [Feature('Shell weight', dtype='float', min_val=0.15, max_val=0.35)]
8+
consequent = [Feature('Rings', dtype='int', min_val=5, max_val=10)]
9+
10+
# pass the transaction data to the Rule constructor to enable the calculation of metrics
11+
rule = Rule(antecedent, consequent, transactions=data.transactions)
12+
13+
print(rule)
14+
print(f'Support: {rule.support}')
15+
print(f'Confidence: {rule.confidence}')
16+
print(f'Lift: {rule.lift}')

0 commit comments

Comments
 (0)