How to use the orange.Value function in Orange

To help you get started, we’ve selected a few Orange examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github biolab / orange2 / orange / orng / orngMosaic.py View on Github external
def classifyExample(self, ex, what = orange.Classifier.GetValue):
        val = self.classVar.getValueFrom(ex).value
        classDist = orange.ContingencyAttrClass(self.classVar, self.data)[val]
        classValue = classDist.keys()[classDist.values().index(max(classDist.values()))]
        if what == orange.Classifier.GetValue:
            return orange.Value(self.data.domain.classVar, classValue)
        elif what == orange.Classifier.GetProbabilities:
            return classDist
        else:
            return (orange.Value(self.data.domain.classVar, classValue), classDist)
github biolab / orange2 / orange / doc / reference / transformvalue-d2c.py View on Github external
e1 = orange.FloatVariable("e=1")
e1.getValueFrom = orange.ClassifierFromVar(whichVar = e)
e1.getValueFrom.transformer = orange.Discrete2Continuous()
e1.getValueFrom.transformer.value = int(orange.Value(e, "1"))

e10 = orange.FloatVariable("e=1")
e10.getValueFrom = orange.ClassifierFromVar(whichVar = e)
e10.getValueFrom.transformer = orange.Discrete2Continuous()
e10.getValueFrom.transformer.value = int(orange.Value(e, "1"))
e10.getValueFrom.transformer.zeroBased = False

e01 = orange.FloatVariable("e=1")
e01.getValueFrom = orange.ClassifierFromVar(whichVar = e)
transformer = e01.getValueFrom.transformer = orange.Discrete2Continuous()
transformer.value = int(orange.Value(e, "1"))
transformer.zeroBased = False
transformer.invert = True


newDomain = orange.Domain([e, e1, e10, e01], data.domain.classVar)
newData = orange.ExampleTable(newDomain, data)
for ex in newData[:10]:
    print ex
print "\n\n"

attributes = [e]
for v in e.values:
    newattr = orange.FloatVariable("e=%s" % v)
    newattr.getValueFrom = orange.ClassifierFromVar(whichVar = e)
    newattr.getValueFrom.transformer = orange.Discrete2Continuous()
    newattr.getValueFrom.transformer.value = int(orange.Value(e, v))
github biolab / orange2 / orange / orng / orngVisFuncts.py View on Github external
    selection.getValueFrom = lambda ex, what: orange.Value(selection, "0")
    data1 = orange.ExampleTable(d1, shortData1)
github biolab / orange2 / Orange / OrangeWidgets / Evaluate / OWPredictions.py View on Github external
                    getValueFrom=lambda ex, rw, c=c: orange.Value(c(ex)))
                  for c in self.predictors.values()]
github biolab / orange2 / orange / doc / reference / filter.py View on Github external
)
for ex in fya(data):
    print ex

print "\nYoung or presbyopic with astigmatism"
fya = orange.Filter_values(domain = data.domain,
                           conditions = [orange.ValueFilter_discrete(position = data.domain.attributes.index(age), values=[orange.Value(age, "young"), orange.Value(age, "presbyopic")], acceptSpecial = 1),
                                         orange.ValueFilter_discrete(position = data.domain.attributes.index(astigm), values=[orange.Value(astigm, "yes")])
                                        ],
                          )
for ex in fya(data):
    print ex

print "\nYoung or presbyopic or astigmatic"
fya = orange.Filter_values(domain = data.domain,
                           conditions = [orange.ValueFilter_discrete(position = data.domain.attributes.index(age), values=[orange.Value(age, "young"), orange.Value(age, "presbyopic")], acceptSpecial = 1),
                                         orange.ValueFilter_discrete(position = data.domain.attributes.index(astigm), values=[orange.Value(astigm, "yes")])
                                        ],
                           conjunction = 0
                          )
for ex in fya(data):
    print ex
github biolab / orange2 / orange / doc / reference / values.py View on Github external
import orange

def err():
    raise Exception("Error")

fruit = orange.EnumVariable("fruit", values = ["plum", "apple", "lemon"])
iq = orange.FloatVariable("iq")
lm = orange.Value(fruit, "lemon")
ap = orange.Value(fruit, 1)
un = orange.Value(fruit)

Mary = orange.Value(iq, "105")
Harry = orange.Value(iq, 80)
Dick = orange.Value(iq)

sf = orange.Value(2)
Sally = orange.Value(118.0)

sf.variable = fruit


city = orange.Value(orange.StringValue("Cicely"))



if (lm!="lemon"): raise error
if (lm<"apple"): raise error
if (orange.Value(1)>lm): raise error


deg3 = orange.EnumVariable(values=["little", "medium", "big"])
deg4 = orange.EnumVariable(values=["tiny", "little", "big", "huge"])
github biolab / orange2 / orange / OrangeWidgets / OWVisAttrSelection.py View on Github external
    selection.getValueFrom = lambda ex, what: orange.Value(selection, "0")
    data1 = orange.ExampleTable(d1, shortData1)
github biolab / orange2 / Orange / OrangeWidgets / Evaluate / OWPredictions.py View on Github external
                                              getValueFrom = lambda ex, rw, cindx=i, c=c: orange.Value(c(ex, c.GetProbabilities)[cindx])) \
                         for i in self.selectedClasses]
github biolab / orange2 / orange / doc / reference / values.py View on Github external
# Classes:     Value
# Uses:        
# Referenced:  Value.htm

import orange

def err():
    raise Exception("Error")

fruit = orange.EnumVariable("fruit", values = ["plum", "apple", "lemon"])
iq = orange.FloatVariable("iq")
lm = orange.Value(fruit, "lemon")
ap = orange.Value(fruit, 1)
un = orange.Value(fruit)

Mary = orange.Value(iq, "105")
Harry = orange.Value(iq, 80)
Dick = orange.Value(iq)

sf = orange.Value(2)
Sally = orange.Value(118.0)

sf.variable = fruit


city = orange.Value(orange.StringValue("Cicely"))



if (lm!="lemon"): raise error
if (lm<"apple"): raise error
if (orange.Value(1)>lm): raise error
github biolab / orange2 / docs / tutorial / rst / code / bayes.py View on Github external
# compute the class probabilities
        p = map(None, self.p_class)
        for c in range(len(self.domain.classVar.values)):
            for a in range(len(self.domain.attributes)):
                if not example[a].isSpecial():
                    p[c] *= self.p_cond[a][int(example[a])][c]
                    
        # normalize probabilities to sum to 1
        sum =0.
        for pp in p: sum += pp
        if sum>0:
            for i in range(len(p)): p[i] = p[i]/sum
            
        # find the class with highest probability
        v_index = p.index(max(p))
        v = orange.Value(self.domain.classVar, v_index)

        # return the value based on requested return type
        if result_type == orange.GetValue:
            return v
        if result_type == orange.GetProbabilities:
            return p
        return (v,p)