rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if None in vals or abs(sum(vals)) >= abs(args[key][0]):
if None in vals or abs(sum(vals)) >= abs(args[key][0]) or not sum([abs(val) == val for val in vals]) in [0, len(vals)]:
def removeWeakerArguments(self): if not self.arguments or not self.arguments.values(): return
def getDataSubset(self, attrList, attrValues): temp = self.data.selectref(dict([(attrList[i], attrValues[i]) for i in range(len(attrList))])) filter = orange.Filter_isDefined(domain=self.data.domain) for v in self.data.domain.variables: filter.check[v] = v.name in attrList return filter(temp)
def getInteractionImportanceProbability(self, attrList, attrValues, subData = None, contingencies = None, aprioriDistribution = None, subDataDistribution = None): assert len(attrList) == len(attrValues)
if self.Mosaic.__class__.__name__ == "OWMosaicOptimization": self.Mosaic.useTimeLimit = 1
def __init__(self, mosaic, data): self.Mosaic = mosaic
if self.Mosaic.__class__.__name__ == "OWMosaicOptimization": del self.Mosaic.useTimeLimit
def __init__(self, mosaic, data): self.Mosaic = mosaic
classVal, prob = self.Mosaic.findArguments(example, 0, 0) else: classVal, prob = self.Mosaic.findArguments(example)
classVal, prob = self.Mosaic.findArguments(example)
def __call__(self, example, returnType = orange.GetBoth): if self.Mosaic.__class__.__name__ == "OWMosaicOptimization": table = orange.ExampleTable(example.domain) table.append(example) self.Mosaic.parentWidget.subsetdataHander(table) classVal, prob = self.Mosaic.findArguments(example, 0, 0) else: classVal, prob = self....
import time
def __call__(self, attr, data): # if the data changed clear the attribute values if data != self.data: self.attrInfo = {} self.data = data
def __call__(self, attr, data): if data.domain[attr].varType == orange.VarTypes.Discrete:
self.sortedAttrList = None def __call__(self, attribute, data): if data.domain[attribute].varType == orange.VarTypes.Discrete:
def __init__(self): S2NMeasure.__init__(self) self.attrInfoMix = {} self.dataMix = None
evalAttrs = []
attrPositionsDict = dict([(attr, []) for attr in cls[0]]) for arr in cls: for i in range(len(arr)): attrPositionsDict[arr[i]].append(i)
def __call__(self, attr, data): if data.domain[attr].varType == orange.VarTypes.Discrete: print "S2NMeasureMix can not evaluate discrete attributes" return -1 # if the data changed clear the attribute values if data != self.dataMix: self.attrInfoMix = {} self.attrInfo = {} self.dataMix = data
if len(cls[i]) == 0: continue attr = cls[i][0] evalAttrs.append(attr) for j in range(numClasses): cls[j].remove(attr)
pos = currPos[i] while pos < len(cls[i]) and cls[i][pos] == None: pos += 1 currPos[i] = pos + 1 if pos >= len(cls[i]): continue
def __call__(self, attr, data): if data.domain[attr].varType == orange.VarTypes.Discrete: print "S2NMeasureMix can not evaluate discrete attributes" return -1 # if the data changed clear the attribute values if data != self.dataMix: self.attrInfoMix = {} self.attrInfo = {} self.dataMix = data
count = len(evalAttrs) for (i, attr) in enumerate(evalAttrs):
attr = cls[i][pos] self.sortedAttrList.append(attr) attrPositions = attrPositionsDict[attr] for j in range(numClasses): cls[j][attrPositions[j]] = None count = len(self.sortedAttrList) for (i, attr) in enumerate(self.sortedAttrList):
def __call__(self, attr, data): if data.domain[attr].varType == orange.VarTypes.Discrete: print "S2NMeasureMix can not evaluate discrete attributes" return -1 # if the data changed clear the attribute values if data != self.dataMix: self.attrInfoMix = {} self.attrInfo = {} self.dataMix = data
if self.attrInfoMix.has_key(data.domain[attr].name): return self.attrInfoMix[data.domain[attr].name]
if self.attrInfoMix.has_key(data.domain[attribute].name): return self.attrInfoMix[data.domain[attribute].name]
def __call__(self, attr, data): if data.domain[attr].varType == orange.VarTypes.Discrete: print "S2NMeasureMix can not evaluate discrete attributes" return -1 # if the data changed clear the attribute values if data != self.dataMix: self.attrInfoMix = {} self.attrInfo = {} self.dataMix = data
contAttrs = [] for attr in data.domain.attributes: if attr.varType == orange.VarTypes.Continuous: contAttrs.append(attr.name) attrVals = [(measure(attr, data), attr) for attr in contAttrs] attrVals.sort() attrVals.reverse() attrNames = [attrVals[i][1] for i in range(len(attrVals))] numClasses = len(data.domain.classV...
if isinstance(measure, S2NMeasureMix): measure(data.domain.attributes[0].name, data) attrNames = [data.domain[ind].name for ind in measure.sortedAttrList] numClasses = len(data.domain.classVar.values) cls = [attrNames[i::numClasses] for i in range(numClasses)] else: attrVals = [(measure(attr.name, data), attr.name) for...
def findAttributeGroupsForRadviz(data, measure): contAttrs = [] for attr in data.domain.attributes: if attr.varType == orange.VarTypes.Continuous: contAttrs.append(attr.name) attrVals = [(measure(attr, data), attr) for attr in contAttrs] attrVals.sort() attrVals.reverse() attrNames = [attrVals[i][1] for i in range(len...
if inS.name not in inConnected + addedInLinks or not inS.single:
if inS.name not in inConnected + addedInLinks or (not inS.single and inS.name not in addedInLinks):
def addDefaultLinks(self): canConnect = 0 addedInLinks = [] addedOutLinks = [] self.multiplePossibleConnections = 0 # can we connect some signal with more than one widget
if self.best:
if self.best is not None:
def winnerIndex(self): if self.best: return self.bestIndex else: return None
self.locOptAttrsToTry = 100
self.locOptAttrsToTry = 50
def __init__(self, visualizationMethod, graph = None): if not graph: if visualizationMethod == SCATTERPLOT: import orngScaleScatterPlotData graph = orngScaleScatterPlotData.orngScaleScatterPlotData() elif visualizationMethod == RADVIZ: import orngScaleLinProjData graph = orngScaleLinProjData.orngScaleLinProjData() grap...
if self.locOptOptimizeProjectionByPermutingAttributes == 1 and self.useSupervisedPCA == 1:
if self.locOptOptimizeProjectionByPermutingAttributes == 1 and self.useSupervisedPCA == 0:
def optimizeBestProjections(self, restartWhenImproved = 1): random.seed(0) # always use the same seed to make results repeatable count = min(len(self.results), self.locOptProjCount) if not count: return self.correctSettingsIfNecessary() self.optimizedProjectionsCount = 0 """ if self.optimizeTimeLimit == self.optim...
while failedConsecutiveTries < 30:
while failedConsecutiveTries < 5 and tries < 50:
def optimizeBestProjections(self, restartWhenImproved = 1): random.seed(0) # always use the same seed to make results repeatable count = min(len(self.results), self.locOptProjCount) if not count: return self.correctSettingsIfNecessary() self.optimizedProjectionsCount = 0 """ if self.optimizeTimeLimit == self.optim...
self.addResult(acc, other_results, len(table), [self.graph.attributeNames[i] for i in newProj], -1, {})
def optimizeBestProjections(self, restartWhenImproved = 1): random.seed(0) # always use the same seed to make results repeatable count = min(len(self.results), self.locOptProjCount) if not count: return self.correctSettingsIfNecessary() self.optimizedProjectionsCount = 0 """ if self.optimizeTimeLimit == self.optim...
self.insertTempProjection(projections, acc, attrList) self.addResult(acc, other_results, lenTable, [self.graph.attributeNames[i] for i in attrList], -1, {}) if hasattr(self, "setStatusBarText"): self.setStatusBarText("Found a better projection with accuracy: %2.2f%%" % (acc)) if acc/accuracy > 1.005: significantImprov...
if acc/accuracy > 1.005: self.insertTempProjection(projections, acc, attrList) self.addResult(acc, other_results, lenTable, [self.graph.attributeNames[i] for i in attrList], -1, {}) if hasattr(self, "setStatusBarText"): self.setStatusBarText("Found a better projection with accuracy: %2.2f%%" % (acc)) if acc/accuracy > ...
def optimizeBestProjections(self, restartWhenImproved = 1): random.seed(0) # always use the same seed to make results repeatable count = min(len(self.results), self.locOptProjCount) if not count: return self.correctSettingsIfNecessary() self.optimizedProjectionsCount = 0 """ if self.optimizeTimeLimit == self.optim...
sys.stdout.flush()
def testScripts(complete): if sys.platform == "win32": import win32process, win32api win32process.SetPriorityClass(win32api.GetCurrentProcess(), 64) skip = ["buildC45.py"] for dir in os.listdir("."): if not os.path.isdir(dir) or dir in ["cvs", "datasets", "widgets"] or (directories and not dir in directories): continu...
testResults.results = [TestedExample(folds[i], int(examples[i].getclass()), nLrn, examples[i].getweight(weight))
testResults.results = [TestedExample(folds[i], conv(examples[i].getclass()), nLrn, examples[i].getweight(weight))
def learningCurve(learners, examples, cv=None, pick=None, proportions=orange.frange(0.1), pps=[], **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) callback = argkw.get("callback", 0) for pp in pps: if pp[0]!="L": raise SystemError, "cannot preprocess testing examples" if not cv or not pick: seed...
conv = examples.domain.classVar.varType == orange.VarTypes.Discrete and int or float
def testWithIndices(learners, examples, indices, indicesrandseed="*", pps=[], callback=None, **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) storeclassifiers = argkw.get("storeclassifiers", 0) or argkw.get("storeClassifiers", 0) cache = cache and not storeclassifiers examples, weight = demangle...
testResults.results = [TestedExample(indices[i], int(examples[i].getclass()), nLrn, examples[i].getweight(weight))
testResults.results = [TestedExample(indices[i], conv(examples[i].getclass()), nLrn, examples[i].getweight(weight))
def testWithIndices(learners, examples, indices, indicesrandseed="*", pps=[], callback=None, **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) storeclassifiers = argkw.get("storeclassifiers", 0) or argkw.get("storeClassifiers", 0) cache = cache and not storeclassifiers examples, weight = demangle...
self.inputs = [("Examples", ExampleTable, self.dataset),("Classifiers", orange.Classifier, self.classifier, 0)]
self.inputs = [("Examples", ExampleTable, self.dataset),("Classifiers", orange.Classifier, self.classifier, Multiple)]
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Classifications")
hi = self.CutEnabled and self.CutHigh or self.upperBound
hi = round(self.CutEnabled and self.CutHigh or self.upperBound, 1)
def drawDistanceMap(self):
self.legendText1.setText(str(self.CutLow)) self.legendText2.setText(str(self.CutHigh))
self.legendText1.setText(str(lo)) self.legendText2.setText(str(hi))
def drawDistanceMap(self):
testref(data.filterref(LENGTH=(-9999, 9999))) testref(data.filterlist(LENGTH=(-9999, 9999)))
testref(data.filterref(filterany)) testref(data.filterlist(filterany))
def testref(mid): pd0 = data[0][1] mid[0][1] += 1 if pd0 == data[0][1]: raise "not reference when there should be"
i = 0
def getVariableValuesSorted(data, index): if data.domain[index].varType == orange.VarTypes.Continuous: print "Invalid index for getVariableValuesSorted" return [] values = list(data.domain[index].values) intValues = [] i = 0 # do all attribute values containt integers? try: intValues = [int(val) for val in values] exc...
intValues = [int(val) for val in values]
intValues = [(int(val), val) for val in values]
def getVariableValuesSorted(data, index): if data.domain[index].varType == orange.VarTypes.Continuous: print "Invalid index for getVariableValuesSorted" return [] values = list(data.domain[index].values) intValues = [] i = 0 # do all attribute values containt integers? try: intValues = [int(val) for val in values] exc...
return [str(val) for val in intValues]
return [val[1] for val in intValues]
def getVariableValuesSorted(data, index): if data.domain[index].varType == orange.VarTypes.Continuous: print "Invalid index for getVariableValuesSorted" return [] values = list(data.domain[index].values) intValues = [] i = 0 # do all attribute values containt integers? try: intValues = [int(val) for val in values] exc...
print "unable to compute the inverse of a singular matrix."
def findSPCAProjection(self, attrIndices = None, setGraphAnchors = 1): try: import LinearAlgebra
return [self.graph.anchorData[i][0] for i in range(len(attributes))], [self.graph.anchorData[i][1] for i in range(len(attributes))], (attributes, attrIndices)
return [anchors[i][0] for i in range(len(attributes))], [anchors[i][1] for i in range(len(attributes))], (attributes, attrIndices)
def findSPCAProjection(self, attrIndices = None, setGraphAnchors = 1): try: import LinearAlgebra
self.operatorStack = QWidgetStack(boxOper)
def __init__(self, parent = None, signalManager = None, name = "Select data"): OWWidget.__init__(self, parent, signalManager, name) #initialize base class
self.lbOperatosNone = QListBox(None, 'SelAttr') self.operatorStack.addWidget(self.lbOperatosNone, 0)
self.lbOperatosNone = QListBox(boxOper, 'SelAttr')
def __init__(self, parent = None, signalManager = None, name = "Select data"): OWWidget.__init__(self, parent, signalManager, name) #initialize base class
self.lbOperatorsD = QListBox(None, 'SelAttr') self.operatorStack.addWidget(self.lbOperatorsD, orange.VarTypes.Discrete)
self.lbOperatorsD = QListBox(boxOper, 'SelAttr') self.lbOperatorsD.hide()
def __init__(self, parent = None, signalManager = None, name = "Select data"): OWWidget.__init__(self, parent, signalManager, name) #initialize base class
self.lbOperatorsC = QListBox(None, 'SelAttr') self.operatorStack.addWidget(self.lbOperatorsC, orange.VarTypes.Continuous)
self.lbOperatorsC = QListBox(boxOper, 'SelAttr') self.lbOperatorsC.hide()
def __init__(self, parent = None, signalManager = None, name = "Select data"): OWWidget.__init__(self, parent, signalManager, name) #initialize base class
self.lbOperatorsS = QListBox(None, 'SelAttr') self.operatorStack.addWidget(self.lbOperatorsS, orange.VarTypes.String)
self.lbOperatorsS = QListBox(boxOper, 'SelAttr') self.lbOperatorsS.hide()
def __init__(self, parent = None, signalManager = None, name = "Select data"): OWWidget.__init__(self, parent, signalManager, name) #initialize base class
self.connect(self.criteriaTable, SIGNAL('currentChanged(int, int)'), self.currentCriteriaChange)
self.connect(self.criteriaTable, SIGNAL('currentChanged(int, int)'), self.currentCriteriaChange) self.criteriaTable.adjustColumn(0) self.criteriaTable.setColumnWidth(1, 500)
def __init__(self, parent = None, signalManager = None, name = "Select data"): OWWidget.__init__(self, parent, signalManager, name) #initialize base class
self.operatorStack.raiseWidget(self.name2var[cond.varName].varType)
for vt,lb in self.lbOperatorsDict.items(): if vt == self.name2var[cond.varName].varType: lb.show() else: lb.hide()
def currentCriteriaChange(self, row, col): """Handles current row change in criteria table; select attribute and operator, and set values according to the selected condition. """ if row < 0: return self.btnRemove.setEnabled(True) self.btnUpdate.setEnabled(True) cond = self.Conditions[row] if cond.type == "OR": return #...
self.operatorStack.raiseWidget(varType)
for vt,lb in self.lbOperatorsDict.items(): if vt == varType: lb.show() else: lb.hide()
def updateOperatorStack(self): """Raises listbox with appropriate operators. """ if self.currentVar: varType = self.currentVar.varType else: varType = 0 self.operatorStack.raiseWidget(varType)
for (short, longName) in self.fileBuffer:
for i in range(len(self.fileBuffer)-1, -1, -1): (short, longName) = self.fileBuffer[i]
def __init__(self, parallelWidget, parent=None): OWBaseWidget.__init__(self, parent, "Parallel Optimization Dialog", "Find attribute subsets that are interesting to visualize using parallel coordinates", FALSE, FALSE, FALSE)
if numberOfIterations > 1:
if res.numberOfIterations > 1:
def AUC_binary(res, useWeights = True): if numberOfIterations > 1: return AUC_iterations(AUC_i, splitByIterations(res), (-1, useWeights, res, res.numberOfIterations)) else: return AUC_i([res], -1, useWeights)
if len(self.scaledData) == 0 or len(labels) == 0:
if not self.noJitteringScaledData or len(self.noJitteringScaledData) == 0 or len(labels) == 0:
def updateData(self, labels): self.removeCurves() self.tips.removeAll()
if self.scaledData[indices[j]][i] == "?": validData[i] = 0
if self.noJitteringScaledData[indices[j]][i] == "?": validData[i] = 0
def updateData(self, labels): self.removeCurves() self.tips.removeAll()
width = self.scaledData[indices[j]][i] * 0.45
width = self.noJitteringScaledData[indices[j]][i] * 0.45
def updateData(self, labels): self.removeCurves() self.tips.removeAll()
controlCallback(value)
for callback in controlCallback: callback(value)
def unisetattr(self, name, value, grandparent): if "." in name: names = name.split(".") lastname = names.pop() obj = reduce(lambda o, n: getattr(o, n, None), names, self) else: lastname, obj = name, self if not obj: print "unable to set setting ", name, " to value ", value else: if hasattr(grandparent, "__setattr__")...
dict.__setitem__(self, key, value)
if not self.has_key(key): dict.__setitem__(self, key, [value]) else: dict.__getitem__(self, key).append(value)
def __setitem__(self, key, value): dict.__setitem__(self, key, value) self.master.setControllers(self.master, key, self.master, "")
url = "/widgets/catalog/%s/%s.htm" % (self.category, self.name())
def openWidgetHelp(self): url = "/widgets/catalog/%s/%s.htm" % (self.category, self.name())
win32help.HtmlHelp(0, orangedir + "/doc/widgets.chm::" + url, win32help.HH_DISPLAY_TOPIC)
win32help.HtmlHelp(0, "%s/doc/catalog.chm::/catalog/%s/%s.htm" % (orangedir, self.category, self.__class__.__name__[2:]), win32help.HH_DISPLAY_TOPIC)
def openWidgetHelp(self): url = "/widgets/catalog/%s/%s.htm" % (self.category, self.name())
webbrowser.open("file://" + orangedir + "/doc" + url, 0, 1)
webbrowser.open("file://%s/doc/widgets/catalog/%s/%s.htm" % (orangedir, self.category, self.__class__.__name__[2:]), 0, 1)
def openWidgetHelp(self): url = "/widgets/catalog/%s/%s.htm" % (self.category, self.name())
webbrowser.open("http://www.ailab.si/orange/doc"+url)
webbrowser.open("http://www.ailab.si/orange/doc/widgets/catalog/%s/%s.htm" % (self.category, self.__class__.__name__[2:]))
def openWidgetHelp(self): url = "/widgets/catalog/%s/%s.htm" % (self.category, self.name())
self.coefficient = 1.0/math.sqrt(reduce(lambda x,y:x+y*y,xcoeffs))
sum = 0.0 for x in xcoeffs: sum += x*x self.coefficient = 1.0/math.sqrt(sum)
def __init__(self, model, translate, normalize): self._name = "SVM Classifier Wrap" self.model = model self.cmodel = orngCRS.SVMClassifier(model) self.translate = translate self.normalize = normalize
minx,maxx,miny,maxy = self.getQCanvasBoundaries() factor = min(float(width)/(maxx-minx), float(height)/(maxy-miny))
factor = 1.0 if isinstance(self.graph, QCanvas): minx,maxx,miny,maxy = self.getQCanvasBoundaries() factor = min(float(width)/(maxx-minx), float(height)/(maxy-miny))
def printPic(self): printer = QPrinter() size = self.getSize()
if text == "\n": return
text = str(text)
def write(self, text): # is this some extra info for debuging #if len(text) > 7 and text[0:7] == "<extra>": # if not self.printExtraOutput: return # text = text[7:] if text == "\n": return
text = text.replace("\n", "<br>/n") text = "<nobr>" + text + "</nobr>"
text = text.replace("\n", "<br>\n")
def write(self, text): # is this some extra info for debuging #if len(text) > 7 and text[0:7] == "<extra>": # if not self.printExtraOutput: return # text = text[7:] if text == "\n": return
self.logFile.write(str(text) + "<br>\n")
self.logFile.write(text)
def write(self, text): # is this some extra info for debuging #if len(text) > 7 and text[0:7] == "<extra>": # if not self.printExtraOutput: return # text = text[7:] if text == "\n": return
self.textOutput.append(str(text))
self.textOutput.setText(str(self.textOutput.text()) + text)
def write(self, text): # is this some extra info for debuging #if len(text) > 7 and text[0:7] == "<extra>": # if not self.printExtraOutput: return # text = text[7:] if text == "\n": return
if self.printOutput:
if self.printOutput and text != "<br>\n":
def write(self, text): # is this some extra info for debuging #if len(text) > 7 and text[0:7] == "<extra>": # if not self.printExtraOutput: return # text = text[7:] if text == "\n": return
text += "<nobr>Unhandled exception of type <b>%s </b> occured at %d:%02d:%02d:</nobr><br><nobr>Traceback:</nobr><br>" % ( str(type) , t[3],t[4],t[5])
text += "<hr><nobr>Unhandled exception of type <b>%s </b> occured at %d:%02d:%02d:</nobr><br><nobr>Traceback:</nobr><br>" % ( str(type) , t[3],t[4],t[5])
def exceptionHandler(self, type, value, tracebackInfo): if self.focusOnCatchException: self.canvasDlg.menuItemShowOutputWindow() self.canvasDlg.workspace.cascade() # cascade shown windows
self.textOutput.append(text)
self.textOutput.setText(str(self.textOutput.text()) + text)
def exceptionHandler(self, type, value, tracebackInfo): if self.focusOnCatchException: self.canvasDlg.menuItemShowOutputWindow() self.canvasDlg.workspace.cascade() # cascade shown windows
if type(btnLabels[i])==type("string"):
if type(btnLabels[i]) == str:
def radioButtonsInBox(widget, master, value, btnLabels, box=None, tooltips=None, callback=None): if box: bg = QVButtonGroup(box, widget) else: bg = widget bg.setRadioButtonExclusive(1) for i in range(len(btnLabels)): if type(btnLabels[i])==type("string"): w = QRadioButton(btnLabels[i], bg) else: w = QRadioButton(str(i...
if self.radvizWidget.restrain == 1:
if self.radvizWidget.freeVizDlg.restrain == 1:
def onMouseMoved(self, e): redraw = (self.tooltipCurveKeys != [] or self.tooltipMarkers != [])
elif self.radvizWidget.restrain == 2:
elif self.radvizWidget.freeVizDlg.restrain == 2:
def onMouseMoved(self, e): redraw = (self.tooltipCurveKeys != [] or self.tooltipMarkers != [])
self.settingsToWidget(widget, context)
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): if self.syncWithGlobal: setattr(widget, self.localContextName, self.globalContexts) else: setattr(widget, self.localContextName, copy.deepcopy(self.globalContexts))
self.moveContextUp(widget, index)
self.moveContextUp(widget, index) return context, False
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): if self.syncWithGlobal: setattr(widget, self.localContextName, self.globalContexts) else: setattr(widget, self.localContextName, copy.deepcopy(self.globalContexts))
return context def closeContext(self, context, widget): self.settingsFromWidget(context, widget)
return context, True def closeContext(self, widget, context): self.settingsFromWidget(widget, context)
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): if self.syncWithGlobal: setattr(widget, self.localContextName, self.globalContexts) else: setattr(widget, self.localContextName, copy.deepcopy(self.globalContexts))
print self.name, self.flags
def __init__(self, name, flags, **argkw): self.name = name self.flags = flags print self.name, self.flags self.__dict__.update(argkw)
def openContext(self, widget, domain):
def findOrCreateContext(self, widget, domain):
def openContext(self, widget, domain): if not domain: return if type(domain) != orange.Domain: domain = domain.domain encodedDomain = self.encodeDomain(domain) context = ContextHandler.openContext(self, widget, domain, encodedDomain) context.encodedDomain = encodedDomain context.orderedDomain = [(attr.name, attr.varTyp...
return
return None, False
def openContext(self, widget, domain): if not domain: return if type(domain) != orange.Domain: domain = domain.domain encodedDomain = self.encodeDomain(domain) context = ContextHandler.openContext(self, widget, domain, encodedDomain) context.encodedDomain = encodedDomain context.orderedDomain = [(attr.name, attr.varTyp...
context = ContextHandler.openContext(self, widget, domain, encodedDomain)
context, isNew = ContextHandler.findOrCreateContext(self, widget, domain, encodedDomain) if not context: return None, False
def openContext(self, widget, domain): if not domain: return if type(domain) != orange.Domain: domain = domain.domain encodedDomain = self.encodeDomain(domain) context = ContextHandler.openContext(self, widget, domain, encodedDomain) context.encodedDomain = encodedDomain context.orderedDomain = [(attr.name, attr.varTyp...
context.orderedDomain = [(attr.name, attr.varType) for attr in domain] context.values = {} return context
metaIds = domain.getmetas().keys() metaIds.sort() context.orderedDomain = [(attr.name, attr.varType) for attr in domain] + [(domain[i].name, domain[i].varType) for i in metaIds] if isNew: context.values = {} context.noCopy = ["orderedDomain"] return context, isNew
def openContext(self, widget, domain): if not domain: return if type(domain) != orange.Domain: domain = domain.domain encodedDomain = self.encodeDomain(domain) context = ContextHandler.openContext(self, widget, domain, encodedDomain) context.encodedDomain = encodedDomain context.orderedDomain = [(attr.name, attr.varTyp...
excludes = getattr(field, "reservoir", []) if excludes and type(excludes) != list: excludes = [excludes]
def settingsToWidget(self, widget, context): ContextHandler.settingsToWidget(self, widget, context) excluded = {} for field in self.fields: name, flags = field.name, field.flags if not context.values.has_key(name): continue value = context.values[name] excludes = getattr(field, "reservoir", []) if excludes and type(ex...
excluded.setdefault(exclude, [])
def settingsToWidget(self, widget, context): ContextHandler.settingsToWidget(self, widget, context) excluded = {} for field in self.fields: name, flags = field.name, field.flags if not context.values.has_key(name): continue value = context.values[name] excludes = getattr(field, "reservoir", []) if excludes and type(ex...
setattr(widget, name, filter(lambda a: a not in values, context.orderedDomain))
ll = filter(lambda a: a not in values, context.orderedDomain) setattr(widget, name, ll)
def settingsToWidget(self, widget, context): ContextHandler.settingsToWidget(self, widget, context) excluded = {} for field in self.fields: name, flags = field.name, field.flags if not context.values.has_key(name): continue value = context.values[name] excludes = getattr(field, "reservoir", []) if excludes and type(ex...
def settingsFromWidget(self, context, widget):
def settingsFromWidget(self, widget, context):
def settingsFromWidget(self, context, widget): ContextHandler.settingsFromWidget(self, widget, context) context.values = {} for field in self.fields: if not field.flags & self.List: self.saveLow(context, widget, field.name, mygetattr(widget, field.name)) else: context.values[field.name] = mygetattr(widget, field.name) ...
handler.settingsFromWidget(context, self)
handler.settingsFromWidget(self, context)
def synchronizeContexts(self): if hasattr(self, "contextHandlers"): for contextName, handler in self.contextHandlers.items(): context = self.currentContexts.get(contextName, None) if context: handler.settingsFromWidget(context, self)
self.closeContext(contextName)
def openContext(self, contextName="", *arg): self.closeContext(contextName) handler = self.contextHandlers[contextName] context = handler.openContext(self, *arg) if context: handler.settingsFromWidget(context, self) # this is needed to sync a semi-matching context with the widget self.currentContexts[contextName] = co...
handler.settingsFromWidget(context, self)
def openContext(self, contextName="", *arg): self.closeContext(contextName) handler = self.contextHandlers[contextName] context = handler.openContext(self, *arg) if context: handler.settingsFromWidget(context, self) # this is needed to sync a semi-matching context with the widget self.currentContexts[contextName] = co...
self.contextHandlers[contextName].closeContext(curcontext, self)
self.contextHandlers[contextName].closeContext(self, curcontext)
def closeContext(self, contextName=""): curcontext = self.currentContexts.get(contextName) if curcontext: self.contextHandlers[contextName].closeContext(curcontext, self) del self.currentContexts[contextName]
printVerbose("Proportion: %5.3f" % p, verb)
orngMisc.printVerbose("Proportion: %5.3f" % p, verb)
def learningCurve(learners, examples, cv=None, pick=None, proportions=orange.frange(0.1), pps=[], **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) callback = argkw.get("callback", 0) for pp in pps: if pp[0]!="L": raise SystemError, "cannot preprocess testing examples" if not cv or not pick: seed...
printVerbose(" loaded from cache", verb)
orngMisc.printVerbose(" loaded from cache", verb)
def learningCurve(learners, examples, cv=None, pick=None, proportions=orange.frange(0.1), pps=[], **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) callback = argkw.get("callback", 0) for pp in pps: if pp[0]!="L": raise SystemError, "cannot preprocess testing examples" if not cv or not pick: seed...
printVerbose(" fold %d" % fold, verb)
orngMisc.printVerbose(" fold %d" % fold, verb)
def learningCurve(learners, examples, cv=None, pick=None, proportions=orange.frange(0.1), pps=[], **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) callback = argkw.get("callback", 0) for pp in pps: if pp[0]!="L": raise SystemError, "cannot preprocess testing examples" if not cv or not pick: seed...
printVerbose("Proportion: %5.3f" % p, verb)
orngMisc.printVerbose("Proportion: %5.3f" % p, verb)
def learningCurveWithTestData(learners, learnset, testset, times=10, proportions=orange.frange(0.1), strat=orange.MakeRandomIndices.StratifiedIfPossible, pps=[], **argkw): verb = argkw.get("verbose", 0) learnset, learnweight = demangleExamples(learnset) testweight = demangleExamples(testset)[1] randomGenerator = argk...
printVerbose(" repetition %d" % t, verb)
orngMisc.printVerbose(" repetition %d" % t, verb)
def learningCurveWithTestData(learners, learnset, testset, times=10, proportions=orange.frange(0.1), strat=orange.MakeRandomIndices.StratifiedIfPossible, pps=[], **argkw): verb = argkw.get("verbose", 0) learnset, learnweight = demangleExamples(learnset) testweight = demangleExamples(testset)[1] randomGenerator = argk...
printVerbose(" loaded from cache", verb)
orngMisc.printVerbose(" loaded from cache", verb)
def testWithIndices(learners, examples, indices, indicesrandseed="*", pps=[], callback=None, **argkw): verb = argkw.get("verbose", 0) cache = argkw.get("cache", 0) storeclassifiers = argkw.get("storeclassifiers", 0) or argkw.get("storeClassifiers", 0) cache = cache and not storeclassifiers examples, weight = demangle...
self.re_vline = re.compile(r'(?P<fname>.*)=(?P<version>[.0-9]*)(:?)(?P<md5>.*)')
self.re_vLocalLine = re.compile(r'(?P<fname>.*)=(?P<version>[.0-9]*)(:?)(?P<md5>.*)') self.re_vInternetLine = re.compile(r'(?P<fname>.*)=(?P<version>[.0-9]*)(:?)(?P<location>.*)')
def __init__(self,*args): apply(QMainWindow.__init__,(self,) + args) self.resize(500,500) self.setCaption("Qt Orange Update") self.toolbar = QToolBar(self, 'toolbar') self.statusBar = QStatusBar(self) self.text = QTextView (self) self.setCentralWidget(self.text) self.statusBar.message('Ready')
self.httpconnection = httplib.HTTPConnection('magix.fri.uni-lj.si')
self.httpconnection = httplib.HTTPConnection('www.ailab.si')
def __init__(self,*args): apply(QMainWindow.__init__,(self,) + args) self.resize(500,500) self.setCaption("Qt Orange Update") self.toolbar = QToolBar(self, 'toolbar') self.statusBar = QStatusBar(self) self.text = QTextView (self) self.setCentralWidget(self.text) self.statusBar.message('Ready')
self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readVersionFile(vf.readlines(), updateGroups = 1)
self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readLocalVersionFile(vf.readlines(), updateGroups = 1)
def __init__(self,*args): apply(QMainWindow.__init__,(self,) + args) self.resize(500,500) self.setCaption("Qt Orange Update") self.toolbar = QToolBar(self, 'toolbar') self.statusBar = QStatusBar(self) self.text = QTextView (self) self.setCentralWidget(self.text) self.statusBar.message('Ready')
self.addText("Orange update failed to locate file '%s'." %(self.downfile))
self.addText("Orange update failed to locate file '%s'. There is no information about current versions of Orange files." %(self.downfile), 0)
def __init__(self,*args): apply(QMainWindow.__init__,(self,) + args) self.resize(500,500) self.setCaption("Qt Orange Update") self.toolbar = QToolBar(self, 'toolbar') self.statusBar = QStatusBar(self) self.text = QTextView (self) self.setCentralWidget(self.text) self.statusBar.message('Ready')
self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readVersionFile(vf.readlines(), updateGroups = 1)
self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readLocalVersionFile(vf.readlines(), updateGroups = 1)
def showFolders(self): self.updateGroups = [] self.dontUpdateGroups = [] try: vf = open(self.downfile) self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readVersionFile(vf.readlines(), updateGroups = 1) vf.close() except: self.addText("Failed to locate file '%s'." %(self.downfile)) self.addText("No folder...
self.addText("Failed to locate file '%s'." %(self.downfile))
self.addText("Failed to locate file '%s'. There is no information on Orange folders that need to be updated." %(self.downfile), 0)
def showFolders(self): self.updateGroups = [] self.dontUpdateGroups = [] try: vf = open(self.downfile) self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readVersionFile(vf.readlines(), updateGroups = 1) vf.close() except: self.addText("Failed to locate file '%s'." %(self.downfile)) self.addText("No folder...
def addText(self, text): self.text.append("<nobr>" + text + "</nobr>\n")
def addText(self, text, nobr = 1): if nobr: self.text.append("<nobr>" + text + "</nobr>\n") else: self.text.append(text)
def addText(self, text): self.text.append("<nobr>" + text + "</nobr>\n") self.text.ensureVisible(0, self.text.contentsHeight())
def readVersionFile(self, data, updateGroups = 1):
def readLocalVersionFile(self, data, updateGroups = 1):
def readVersionFile(self, data, updateGroups = 1): versions = {} updateGroups = []; dontUpdateGroups = [] for line in data: if line: line = line.replace("\r", "") # replace \r in case of linux files line = line.replace("\n", "") if line[0] == "+": updateGroups.append(line[1:]) elif line[0] == "-": dontUpdateGroups.ap...
fnd = self.re_vline.match(line)
fnd = self.re_vLocalLine.match(line)
def readVersionFile(self, data, updateGroups = 1): versions = {} updateGroups = []; dontUpdateGroups = [] for line in data: if line: line = line.replace("\r", "") # replace \r in case of linux files line = line.replace("\n", "") if line[0] == "+": updateGroups.append(line[1:]) elif line[0] == "-": dontUpdateGroups.ap...
def updatefile(self, fname, version, md):
def updatefile(self, fname, location, version, md):
def updatefile(self, fname, version, md): dname = os.path.dirname(fname) if dname and not os.path.exists(dname): os.makedirs(dname)
newscript = self.download("/orangeUpdate/"+fname)
newscript = self.download("/orange/download/lastStable/"+location)
def updatefile(self, fname, version, md): dname = os.path.dirname(fname) if dname and not os.path.exists(dname): os.makedirs(dname)
if not os.path.exists("test/"+os.path.dirname(fname)): os.makedirs("test/"+os.path.dirname(fname))
if not os.path.exists(os.path.dirname(fname)): os.makedirs(os.path.dirname(fname))
def updatefile(self, fname, version, md): dname = os.path.dirname(fname) if dname and not os.path.exists(dname): os.makedirs(dname)
if md != "" and os.path.exists("test/" + fname): existing = open("test/" + fname, "rb")
if md != "" and os.path.exists(fname): existing = open(fname, "rb")
def updatefile(self, fname, version, md): dname = os.path.dirname(fname) if dname and not os.path.exists(dname): os.makedirs(dname)
if os.path.exists("test/"+fname+".bak"): os.remove("test/"+fname+".bak") os.rename("test/"+fname, "test/"+fname+".bak")
if os.path.exists(fname+".bak"): os.remove(fname+".bak") os.rename(fname, fname+".bak")
def updatefile(self, fname, version, md): dname = os.path.dirname(fname) if dname and not os.path.exists(dname): os.makedirs(dname)
nf = open("test/"+fname, "wb")
nf = open(fname, "wb")
def updatefile(self, fname, version, md): dname = os.path.dirname(fname) if dname and not os.path.exists(dname): os.makedirs(dname)