예제 #1
0
    def updateFilteredDataLens(self, cond=None):
        """Updates the number of examples that match individual conditions in criteria table.
        If cond is given, updates the given row and the corresponding OR row;
        if cond==None, updates the number of examples in OR rows.
        """
        if cond:
            condIdx = self.Conditions.index(cond)
            # idx1: the first non-OR condition above the clicked condition
            # idx2: the first OR condition below the clicked condition
            idx1 = 0
            idx2 = len(self.Conditions)
            for i in range(condIdx,idx1-1,-1):
                if self.Conditions[i].type == "OR":
                    idx1 = i+1
                    break
            for i in range(condIdx+1,idx2):
                if self.Conditions[i].type == "OR":
                    idx2 = i
                    break
            fdListAll = self.getFilterList(self.data.domain, self.Conditions[idx1:idx2], enabledOnly=False)
            fdListEnabled = self.getFilterList(self.data.domain, self.Conditions[idx1:idx2], enabledOnly=True)
            # if we click on the row which has a preceeding OR: update OR at index idx1-1
            if idx1 > 0:
                self.criteriaTable.cellWidget(idx1-1,0).setText(str(len(orange.Filter_conjunction(fdListEnabled[0])(self.data))))
            # update the clicked row
            self.criteriaTable.cellWidget(condIdx,0).setText(str(len(fdListAll[0][condIdx-idx1](self.data))))

        elif len(self.Conditions) > 0:
            # update all "OR" rows
            fdList = self.getFilterList(self.data.domain, self.Conditions, enabledOnly=True)
            idx = 1
            for row,cond in enumerate(self.Conditions):
                if cond.type == "OR":
                    self.criteriaTable.cellWidget(row,0).setText(str(len(orange.Filter_conjunction(fdList[idx])(self.data))))
                    idx += 1
예제 #2
0
    def setOutput(self):
        matchingOutput = self.data
        nonMatchingOutput = None
        hasClass = False
        if self.data:
            hasClass = bool(self.data.domain.classVar)
            filterList = self.getFilterList(self.data.domain, self.Conditions, enabledOnly=True)
            if len(filterList)>0:
                filter = orange.Filter_disjunction([orange.Filter_conjunction(l) for l in filterList])
            else:
                filter = orange.Filter_conjunction([]) # a filter that does nothing
            matchingOutput = filter(self.data, 1)
            matchingOutput.name = self.data.name
            nonMatchingOutput = filter(self.data, 1, negate=1)
            nonMatchingOutput.name = self.data.name

            if self.purgeAttributes or self.purgeClasses:
                remover = orange.RemoveUnusedValues(removeOneValued=True)

                newDomain = remover(matchingOutput, 0, True, self.purgeClasses)
                if newDomain != matchingOutput.domain:
                    matchingOutput = orange.ExampleTable(newDomain, matchingOutput)

                newDomain = remover(nonMatchingOutput, 0, True, self.purgeClasses)
                if newDomain != nonMatchingOutput.domain:
                    nonmatchingOutput = orange.ExampleTable(newDomain, nonMatchingOutput)

        self.send("Matching Data", matchingOutput)
        self.send("Unmatched Data", nonMatchingOutput)

        self.updateInfoOut(matchingOutput)
예제 #3
0
    def setOutput(self):
        matchingOutput = self.data
        nonMatchingOutput = None
        hasClass = False
        if self.data:
            hasClass = bool(self.data.domain.classVar)
            filterList = self.getFilterList(self.data.domain, self.Conditions, enabledOnly=True)
            if len(filterList)>0:
                filter = orange.Filter_disjunction([orange.Filter_conjunction(l) for l in filterList])
            else:
                filter = orange.Filter_conjunction([]) # a filter that does nothing
            matchingOutput = filter(self.data, 1)
            matchingOutput.name = self.data.name
            nonMatchingOutput = filter(self.data, 1, negate=1)
            nonMatchingOutput.name = self.data.name

            if self.purgeAttributes or self.purgeClasses:
                ##scPA  Using instead the method getDataWithoutUnusedValues of dataUtilities
                matchingOutput = dataUtilities.getDataWithoutUnusedValues(matchingOutput, self.purgeClasses)
                nonmatchingOutput = dataUtilities.getDataWithoutUnusedValues(nonMatchingOutput, self.purgeClasses)
                #remover = orange.RemoveUnusedValues(removeOneValued=True)

                #newDomain = remover(matchingOutput, 0, True, self.purgeClasses)
                #if newDomain != matchingOutput.domain:
                #    matchingOutput = orange.ExampleTable(newDomain, matchingOutput)

                #newDomain = remover(nonMatchingOutput, 0, True, self.purgeClasses)
                #if newDomain != nonMatchingOutput.domain:
                #    nonmatchingOutput = orange.ExampleTable(newDomain, nonMatchingOutput)
                ##ecPA

        self.send("Matching Examples", matchingOutput)
        self.send("Non-Matching Examples", nonMatchingOutput)

        self.updateInfoOut(matchingOutput)
예제 #4
0
print "\n\nYoung and presbyopic examples\n"
for ex in fya(data):
    print ex

astigm = data.domain["astigmatic"]
fya["age"] = ["presbyopic", "young"]
fya[astigm] = "yes"
print "\n\nYoung and presbyopic examples that are astigmatic\n"
for ex in fya(data):
    print ex

fr = orange.Filter_values(domain=data.domain)
fr[3] = "reduced"

# Conjunction is not necessary here - we could still do this with a single filter
fcon = orange.Filter_conjunction([fya, fr])
print "\n\nYoung and presbyopic examples that are astigmatic and have reduced tear rate\n"
for ex in fcon(data):
    print ex

fcon = orange.Filter_disjunction([fya, fr])
print "\n\nYoung and presbyopic asticmatic examples and examples that have reduced tear rate\n"
for ex in fcon(data):
    print ex

############ THIS IS WHAT YOU CAN DO WITH CONTINUOUS ATTRIBUTES

data = orange.ExampleTable("iris")

fcont = orange.Filter_values(domain=data.domain)
fcont[0] = (orange.ValueFilter.Equal, 4.59999999999999