-
Notifications
You must be signed in to change notification settings - Fork 2
/
stdPysubgroup.py
48 lines (44 loc) · 1.39 KB
/
stdPysubgroup.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
# Package imports
import pysubgroup as ps
# Function used to execute the BestFirstSearch algorithm from the pysubgroup package
def bestFirstSearch(data):
target = ps.BinaryTarget('target', True)
searchspace = ps.create_selectors(data, ignore=['target'])
task = ps.SubgroupDiscoveryTask(
data,
target,
searchspace,
result_set_size = 100,
depth = 2,
qf = ps.WRAccQF()
)
result = ps.BestFirstSearch(beam_width=100).execute(task)
return result.to_dataframe()
# Function used to execute the DFS algorithm from the pysubgroup package
def DFS(data):
target = ps.BinaryTarget('target', True)
searchspace = ps.create_selectors(data, ignore=['target'])
task = ps.SubgroupDiscoveryTask(
data,
target,
searchspace,
result_set_size = 100,
depth = 2,
qf = ps.WRAccQF()
)
result = ps.SimpleDFS().execute(task)
return result.to_dataframe()
# Function used to execute the Apriori algorithm from the pysubgroup package
def apriori(data):
target = ps.BinaryTarget('target', True)
searchspace = ps.create_selectors(data, ignore=['target'])
task = ps.SubgroupDiscoveryTask(
data,
target,
searchspace,
result_set_size = 100,
depth = 2,
qf = ps.WRAccQF()
)
result = ps.Apriori().execute(task)
return result.to_dataframe()