rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.scaledData[index] = self.noJitteringScaledData[index] + 0.5 - self.jitterSize/50.0 * RandomArray.random(len(data))
self.scaledData[index] = self.noJitteringScaledData[index] + self.jitterSize/50.0 * (0.5 - RandomArray.random(len(data)))
def setData(self, data): # clear all curves, markers, tips self.removeAllSelections(0) # clear all selections self.removeCurves() self.removeMarkers() self.tips.removeAll() self.attributeFlipInfo = {} self.attrValues = {} self.rawdata = data if data == None or len(data) == 0: self.scaledData = self.noJitteringScaledD...
self.inputs = [("Classified Examples", ExampleTableWithClass, self.cdata), ("Example Subset", ExampleTable, self.subsetdata, 1, 1), ("Selection", list, self.selection)]
self.inputs = [("Classified Examples", ExampleTableWithClass, self.cdata), ("Example Subset", ExampleTable, self.subsetdata, 1, 1), ("Selection", list, self.selection), ("Evaluation Results", orngTest.ExperimentResults, self.test_results)]
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Radviz", TRUE)
self.optimizationDlg.classifierNameChanged(self.VizRankClassifierName)
self.optimizationDlg.updateClassifierChanges()
def activateLoadedSettings(self): self.graph.updateSettings(showLegend = self.showLegend, showFilledSymbols = self.showFilledSymbols, optimizedDrawing = self.optimizedDrawing, tooltipValue = self.tooltipValue, tooltipKind = self.tooltipKind) self.graph.useDifferentSymbols = self.useDifferentSymbols self.graph.useDiffer...
kNNValues = None
values = self.classificationResults
def showSelectedAttributes(self): self.graph.removeAllSelections() val = self.optimizationDlg.getSelectedProjection() if not val: return (accuracy, other_results, tableLen, attrList, tryIndex, strList) = val kNNValues = None if self.optimizationDlg.showKNNCorrectButton.isOn() or self.optimizationDlg.showKNNWrongButton...
kNNValues = self.optimizationDlg.kNNClassifyData(shortData) if self.optimizationDlg.showKNNCorrectButton.isOn(): kNNValues = [1.0 - val for val in kNNValues]
values = self.optimizationDlg.kNNClassifyData(shortData) if self.optimizationDlg.showKNNCorrectButton.isOn(): values = [1.0 - val for val in values]
def showSelectedAttributes(self): self.graph.removeAllSelections() val = self.optimizationDlg.getSelectedProjection() if not val: return (accuracy, other_results, tableLen, attrList, tryIndex, strList) = val kNNValues = None if self.optimizationDlg.showKNNCorrectButton.isOn() or self.optimizationDlg.showKNNWrongButton...
self.showAttributes(attrList, kNNValues, clusterClosure)
self.showAttributes(attrList, values, clusterClosure)
def showSelectedAttributes(self): self.graph.removeAllSelections() val = self.optimizationDlg.getSelectedProjection() if not val: return (accuracy, other_results, tableLen, attrList, tryIndex, strList) = val kNNValues = None if self.optimizationDlg.showKNNCorrectButton.isOn() or self.optimizationDlg.showKNNWrongButton...
if not self.setShownAttributes(attrList): return self.graph.updateData(attrList, insideColors = insideColors, clusterClosure = clusterClosure)
self.setShownAttributes(attrList) self.graph.updateData(attrList, setAnchors = 1, insideColors = insideColors, clusterClosure = clusterClosure)
def showAttributes(self, attrList, insideColors = None, clusterClosure = None): if not self.setShownAttributes(attrList): return self.graph.updateData(attrList, insideColors = insideColors, clusterClosure = clusterClosure) self.graph.repaint() self.sendShownAttributes()
for attr in data.domain.attributes[10:]: self.hiddenAttribsLB.insertItem(attr.name)
if len(data.domain.attributes) > 10: for attr in data.domain.attributes[10:]: self.hiddenAttribsLB.insertItem(attr.name)
def cdata(self, data, clearResults = 1): if data: name = "" if hasattr(data, "name"): name = data.name data = orange.Preprocessor_dropMissingClasses(data) data.name = name if self.data != None and data != None and self.data.checksum() == data.checksum(): return # check if the new data set is the same as the old one ...
makedepsfile.write("STATC_OBJECTS = $(ODIR)/statc.o $(ODIR)/c2py.o $(ODIR)/statexceptions.o $(ODIR)/lcomb.o\n\n")
makedepsfile.write("STATC_OBJECTS = $(ODIR)/stat.o $(ODIR)/statc.o $(ODIR)/c2py.o $(ODIR)/statexceptions.o $(ODIR)/lcomb.o\n\n")
def recdeps(rootname, filename): if not filename in deps[rootname]: if deps.has_key(filename) and (rootname!=filename): deps[rootname].update(deps[filename]) else: deps[rootname][filename]=None for dep in files.get(filename, ("", []))[1]: recdeps(rootname, dep)
return object.__getattribute__(self, "__dict__")[name]
return self.__dict__[name]
def __getattr__(self, name): #print "getattr",name if name in ["points", "projectedDistances", "distances" ,"stress", "progressCallback", "n", "dim", "avgStress"]: #print "rec:",name return self.__dict__["mds"].__dict__[name] else: return object.__getattribute__(self, "__dict__")[name]
def optimize(iter, stressFunc=SgnRelStress, eps=1e-3, progeressCallback=None):
def optimize(self, iter, stressFunc=SgnRelStress, eps=1e-3, progressCallback=None):
def optimize(iter, stressFunc=SgnRelStress, eps=1e-3, progeressCallback=None): self.mds.progressCallback=progressCallback self.mds.optimize(iter, stressFunc, eps)
classIndices = getVariableValueIndices(self.rawdata, colorAttr) classCount = len(classIndices)
classCount = len(colorIndices)
def updateData(self, xAttr, yAttr, colorAttr, shapeAttr = "", sizeShapeAttr = "", showColorLegend = 0, **args): self.removeDrawingCurves() # my function, that doesn't delete selection curves self.removeMarkers() self.tips.removeAll() #self.enableLegend(0) self.removeTooltips() self.tooltipData = []
if colorIndex != -1: index = classIndices[self.rawdata[i][colorIndex].value]
if colorIndex != -1: index = colorIndices[self.rawdata[i][colorIndex].value]
def updateData(self, xAttr, yAttr, colorAttr, shapeAttr = "", sizeShapeAttr = "", showColorLegend = 0, **args): self.removeDrawingCurves() # my function, that doesn't delete selection curves self.removeMarkers() self.tips.removeAll() #self.enableLegend(0) self.removeTooltips() self.tooltipData = []
newColor = QColor(0,0,0) if colorIndex != -1: newColor.setHsv(self.coloringScaledData[colorIndex][i], 255, 255)
if colorIndex != -1: if self.rawdata.domain[colorIndex].varType == orange.VarTypes.Continuous: newColor.setHsv(self.coloringScaledData[colorIndex][i], 255, 255) else: newColor = classColors[colorIndices[self.rawdata[i][colorIndex].value]] else: newColor = QColor(0,0,0)
def updateData(self, xAttr, yAttr, colorAttr, shapeAttr = "", sizeShapeAttr = "", showColorLegend = 0, **args): self.removeDrawingCurves() # my function, that doesn't delete selection curves self.removeMarkers() self.tips.removeAll() #self.enableLegend(0) self.removeTooltips() self.tooltipData = []
classIndices = getVariableValueIndices(self.rawdata, self.attributeNames.index(self.rawdata.domain.classVar.name))
def updateData(self, xAttr, yAttr, colorAttr, shapeAttr = "", sizeShapeAttr = "", showColorLegend = 0, **args): self.removeDrawingCurves() # my function, that doesn't delete selection curves self.removeMarkers() self.tips.removeAll() #self.enableLegend(0) self.removeTooltips() self.tooltipData = []
if colorIndex != -1 and not self.subsetData[i][colorIndex].isSpecial(): newColor = classColors[self.subsetData[i][colorIndex].value] else: newColor = QColor(70,70,70)
if colorIndex != -1 and not self.subsetData[i][colorIndex].isSpecial(): if self.rawdata.domain[colorIndex].varType == orange.VarTypes.Continuous: newColor.setHsv(self.scaleExampleValue(self.subsetData[i], colorIndex), 255, 255) else: newColor = classColors[colorIndices[self.subsetData[i][colorIndex].value]] else: newCo...
def updateData(self, xAttr, yAttr, colorAttr, shapeAttr = "", sizeShapeAttr = "", showColorLegend = 0, **args): self.removeDrawingCurves() # my function, that doesn't delete selection curves self.removeMarkers() self.tips.removeAll() #self.enableLegend(0) self.removeTooltips() self.tooltipData = []
if not tabName: tabName = str(id)
if not tabName: tabName = str(len(self.data))
def dataset(self, data, id=None): """Generates a new table and adds it to a new tab when new data arrives; or hides the table and removes a tab when data==None; or replaces the table when new data arrives together with already existing id. """ if data: if self.data.has_key(id): # remove existing table self.data.pop(id)...
dont_compile = ["garbage_c_manner.cpp", "garbage_py_manner.cpp", "im_col_assess.cpp", "mlpyc45.cpp"]
dont_compile = ["im_col_assess.cpp"]
def recdeps(rootname, filename): if not filename in deps[rootname]: if deps.has_key(filename) and (rootname!=filename): deps[rootname].update(deps[filename]) else: deps[rootname][filename]=None for dep in files.get(filename, ("", []))[1]: recdeps(rootname, dep)
self.energyLabel.setText("Energy: %.3f" % E) self.energyLabel.repaint() self.graph.updateData(attrList) self.graph.repaint() if singleStep: noChange = 5 else: if E > minE*0.99: noChange += 1
self.energyLabel.setText("Energy: %.3f" % E) self.energyLabel.repaint() self.graph.updateData(attrList) self.graph.repaint() if singleStep: noChange = 5
def freeAttributes(self, iterations, steps, singleStep = False): attrList = self.getShownAttributeList() classes = [int(x.getclass()) for x in self.graph.rawdata] optimizer = self.lockToCircle and orangeom.optimizeAnchorsRadial or orangeom.optimizeAnchors ai = self.graph.attributeNameIndex attrIndices = [ai[label] for ...
minE = E noChange = 0
if E > minE*0.99: noChange += 1 else: minE = E noChange = 0
def freeAttributes(self, iterations, steps, singleStep = False): attrList = self.getShownAttributeList() classes = [int(x.getclass()) for x in self.graph.rawdata] optimizer = self.lockToCircle and orangeom.optimizeAnchorsRadial or orangeom.optimizeAnchors ai = self.graph.attributeNameIndex attrIndices = [ai[label] for ...
for attr in ("name", "kernel", "degree", "gamma", "coef0", "C", "p", "eps", "nu", "shrinking"):
for attr in ("name", "kernel", "degree", "shrinking"):
def applySettings(self): self.learner = BasicSVMLearner() for attr in ("name", "kernel", "degree", "gamma", "coef0", "C", "p", "eps", "nu", "shrinking"): setattr(self.learner, attr, getattr(self, attr)) self.learner.for_nomogram = 1
self.evaluatedAttributes = OWVisAttrSelection.evaluateAttributes(data, None, discMeasures[self.attrDisc][1])
self.evaluatedAttributes = orngVisFuncts.evaluateAttributes(data, None, discMeasures[self.attrDisc][1])
def getEvaluatedAttributes(self, data): if not data.domain.classVar or data.domain.classVar.varType != orange.VarTypes.Discrete: return [] if self.evaluatedAttributes: return self.evaluatedAttributes try: # evaluate attributes using the selected attribute measure self.evaluatedAttributes = OWVisAttrSelection.evaluateA...
if self.optimizationType == 0: totalPossibilities = OWVisFuncts.combinationsCount(self.attributeCount, len(evaluatedAttrs))
if self.optimizationType == 0: totalPossibilities = orngVisFuncts.combinationsCount(self.attributeCount, len(evaluatedAttrs))
def evaluateProjections(self): if not self.data or not self.classVals: return
for i in range(1, self.attributeCount+1): totalPossibilities += OWVisFuncts.combinationsCount(i, len(evaluatedAttrs))
for i in range(1, self.attributeCount+1): totalPossibilities += orngVisFuncts.combinationsCount(i, len(evaluatedAttrs))
def evaluateProjections(self): if not self.data or not self.classVals: return
combinations = OWVisFuncts.combinations(evaluatedAttrs[:z], u)
combinations = orngVisFuncts.combinations(evaluatedAttrs[:z], u)
def evaluateProjections(self): if not self.data or not self.classVals: return
self.setStatusBarText("Evaluated %s visualizations..." % (OWVisFuncts.createStringFromNumber(triedPossibilities)))
self.setStatusBarText("Evaluated %s visualizations..." % (orngVisFuncts.createStringFromNumber(triedPossibilities)))
def evaluateProjections(self): if not self.data or not self.classVals: return
self.setStatusBarText("Evaluation stopped (evaluated %s projections in %d min, %d sec)" % (OWVisFuncts.createStringFromNumber(evaluatedProjections), secs/60, secs%60))
self.setStatusBarText("Evaluation stopped (evaluated %s projections in %d min, %d sec)" % (orngVisFuncts.createStringFromNumber(evaluatedProjections), secs/60, secs%60))
def finishEvaluation(self, evaluatedProjections): if self.__class__.__name__ == "OWMosaicOptimization": secs = time.time() - self.startTime self.setStatusBarText("Evaluation stopped (evaluated %s projections in %d min, %d sec)" % (OWVisFuncts.createStringFromNumber(evaluatedProjections), secs/60, secs%60)) self.parentW...
argList = {1: {}, 2: {}, 3:{}, 4:{}} for argsByClass in self.arguments.values(): for i in range(len(argsByClass)): attrs = argsByClass[i][2]
for classValue in self.arguments.keys(): argList = {1: {}, 2: {}, 3:{}, 4:{}} arguments = self.arguments[classValue] for i in range(len(arguments)): attrs = arguments[i][2]
def removeWeakerArguments(self): if not self.arguments or not self.arguments.values(): return
existingVal, existingIndexList = argList[len(attrs)].get(tuple(attrs), (0.0, [])) argList[len(attrs)][tuple(attrs)] = (existingVal + abs(argsByClass[i][0]), existingIndexList + [i]) if len(argList[1]) == 0: return for count in [4,3,2]: args = argList[count] candidates = [] for key in args.keys(): splits = OWVisFunct...
argList[len(attrs)][tuple(attrs)] = (arguments[i][0], i) if len(argList[1]) == 0: return for count in [4,3,2]: args = argList[count] candidates = [] for key in args.keys(): splits = orngVisFuncts.getPossibleSplits(list(key)) for split in splits: vals = [argList[len(v)].get(tuple(v), [None, None])[0] for v in split] ...
def removeWeakerArguments(self): if not self.arguments or not self.arguments.values(): return
if len(indices) == 0 or j != indices[-1]:
if len(indicesToKeep) == 0 or j != indicesToKeep[-1]:
def removeWeakerArguments(self): if not self.arguments or not self.arguments.values(): return
else: indices.pop()
else: indicesToKeep.pop()
def removeWeakerArguments(self): if not self.arguments or not self.arguments.values(): return
fullData = orange.ExampleTable(contDomain)
def evaluateProjections(self): evaluatedProjections = 0 self.startTime = time.time()
for i in range(len(self.data)): fullData.append([self.graph.noJitteringScaledData[ind][i] for ind in range(attrCount)] + [self.data[i].getclass()]) if self.evaluationAlgorithm == ALGORITHM_HEURISTIC: attrs = [orange.EquiDistDiscretization(fullData.domain[attr], fullData, numberOfIntervals = NUMBER_OF_INTERVALS) for a...
def evaluateProjections(self): evaluatedProjections = 0 self.startTime = time.time()
valid = self.graph.validDataArray[attr1] + self.graph.validDataArray[attr2] - 1 table = fullData.select([attr1, attr2, self.data.domain.classVar.name]) table = table.select(list(valid))
table = self.graph.createProjectionAsExampleTable([attr1, attr2])
def evaluateProjections(self): evaluatedProjections = 0 self.startTime = time.time()
error_status = 3
result = "crash" error_status = 4
def testScripts(complete): global error_status if sys.platform == "win32" and sys.executable[-6:].upper() != "_D.EXE": 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",...
if result == "error":
if result in ["error", "crash"]:
def testScripts(complete): global error_status if sys.platform == "win32" and sys.executable[-6:].upper() != "_D.EXE": 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",...
if self.notTargetClassIndex == 1 or self.notTargetClassIndex == cl.domain.classVar[1]:
if self.notTargetClassIndex == 1 or self.notTargetClassIndex == cl.continuizedDomain.classVar[1]:
def err(e, priorError, key, data): inf = 0.0 sume = e[0]+e[1] for d in data: if d[at]==key: inf += (e[0]*e[1]/sume/sume) inf = max(inf, 0.00000001) var = 1/inf - priorError*priorError return (math.sqrt(var))
self.table.setNumRows(len(self.classifier.domain.attributes)+1)
self.table.setNumRows(len(self.classifier.continuizedDomain.attributes)+1)
def err(e, priorError, key, data): inf = 0.0 sume = e[0]+e[1] for d in data: if d[at]==key: inf += (e[0]*e[1]/sume/sume) inf = max(inf, 0.00000001) var = 1/inf - priorError*priorError return (math.sqrt(var))
for i in range(len(self.classifier.domain.attributes)): self.table.setText(i+1,0,str(self.classifier.domain.attributes[i].name))
for i in range(len(self.classifier.continuizedDomain.attributes)): self.table.setText(i+1,0,str(self.classifier.continuizedDomain.attributes[i].name))
def err(e, priorError, key, data): inf = 0.0 sume = e[0]+e[1] for d in data: if d[at]==key: inf += (e[0]*e[1]/sume/sume) inf = max(inf, 0.00000001) var = 1/inf - priorError*priorError return (math.sqrt(var))
self.debugFile.write("\n\ttoken type = ExampleTable. len = " + str(len(object)) + "\n\tdomain = " + str(object.domain))
name = " " + getattr(object, "name", "") self.debugFile.write("\n\ttoken type = ExampleTable" + name + ". len = " + str(len(object)))
def addEvent(self, strValue, object = None): if self.debugFile: self.debugFile.write(strValue) if object: if type(object) == orange.ExampleTable: self.debugFile.write("\n\ttoken type = ExampleTable. len = " + str(len(object)) + "\n\tdomain = " + str(object.domain)) self.debugFile.write("\n")
imports = "import sys, os, cPickle, orange\nfrom orngSignalManager import *\n"
imports = "import sys, os, cPickle, orange\nimport orngSignalManager\n\n
def saveDocumentAsApp(self, asTabs = 1): # get filename appName = os.path.splitext(self.applicationname)[0] + ".py" qname = QFileDialog.getSaveFileName( os.path.join(self.applicationpath, appName) , "Orange Scripts (*.py)", self, "", "Save File as Application") if qname.isEmpty(): return
self.setCaption("Qt %s")""" % (fileName)
self.setCaption("Qt %s") signalManager = orngSignalManager.SignalManager(DEBUG_MODE)""" % (fileName)
def __init__(self,parent=None): QVBox.__init__(self,parent) self.setCaption("Qt %s")""" % (fileName)
self.rects = [] self.texts = []
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Mosaic display", TRUE, TRUE)
self.symbols = []
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Mosaic display", TRUE, TRUE)
for rect in self.rects: rect.hide() for text in self.texts: text.hide() for name in self.names: name.hide() for symbol in self.symbols: symbol.hide()
for item in self.canvas.allItems(): item.setCanvas(None)
def updateData(self, *args): # hide all rectangles self.warning() for rect in self.rects: rect.hide() for text in self.texts: text.hide() for name in self.names: name.hide() for symbol in self.symbols: symbol.hide() for tip in self.tooltips: QToolTip.remove(self.canvasView, tip) self.rects = []; self.texts = []; self.s...
self.rects = []; self.texts = []; self.symbols = []; self.names = []; self.tooltips = []
self.names = []; self.tooltips = []
def updateData(self, *args): # hide all rectangles self.warning() for rect in self.rects: rect.hide() for text in self.texts: text.hide() for name in self.names: name.hide() for symbol in self.symbols: symbol.hide() for tip in self.tooltips: QToolTip.remove(self.canvasView, tip) self.rects = []; self.texts = []; self.s...
if side == 0: self.texts.append(OWCanvasText(self.canvas, attr, x0+(x1-x0)/2, y1 + self.attributeNameOffset, Qt.AlignCenter, bold = 1)) elif side == 1: self.texts.append(OWCanvasText(self.canvas, attr, x0 - self.attributeNameOffset, y0+(y1-y0)/2, Qt.AlignRight + Qt.AlignVCenter, bold = 1)) elif side == 2: self.tex...
if side == 0: OWCanvasText(self.canvas, attr, x0+(x1-x0)/2, y1 + self.attributeNameOffset, Qt.AlignCenter, bold = 1) elif side == 1: OWCanvasText(self.canvas, attr, x0 - self.attributeNameOffset, y0+(y1-y0)/2, Qt.AlignRight + Qt.AlignVCenter, bold = 1) elif side == 2: OWCanvasText(self.canvas, attr, x0+(x1-x0)/2, ...
def DrawText(self, data, side, attr, (x0, x1), (y0, y1), totalAttrs, lastValueForFirstAttribute): if self.drawnSides[side]: return if side == RIGHT and lastValueForFirstAttribute != 2: return if not data or len(data) == 0: if not self.drawPositions.has_key(side): self.drawPositions[side] = (x0, x1, y0, y1) return else...
if side == 0: self.texts.append(OWCanvasText(self.canvas, str(val), x0+currPos+width*0.5*perc, y1 + self.attributeValueOffset, Qt.AlignCenter, bold = 0)) elif side == 1: self.texts.append(OWCanvasText(self.canvas, str(val), x0-self.attributeValueOffset, y0+currPos+height*0.5*perc, Qt.AlignRight + Qt.AlignVCenter, b...
if side == 0: OWCanvasText(self.canvas, str(val), x0+currPos+width*0.5*perc, y1 + self.attributeValueOffset, Qt.AlignCenter, bold = 0) elif side == 1: OWCanvasText(self.canvas, str(val), x0-self.attributeValueOffset, y0+currPos+height*0.5*perc, Qt.AlignRight + Qt.AlignVCenter, bold = 0) elif side == 2: OWCanvasTex...
def DrawText(self, data, side, attr, (x0, x1), (y0, y1), totalAttrs, lastValueForFirstAttribute): if self.drawnSides[side]: return if side == RIGHT and lastValueForFirstAttribute != 2: return if not data or len(data) == 0: if not self.drawPositions.has_key(side): self.drawPositions[side] = (x0, x1, y0, y1) return else...
for name in self.names: name.hide() for symbol in self.symbols: symbol.hide() self.symbols = []; self.names = []
def DrawLegend(self, data, (x0, x1), (y0, y1)): for name in self.names: name.hide() for symbol in self.symbols: symbol.hide() self.symbols = []; self.names = []
self.names = []
def DrawLegend(self, data, (x0, x1), (y0, y1)): for name in self.names: name.hide() for symbol in self.symbols: symbol.hide() self.symbols = []; self.names = []
symbol = OWCanvasRectangle(self.canvas, startX + xOffset, y, size, size, edgeColor, colors[i]) self.symbols.append(symbol)
OWCanvasRectangle(self.canvas, startX + xOffset, y, size, size, edgeColor, colors[i])
def DrawLegend(self, data, (x0, x1), (y0, y1)): for name in self.names: name.hide() for symbol in self.symbols: symbol.hide() self.symbols = []; self.names = []
self.rects.append(rect)
def addRect(self, x0, x1, y0, y1, data = None, condition = "", usedAttrs = []): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
self.rects.append(r)
def addRect(self, x0, x1, y0, y1, data = None, condition = "", usedAttrs = []): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
self.rects.append(OWCanvasLine(self.canvas, x0+total, y0+1, x0+total, y1-1, z = 10))
OWCanvasLine(self.canvas, x0+total, y0+1, x0+total, y1-1, z = 10)
def addRect(self, x0, x1, y0, y1, data = None, condition = "", usedAttrs = []): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
self.rects.append(OWCanvasLine(self.canvas, x0+1, y0+total, x1-1, y0+total, z = 10))
OWCanvasLine(self.canvas, x0+1, y0+total, x1-1, y0+total, z = 10)
def addRect(self, x0, x1, y0, y1, data = None, condition = "", usedAttrs = []): x0 = int(x0); x1 = int(x1); y0 = int(y0); y1 = int(y1) if x0 == x1: x1+=1 if y0 == y1: y1+=1
class S2NMeasure:
class S2NMeasure2:
def MeasureAttribute_info(self, attr, data): # if basic statistics is not computed for this dataset -> compute it if not (self.stats and self.dataset == data): self.stats = {} self.dataset = data
self.dataset = None
def __init__(self): self.dataset = None self.attrInfo = {} self.data = None
pass
def __init__(self): S2NMeasure.__init__(self) self.attrInfoMix = {} self.dataMix = None def __call__(self, attr, data): if data.domain[attr].varType == orange.VarTypes.Discrete: print "S2NMeasureMix can not evaluate discrete attributes" return -1 if data != self.dataMix: self.attrInfoMix = {} self.attrInfo = {} self...
def __call__(self, attr, data): # if the data changed clear the attribute values if data != self.data: self.attrInfo = {} self.data = data
def findAttributeGroupsForRadviz(data, measure, attrs): attrVals = [(measure(attr, data), attr) for attr in attrs] attrVals.sort() attrVals.reverse() attrNames = [attrVals[i][1] for i in range(len(attrVals))] numClasses = len(data.domain.classVar.values) cls = [attrNames[i::numClasses] for i in range(numClasses)] re...
def mergeClassValues(data, value): selection = orange.EnumVariable("Selection", values = ["0", "1"]) selectedClassesStr = [value] nonSelectedClassesStr = [] for val in data.domain.classVar.values: if val not in selectedClassesStr: nonSelectedClassesStr.append(val) shortData1 = data.select({data.domain.classVar.name: ...
attrs = []; contAttrs = []
attrs = []
def evaluateAttributes(data, contMeasure, discMeasure): attrs = []; contAttrs = [] corr = MeasureCorrelation() for attr in data.domain.attributes: if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((corr(attr.name, data), attr.name)) elif data.doma...
elif attr.varType == orange.VarTypes.Continuous: if not isinstance(contMeasure, S2NMeasureMix): attrs.append((contMeasure(attr.name, data), attr.name)) else: contAttrs.append(attr.name) else: attrs.append((discMeasure(attr.name, data), attr.name))
elif attr.varType == orange.VarTypes.Continuous: attrs.append((contMeasure(attr.name, data), attr.name)) else: attrs.append((discMeasure(attr.name, data), attr.name))
def evaluateAttributes(data, contMeasure, discMeasure): attrs = []; contAttrs = [] corr = MeasureCorrelation() for attr in data.domain.attributes: if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((corr(attr.name, data), attr.name)) elif data.doma...
attrs2 = [] if isinstance(contMeasure, S2NMeasureMix) and contAttrs != []: cls = [] for c in data.domain.classVar.values: v = [] data2 = mergeClassValues(data, c) for attr in contAttrs: v.append((contMeasure(attr, data2), attr)) v.sort() cls.append(v) ableToAdd = 1 while ableToAdd: ableToAdd = 0 for i in range(len(dat...
return [attr for (val, attr) in attrs]
def evaluateAttributes(data, contMeasure, discMeasure): attrs = []; contAttrs = [] corr = MeasureCorrelation() for attr in data.domain.attributes: if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((corr(attr.name, data), attr.name)) elif data.doma...
print "CONTEXT FOUND"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "TAKING GLOBAL"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "COPYING GLOBAL"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "settings to widget"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "index", index
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "add context"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "context up"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
print "settings from widget"
def openContext(self, widget, *arg, **argkw): if not hasattr(widget, self.localContextName): print "CONTEXT FOUND" if self.syncWithGlobal: print "TAKING GLOBAL" setattr(widget, self.localContextName, self.globalContexts) else: print "COPYING GLOBAL" setattr(widget, self.localContextName, copy.deepcopy(self.globalContex...
ow.cdata(data) l1 = orange.MajorityLearner() l1.name = 'Maj 1' ow.learner(l1, 1)
l1 = orange.MajorityLearner(); l1.name = '1 - Majority'
def finish(self): self.widget.progressBarFinished()
l2.name = 'Naive Bayes (m=10)'
def finish(self): self.widget.progressBarFinished()
ow.learner(l2, 2) l3 = orange.BayesLearner() l3.name = 'NB First' ow.learner(l3, 3) l1.name = 'Maj 1 updated' ow.learner(l1, 1) ow.learner(None, 2) l4 = orange.MajorityLearner() l4.name = "Maj 2" ow.learner(l4, 4)
l2.name = '2 - NBC (m=10)' l3 = orange.BayesLearner(); l3.name = '3 - NBC (default)' l4 = orange.MajorityLearner(); l4.name = "4 - Majority" testcase = 0 if testcase == 0: ow.cdata(data) ow.learner(l1, 1) ow.learner(l2, 2) ow.learner(l3, 3) l1.name = l1.name + " UPD" ow.learner(l1, 1) ow.learner(None, 2) ow.learner...
def finish(self): self.widget.progressBarFinished()
def addWidget(self, widget, x= -1, y=-1, caption = ""):
def addWidget(self, widget, x= -1, y=-1, caption = "", activateSettings = 1):
def addWidget(self, widget, x= -1, y=-1, caption = ""): qApp.setOverrideCursor(QWidget.waitCursor) try: newwidget = orngCanvasItems.CanvasWidget(self.signalManager, self.canvas, self.canvasView, widget, self.canvasDlg.defaultPic, self.canvasDlg) newwidget.instance.setEventHandler(self.canvasDlg.output.widgetEvents) exc...
newwidget.instance.activateLoadedSettings()
if activateSettings: newwidget.instance.activateLoadedSettings()
def addWidget(self, widget, x= -1, y=-1, caption = ""): qApp.setOverrideCursor(QWidget.waitCursor) try: newwidget = orngCanvasItems.CanvasWidget(self.signalManager, self.canvas, self.canvasView, widget, self.canvasDlg.defaultPic, self.canvasDlg) newwidget.instance.setEventHandler(self.canvasDlg.output.widgetEvents) exc...
def addWidgetByFileName(self, widgetName, x, y, caption):
def addWidgetByFileName(self, widgetName, x, y, caption, activateSettings = 1):
def addWidgetByFileName(self, widgetName, x, y, caption): for widget in self.canvasDlg.tabs.allWidgets: if widget.getFileName() == widgetName: return self.addWidget(widget, x, y, caption) return None
return self.addWidget(widget, x, y, caption)
return self.addWidget(widget, x, y, caption, activateSettings)
def addWidgetByFileName(self, widgetName, x, y, caption): for widget in self.canvasDlg.tabs.allWidgets: if widget.getFileName() == widgetName: return self.addWidget(widget, x, y, caption) return None
tempWidget = self.addWidgetByFileName(name, int(widget.getAttribute("xPos")), int(widget.getAttribute("yPos")), widget.getAttribute("caption"))
tempWidget = self.addWidgetByFileName(name, int(widget.getAttribute("xPos")), int(widget.getAttribute("yPos")), widget.getAttribute("caption"), activateSettings = 0)
def loadDocument(self, filename): if not os.path.exists(filename): self.close() QMessageBox.critical(self,'Orange Canvas','Unable to find file "'+ filename, QMessageBox.Ok + QMessageBox.Default) return
width = height = int(1 + 2.0*margin + hook + maxlabel + max(lineskip*(0.5+len(labels)) + tcanvas.fontHeight(normal),2*maxlabel))
width = height = int(1 + 2.0*margin + hook + maxlabel + lineskip*(len(labels)) + tcanvas.fontHeight(normal))
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
x = offset - labellen[idx] + lineskip
x = offset - labellen[idx]
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
x2 = offset + lineskip/2
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
canvas.drawString(labels[idx], y+lineskip, y2+block-hook-lineskip, angle=90,font=normal)
canvas.drawString(labels[idx], y+block+halfline-lineskip+hook, y2+block-hook-lineskip, angle=90,font=normal)
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
canvas.drawString(labels[idx], y+lineskip, y2+block-hook, angle=90,font=normal)
canvas.drawString(labels[idx], y+block+halfline-lineskip+hook, y2+block-hook, angle=90,font=normal)
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
canvas.drawString(labels[idx], y2+lineskip, x2+block-lineskip, angle=90,font=normal)
canvas.drawString(labels[idx], y+block+halfline-lineskip+hook, offset+lineskip-block-hook, angle=90,font=normal)
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
x = offset+hook+lineskip*(j+1)+block y = offset+lineskip*(i+1)-halfline
x = offset+hook+lineskip*(j)+block y = offset+lineskip*(i+1)
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
x = offset+hook+lineskip*(i+1)+block y = offset+lineskip*(j+1)-halfline
x = offset+hook+lineskip*(i)+block y = offset+lineskip*(j+1)
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
x = offset+hook+lineskip*(i+1)+block y = offset+lineskip*(i+1)-halfline
x = offset+hook+lineskip*(i)+block y = offset+lineskip*(i+1)
def matrix(self,labels, diss, margin = 10, hook = 10, block = None, line_size = 2.0, att_colors = [], canvas = None,color_mode=0,diagonal=0): # prevent divide-by-zero... if len(labels) < 2: return canvas
width = int(1 + 2.0*margin + hook + maxlabelx + max(lineskip*(0.5+len(hlabels)) + tcanvas.fontHeight(normal),2*maxlabelx)) height = int(1 + 2.0*margin + hook + maxlabely + max(lineskip*(0.5+len(vlabels)) + tcanvas.fontHeight(normal),2*maxlabely))
width = int(1 + 2.0*margin + hook + maxlabelx + lineskip*(len(vlabels)) + tcanvas.fontHeight(normal)) height = int(1 + 2.0*margin + hook + maxlabely + lineskip*(len(hlabels)) + tcanvas.fontHeight(normal))
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
_colorize = colorpicker(color_mode)
_colorize = _color_picker(color_mode)
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
x2 = offsetx + lineskip/2 y2 = offsety + lineskip*(i+1)
x2 = offsetx + lineskip*(i) + hook y2 = offsety + halfline - hook
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
canvas.drawString(vlabels[i], y2+lineskip, x2+block-lineskip, angle=90,font=normal)
canvas.drawString(vlabels[i], x2+block+halfline, y2+block, angle=90,font=normal)
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
x = offsetx - labellen[i] + lineskip
x = offsetx - labellen[i]
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
for j in range(len(hlabels)):
for j in range(len(vlabels)):
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
x = offsetx+hook+lineskip*(j+1)+block y = offsety+lineskip*(i+1)-halfline
x = offsetx+hook+lineskip*(j)+block y = offsety+lineskip*(i+1)
def Matrix(diss, hlabels=[], vlabels=[], sizing = [], margin = 10, hook = 10, block = None, line_size = 2.0, color_mode=0, sizing2 = [], canvas = None, multiplier = 1.0): # prevent divide-by-zero... if len(hlabels) < 2: return canvas ## ADJUST DIMENSIONS ### if canvas == None: tcanvas = piddlePIL.PILCanvas() else: tc...
line = file.readline()[:-1]; ind = 0
def loadProjections(self, name = None): self.projections = [] self.kNeighborsLabel.setText("Number of neighbors (k): " ) self.percentDataUsedLabel.setText("Percent of data used:" ) self.testingMethodLabel.setText("Testing method used:" ) self.qualityMeasureLabel.setText("Quality measure used:" ) if name == None: name ...
(acc, other_results, lenTable, attrList, strList) = eval(line)
line = file.readline()[:-1]; ind = 0 (acc, other_results, lenTable, attrList, tryIndex, strList) = eval(line)
def loadProjections(self, name = None): self.projections = [] self.kNeighborsLabel.setText("Number of neighbors (k): " ) self.percentDataUsedLabel.setText("Percent of data used:" ) self.testingMethodLabel.setText("Testing method used:" ) self.qualityMeasureLabel.setText("Quality measure used:" ) if name == None: name ...
(acc, other_results, lenTable, attrList, strList) = eval(line)
(acc, other_results, lenTable, attrList, tryIndex, strList) = eval(line)
def loadProjections(self, name = None): self.projections = [] self.kNeighborsLabel.setText("Number of neighbors (k): " ) self.percentDataUsedLabel.setText("Percent of data used:" ) self.testingMethodLabel.setText("Testing method used:" ) self.qualityMeasureLabel.setText("Quality measure used:" ) if name == None: name ...
self.showTip(intX, intY, text[:-2].replace("; ", "\n"))
text = text[:-2].replace("; ", "<br>") text += "<hr>Example index = %d" % (index+1) self.showTip(intX, intY, text)
def onMouseMoved(self, e): redraw = 0 if self.tooltipCurveKeys != [] or self.tooltipMarkers != []: redraw = 1
return self.kNNOptimization.kNNComputeAccuracy(self.createProjectionAsExampleTable([self.attributeNameIndex[i] for i in attrList]))
return self.kNNOptimization.kNNComputeAccuracy(self.createProjectionAsExampleTable([self.attributeNameIndex[attr] for attr in attrList]))
def getProjectionQuality(self, attrList): return self.kNNOptimization.kNNComputeAccuracy(self.createProjectionAsExampleTable([self.attributeNameIndex[i] for i in attrList]))
self.kNNOptimization.setStatusBarText("Evaluation stopped (evaluated %d projections in %d min, %d sec)" % (self.triedPossibilities, secs/60, secs%60))
self.kNNOptimization.setStatusBarText("Evaluation stopped (evaluated %s projections in %d min, %d sec)" % (createStringFromNumber(self.triedPossibilities), secs/60, secs%60))
def getOptimalSeparation(self, attributes, minLength, maxLength, addResultFunct): dataSize = len(self.rawdata) self.triedPossibilities = 0