Esempio n. 1
0
import pysubgroup as ps
import pandas as pd
data = pd.read_table("../data/titanic.csv")
target = ps.NominalTarget('Survived', True)

searchspace = ps.create_selectors(data, ignore=['Survived'])
task = ps.SubgroupDiscoveryTask(data,
                                target,
                                searchspace,
                                result_set_size=5,
                                depth=2,
                                qf=ps.ChiSquaredQF())
result = ps.BeamSearch().execute(task)

for (q, sg) in result:
    print(str(q) + ":\t" + str(sg.subgroup_description))
Esempio n. 2
0
from scipy.io import arff

import pysubgroup as ps
import pandas as pd

data = pd.DataFrame(arff.loadarff("../data/credit-g.arff")[0])

target = ps.NominalTarget('class', b'bad')
searchSpace = ps.createNominalSelectors(data, ignore=['class'])
task = ps.SubgroupDiscoveryTask(data,
                                target,
                                searchSpace,
                                resultSetSize=10,
                                depth=3,
                                qf=ps.StandardQF(1.0))

result = ps.BeamSearch(beamWidth=10).execute(task)
for (q, sg) in result:
    print(str(q) + ":\t" + str(sg.subgroupDescription))

print("******")
result = ps.SimpleDFS().execute(task)
for (q, sg) in result:
    print(str(q) + ":\t" + str(sg.subgroupDescription))

# print WRAccQF().evaluateFromDataset(data, Subgroup(target, []))
Esempio n. 3
0
import pysubgroup as ps
import pandas as pd
import matplotlib.pyplot as plt
plt.interactive(False)


data = pd.read_csv("~/datasets/titanic.csv")
target = ps.NominalTarget ('survived', 0)
searchSpace = ps.createSelectors(data, ignore=['survived'])
task = ps.SubgroupDiscoveryTask (data, target, searchSpace, 
                                 resultSetSize=5, depth=2, 
                                 qf=ps.ChiSquaredQF())

result = ps.SimpleDFS().execute(task)

dfs = ps.utils.resultsAsDataFrame (data, result)
plt = ps.plot_roc (data, dfs, ps.ChiSquaredQF())
plt.show()