Commit f5f25a86 authored by Anze Vavpetic's avatar Anze Vavpetic
Browse files

build subgroups now properly returns a classifier

parent d5aa32b7
......@@ -82,14 +82,15 @@ class SD_learner(orange.Learner):
#________________________________________________________________________________________
class SD_Classifier(orange.Classifier):
def __init__(self, data):
if type(data) is not orange.ExampleTable:
raise TypeError('Data is not an orange.ExampleTable')
if data.domain.classVar.varType != orange.VarTypes.Discrete:
raise TypeError('Data should have a discrete target variable.')
def __init__(self, data=None):
if data:
if type(data) is not orange.ExampleTable:
raise TypeError('Data is not an orange.ExampleTable')
if data.domain.classVar.varType != orange.VarTypes.Discrete:
raise TypeError('Data should have a discrete target variable.')
self.data = data
self.majorityClassifier = orange.MajorityLearner(self.data)
self.majorityClassifier = data and orange.MajorityLearner(self.data)
self.rulesClass = [] # list of istances SDRules
self.algorithm = "Subgroup discovery algorithm"
......@@ -125,13 +126,11 @@ class SD_Classifier(orange.Classifier):
else :
return dist
def addRulesForClass(self, listOfRules, targetClass):
targetClassRule = SDRule(self.data, targetClass, conditions=[], g =1)
tmp = SDRules(listOfRules, targetClassRule )
self.rulesClass.append( tmp)
def printAll(self):
rulesList = []
for rClass in self.rulesClass:
......
......@@ -62,7 +62,7 @@ def build_subgroups_finished(postdata, input_dict, output_dict):
# add id's
for i, rule in enumerate(rules.rules):
rule.id = i
return {'rules' : rules, 'classifier' : None}
return {'rules' : rules, 'classifier' : classifier}
def subgroup_bar_visualization(input_dict):
return {'rules' : None}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment