-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
test_arules.py
52 lines (43 loc) · 1.21 KB
/
test_arules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pandas as pd
import pycaret.arules
import pycaret.datasets
def test_arules():
# loading dataset
data = pycaret.datasets.get_data("france")
assert isinstance(data, pd.DataFrame)
row, col = data.shape
assert row == 8557
assert col == 8
# init setup
arul101 = pycaret.arules.setup(
data=data,
transaction_id="InvoiceNo",
item_id="Description",
session_id=123,
)
assert isinstance(arul101, tuple)
assert isinstance(arul101[0], pd.DataFrame)
row, col = arul101[0].shape
assert row == 8557
assert col == 8
assert isinstance(arul101[1], str)
assert isinstance(arul101[2], str)
assert isinstance(arul101[4], int)
assert isinstance(arul101[5], list)
# create model
model = pycaret.arules.create_model()
assert isinstance(model, pd.DataFrame)
row, col = model.shape
assert row == 141
assert col == 9
# get rules
rules = pycaret.arules.get_rules(
data=data, transaction_id="InvoiceNo", item_id="Description"
)
assert isinstance(rules, pd.DataFrame)
row, col = rules.shape
assert row == 141
assert col == 9
assert 1 == 1
if __name__ == "__main__":
test_arules()