Skip to content

Commit

Permalink
Merge pull request #77 from zStupan/examples
Browse files Browse the repository at this point in the history
Add rule example
  • Loading branch information
zStupan authored Dec 17, 2022
2 parents 8073dda + 8983ef8 commit 5ee5abb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/make_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from niaarm import Dataset, Feature, Rule

# load the Abalone dataset
data = Dataset("datasets/Abalone.csv")

# make the rule Shell weight([0.15, 0.35]) => Rings([5, 10])
antecedent = [Feature('Shell weight', dtype='float', min_val=0.15, max_val=0.35)]
consequent = [Feature('Rings', dtype='int', min_val=5, max_val=10)]

# pass the transaction data to the Rule constructor to enable the calculation of metrics
rule = Rule(antecedent, consequent, transactions=data.transactions)

print(rule)
print(f'Support: {rule.support}')
print(f'Confidence: {rule.confidence}')
print(f'Lift: {rule.lift}')

0 comments on commit 5ee5abb

Please sign in to comment.