How to use the orange.FloatVariable 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 pandastrike / bayzee / src / classifier.py View on Github external
def __getOrangeVariableForFeature(self, feature):
    if feature["is_numerical"]: 
      return orange.FloatVariable(feature["name"])
    else:
      return orange.EnumVariable(feature["name"])
github biolab / orange2 / orange / Orange / classify / logreg.py View on Github external
def createLogRegExampleTable(data, weightID):
            setsOfData = []
            for at in data.domain.attributes:
                # za vsak atribut kreiraj nov newExampleTable newData
                # v dataOrig, dataFinal in newData dodaj nov atribut -- continuous variable
                if at.varType == orange.VarTypes.Continuous:
                    atDisc = orange.FloatVariable(at.name + "Disc")
                    newDomain = orange.Domain(data.domain.attributes+[atDisc,data.domain.classVar])
                    newDomain.addmetas(data.domain.getmetas())
                    newData = orange.ExampleTable(newDomain,data)
                    altData = orange.ExampleTable(newDomain,data)
                    for i,d in enumerate(newData):
                        d[atDisc] = 0
                        d[weightID] = 1*data[i][weightID]
                    for i,d in enumerate(altData):
                        d[atDisc] = 1
                        d[at] = 0
                        d[weightID] = 0.000001*data[i][weightID]
                elif at.varType == orange.VarTypes.Discrete:
                # v dataOrig, dataFinal in newData atributu "at" dodaj ee  eno  vreednost, ki ima vrednost kar  ime atributa +  "X"
                    atNew = orange.EnumVariable(at.name, values = at.values + [at.name+"X"])
                    newDomain = orange.Domain(filter(lambda x: x!=at, data.domain.attributes)+[atNew,data.domain.classVar])
                    newDomain.addmetas(data.domain.getmetas())
github biolab / orange2 / Orange / OrangeWidgets / Evaluate / OWConfusionMatrix.py View on Github external
domain = orange.Domain(data.domain.attributes, data.domain.classVar)
            domain.addmetas(data.domain.getmetas())
            data = orange.ExampleTable(domain, data)
        
            if self.appendPredictions:
                cname = self.learnerNames[learnerI]
                predVar = type(domain.classVar)("%s(%s)" % (domain.classVar.name, cname.encode("utf-8") if isinstance(cname, unicode) else cname))
                if hasattr(domain.classVar, "values"):
                    predVar.values = domain.classVar.values
                predictionsId = orange.newmetaid()
                domain.addmeta(predictionsId, predVar)
                for i, ex in zip(selectionIndices, data):
                    ex[predictionsId] = res.results[i].classes[learnerI]
                    
            if self.appendProbabilities:
                probVars = [orange.FloatVariable("p(%s)" % v) for v in domain.classVar.values]
                probIds = [orange.newmetaid() for pv in probVars]
                domain.addmetas(dict(zip(probIds, probVars)))
                for i, ex in zip(selectionIndices, data):
                    for id, p in zip(probIds, res.results[i].probabilities[learnerI]):
                        ex[id] = p

        if data is not None:
            data.name = self.learnerNames[learnerI]

        self.send("Selected Data", data)
github biolab / orange2 / Orange / OrangeWidgets / VisualizeQt / OWMDSQt.py View on Github external
def sendList(self, selectedInd):
        if self.data and type(self.data[0]) == str:
            xAttr=orange.FloatVariable("X")
            yAttr=orange.FloatVariable("Y")
            nameAttr=  orange.StringVariable("name")
            if self.selectionOptions == 1:
                domain = orange.Domain([xAttr, yAttr, nameAttr])
                selection = orange.ExampleTable(domain)
                for i in range(len(selectedInd)):
                    selection.append(list(self.mds.points[selectedInd[i]]) + [self.data[i]])
            else:
                domain = orange.Domain([nameAttr])
                if self.selectionOptions:
                    domain.addmeta(orange.newmetaid(), xAttr)
                    domain.addmeta(orange.newmetaid(), yAttr)
                selection = orange.ExampleTable(domain)
                for i in range(len(selectedInd)):
                    selection.append([self.data[i]])
                    if self.selectionOptions:
github biolab / orange2 / Orange / OrangeWidgets / Data / OWOutliers.py View on Github external
def applySettings(self):              
        """use the setting from the widget, identify the outliers"""
        if self.haveInput == 1:
            outlier = self.outlier
            outlier.setKNN(self.ks[self.k][1])
       
            newdomain = orange.Domain(self.data.domain)
            newdomain.addmeta(orange.newmetaid(), orange.FloatVariable("Z score"))
            
            self.newdata = orange.ExampleTable(newdomain, self.data)

            zv = outlier.zValues()
            for i, el in enumerate(zv):
                self.newdata[i]["Z score"] = el            

            self.send("Data with z-score", self.newdata)
            
            filterout = orange.Filter_values(domain=self.newdata.domain)
            filterout["Z score"] = (orange.Filter_values.Greater, eval(self.zscore))
            outliers = filterout(self.newdata)

            filterin = orange.Filter_values(domain=self.newdata.domain)
            filterin["Z score"] = (orange.Filter_values.LessEqual, eval(self.zscore))
            inliers = filterin(self.newdata)
github biolab / orange2 / orange / doc / networks / makeNetworkList.py View on Github external
import os
import os.path
import glob

import orange
import orngNetwork

atts = []
atts.append(orange.StringVariable("Network Name"))
atts.append(orange.StringVariable("Network File"))
atts.append(orange.StringVariable("dir"))
atts.append(orange.StringVariable("Item Set"))
atts.append(orange.StringVariable("Edge Set"))
atts.append(orange.FloatVariable("Vertices"))
atts[-1].numberOfDecimals = 0
atts.append(orange.FloatVariable("Edges"))
atts[-1].numberOfDecimals = 0
atts.append(orange.StringVariable("Date"))
atts.append(orange.StringVariable("Description"))

netlist = orange.ExampleTable(orange.Domain(atts, False))

for netFile in glob.glob(os.path.join(os.getcwd(), '*.net')):
	net = orngNetwork.Network.read(netFile)
	name, ext = os.path.splitext(netFile)
	
	itemFile = ""
	if os.path.exists(name + '_items.tab'):
		itemFile = name + '_items.tab'
	elif os.path.exists(name + '.tab'):
		itemFile = name + '.tab'
github biolab / orange2 / Orange / OrangeWidgets / VisualizeQt / OWMDSQt.py View on Github external
def sendExampleTable(self, selectedInd):
        if self.selectionOptions==0:
            self.send("Data", orange.ExampleTable(self.data.getitems(selectedInd)))
        else:
            xAttr=orange.FloatVariable("X")
            yAttr=orange.FloatVariable("Y")
            if self.selectionOptions==1:
                domain=orange.Domain([xAttr, yAttr]+[v for v in self.data.domain.variables])
                domain.addmetas(self.data.domain.getmetas())
            else:
                domain=orange.Domain(self.data.domain)
                domain.addmeta(orange.newmetaid(), xAttr)
                domain.addmeta(orange.newmetaid(), yAttr)
            selection=orange.ExampleTable(domain)
            selection.extend(self.data.getitems(selectedInd))
            for i in range(len(selectedInd)):
                selection[i][xAttr]=self.mds.points[selectedInd[i]][0]
                selection[i][yAttr]=self.mds.points[selectedInd[i]][1]
            self.send("Data", selection)
github biolab / orange2 / Orange / OrangeWidgets / Unsupervised / OWMDS.py View on Github external
def sendExampleTable(self, selectedInd):
        if self.selectionOptions == 0:
            self.send("Data", orange.ExampleTable(self.data.getitems(selectedInd)))
        else:
            xAttr = orange.FloatVariable("X")
            yAttr = orange.FloatVariable("Y")
            if self.selectionOptions == 1:
                domain = orange.Domain([xAttr, yAttr] + 
                                       [v for v in self.data.domain.variables])
                domain.addmetas(self.data.domain.getmetas())
            else:
                domain = orange.Domain(self.data.domain)
                domain.addmeta(orange.newmetaid(), xAttr)
                domain.addmeta(orange.newmetaid(), yAttr)
            selection = orange.ExampleTable(domain)
            selection.extend(self.data.getitems(selectedInd))
            for i in range(len(selectedInd)):
                selection[i][xAttr] = self.mds.points[selectedInd[i]][0]
                selection[i][yAttr] = self.mds.points[selectedInd[i]][1]
            self.send("Data", selection)
github biolab / orange2 / orange / orng / orngMosaic.py View on Github external
def evaluateAttributeOrder(self, attrs, valueOrder, conditions, revert, domain = None):
        if not domain:
            domain = orange.Domain([orange.FloatVariable("xVar"), orange.FloatVariable("yVar"), self.data.domain.classVar])
            self.weightID = orange.newmetaid()
            domain.addmeta(self.weightID, orange.FloatVariable("ExampleWeight"))
        projData = orange.ExampleTable(domain)
        projData.domain.classVar.distributed = True

        triedIndices = [0]*(len(attrs))
        maxVals = [len(val) for val in valueOrder]
        xpos = 0; ypos = 0
        while triedIndices[0] < maxVals[0]:
            vals = [valueOrder[i][triedIndices[i]] for i in range(len(attrs))]
            combVal = reduce(operator.concat, map(operator.concat, [vals[i] for i in revert], ["-"]*len(vals)))[:-1]
            if conditions[combVal][0] > 0:
                #projData.append([xpos, ypos, conditions[combVal][1]])
                projData.append([xpos, ypos, projData.domain.classVar.values[0]])
                val = orange.Value(projData.domain.classVar, conditions[combVal][1])
                val.svalue = conditions[combVal][2]
github biolab / orange2 / orange / orng / orngPade.py View on Github external
def createQTable(cache, data, dimensions, outputAttr = -1, threshold = 0, MQCNotation = False, derivativeAsMeta = False, differencesAsMeta = False, correlationsAsMeta = False, originalAsMeta = False):
    nDimensions = len(dimensions)
    
    needQ = outputAttr < 0 or derivativeAsMeta
    if needQ:
        qVar = createClassVar([cache.attributes[i][0] for i in dimensions], MQCNotation)
        
    if outputAttr >= 0:
        classVar = orange.FloatVariable("df/d"+cache.attributes[outputAttr][0])
    else:
        classVar = qVar
            
    dom = orange.Domain(data.domain.attributes, classVar)
    dom.addmetas(data.domain.getmetas())
    setattr(dom, "constraintAttributes", [cache.contAttributes[i] for i in dimensions])

    if derivativeAsMeta:
        derivativeID = orange.newmetaid()
        dom.addmeta(derivativeID, qVar)
    else:
        derivativeID = 0
            
    metaIDs = []        
    if differencesAsMeta:
        for dim in dimensions: