rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if not os.path.exists(fname): if self.updateMissingFilesCB.isChecked(): updatedFiles += self.updatefile(fname, location, version, "", "updating missing file")
if len(dirs) >= 1 and dirs[0].lower() == "doc" and "Documentation" in self.dontUpdateGroups: continue if len(dirs) >= 1 and dirs[0].lower() == "orangecanvas" and "Orange Canvas" in self.dontUpdateGroups: continue if len(dirs) == 1 and "Orange Root" in self.dontUpdateGroups: continue if self.downstuff.has_key(fname) an...
def executeUpdate(self): self.addText("Starting updating new files") self.addText("Reading file status from server")
self.addText("Skipping missing file %s" % (fname)) continue if self.downstuff.has_key(fname): if self.downstuff[fname][0] < upstuff[fname][0]: updatedFiles += self.updatefile(fname, location, version, self.downstuff[fname][1], "updating") else: self.updatefile(fname, location, version, "") newFiles += 1
self.addText("Skipping new file %s" % (fname))
def executeUpdate(self): self.addText("Starting updating new files") self.addText("Reading file status from server")
self.addText("Finished updating new files. New files: <b>%d</b>. Updated files: <b>%d</b>\n<hr>" %(newFiles, updatedFiles))
self.addText("Finished updating new files. New files: <b>%d</b>. Updated files: <b>%d</b>\n<hr>" %(newFiles, updatedFiles), addBreak = 0)
def executeUpdate(self): self.addText("Starting updating new files") self.addText("Reading file status from server")
if os.path.exists(os.path.join(self.orangeDir, "OrangeCanvas/widgetregistry.xml")):
if os.path.exists(os.path.join(self.orangeDir, "OrangeCanvas/widgetregistry.xml")) and newFiles + updatedFiles > 0:
def executeUpdate(self): self.addText("Starting updating new files") self.addText("Reading file status from server")
self.httpconnection.request("GET", urllib.quote(fname))
try: self.httpconnection.request("GET", urllib.quote(fname)) except: self.httpconnection = httplib.HTTPConnection('www.ailab.si') self.httpconnection.request("GET", urllib.quote(fname))
def download(self, fname): self.httpconnection.request("GET", urllib.quote(fname)) r = self.httpconnection.getresponse() if r.status != 200: self.addText("Got '%s' while downloading '%s'" % (r.reason, fname)) raise "Got '%s' while downloading '%s'" % (r.reason, fname) return r.read()
self.addText("Got '%s' while downloading '%s'" % (r.reason, fname)) raise "Got '%s' while downloading '%s'" % (r.reason, fname) return r.read()
raise Exception("Got '%s'" % (r.reason)) return resp
def download(self, fname): self.httpconnection.request("GET", urllib.quote(fname)) r = self.httpconnection.getresponse() if r.status != 200: self.addText("Got '%s' while downloading '%s'" % (r.reason, fname)) raise "Got '%s' while downloading '%s'" % (r.reason, fname) return r.read()
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except:
def updatefile(self, fname, location, version, md, type = "Downloading"): self.addText(type + " %s ... " % fname, addBreak = 0) qApp.processEvents() try: newscript = self.download("/orange/download/lastStable/" + location) except Exception, inst: self.addText('<font color="
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
saveFile = 1
createBackup = 0
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
res = QMessageBox.information(self,'Update Orange',"Local file '%s' was changed. Do you wish to overwrite local copy \nwith newest version (a backup of current file will be created) or keep current file?" % (os.path.split(fname)[1]),'Overwrite with newest','Keep current file')
res = QMessageBox.information(self,'Update Orange',"Your local file '%s' was edited. A newer version of this file is available on the web.\nDo you wish to overwrite local copy with newest version (a backup of current file will be created) or keep your current file?" % (os.path.split(fname)[1]),'Overwrite With Newest','...
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
saveFile = 2
createBackup = 1
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
saveFile = 0
self.addText('<font color=" return 0
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
if saveFile == 0: return 0 elif saveFile == 2:
if createBackup:
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
self.addText("Unable to rename file <b>'%s'</b> to <b>'%s'</b>. Please close all programs that are using it." % (os.path.split(fname)[1], os.path.split(fname)[1]+'.bak'))
self.addText('<font color=" self.addText('Unable to update file <font color="
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
self.addText("Unable to write file <b>'%s'</b>. Please close all programs that are using it." % (os.path.split(fname)[1]))
self.addText('<font color=" self.addText('Unable to update file <font color="
def updatefile(self, fname, location, version, md, type = "downloading"): self.addText(type + " <b>%s</b>" % fname) try: newscript = self.download("/orange/download/lastStable/"+location) except: return 0
spec = value.isSpecial()
spec = v.isSpecial()
def _getattr(ex,attr): # a 'smart' function tries to access an attribute first by reference, then by name spec = 0 try: v = ex[attr] except: # perhaps the domain changed try: v = ex[attr.name] except: warnings.warn("Missing attribute %s"%attr.name) v = attr.values[0] spec = 1 if spec == 0: try: spec = value.isSpecial()...
makedepsfile.write("\tpython ../pyxtract/pyxtract.py -m -q -n %s %s %s" % (modulename, short, " ".join(px_timestamp_dep))
makedepsfile.write("\tpython ../pyxtract/pyxtract.py -m -q -n %s %s %s" % (modulename, short, " ".join(px_timestamp_dep)))
def readArguments(args): global filenames, verbose, recreate, action, libraries, modulename, dirs filenames, libraries, verbose, recreate, modulename = [], [], 0, 0, "" action = [] dirs = ["."] i = 0 while(i<len(args)): if args[i][0]=="-": opt = args[i][1:] if opt=="n": i += 1 modulename = args[i] elif opt=="d": import...
orngMisc.printVerbose("Proportion: %5.3f" % p, verb)
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...
orngMisc.printVerbose(" loaded from cache", verb)
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...
orngMisc.printVerbose(" fold %d" % fold, verb)
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...
orngMisc.printVerbose("Proportion: %5.3f" % p, verb)
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...
orngMisc.printVerbose(" repetition %d" % t, verb)
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...
orngMisc.printVerbose(" loaded from cache", verb)
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...
if id[2]:
if id[2] != None:
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)...
for i in range(len(learners)): classifiers[i].name = learners[i].name
for i in range(len(learners)): classifiers[i].name = getattr(learners[i], "name", "noname")
def learnAndTestOnLearnData(learners, learnset, testResults=None, iterationNumber=0, pps=[], **argkw): storeclassifiers = argkw.get("storeclassifiers", 0) or argkw.get("storeClassifiers", 0) learnset, learnweight = demangleExamples(learnset) hasLorT = 0 for pp in pps: if pp[0]=="B": learnset = pp[1](learnset) else: h...
self.addText("Failed to locate file 'whatsdown.txt'. There is no information on installed Orange files.", nobr = 0)
self.addText("Failed to locate file 'whatsdown.txt'. There is no information on current versions of Orange files. By clicking 'Update files' you will download the latest versions of files.", nobr = 0)
def showFolders(self): self.updateGroups = [] self.dontUpdateGroups = [] try: vf = open(self.downfile) self.downstuff, self.updateGroups, self.dontUpdateGroups = self.readLocalVersionFile(vf.readlines(), updateGroups = 1) vf.close() except: self.addText("Failed to locate file 'whatsdown.txt'. There is no information on...
res = QMessageBox.information(self,'Update Orange',"There is no 'whatsdown.txt' file. This file contains information about versions of your local Orange files.\nIf you press 'Download Latest Files' you will replace all your local Orange files with the latest versions from the web.\n",'Download Latest Files', "Cancel", ...
res = QMessageBox.information(self, 'Update Orange', "The 'whatsdown.txt' file if missing (most likely because you downloaded Orange from CVS).\nThis file contains information about versions of your local Orange files.\n\nIf you press 'Replace Local Files' you will not replace only updated files, but will \noverwrite a...
def executeUpdate(self): self.addText("Reading file status from web server")
def countCompatibleConnections(self, outputs, inputs, outType, inType):
def countCompatibleConnections(self, outputs, inputs, outInstance, inInstance, outType, inType):
def countCompatibleConnections(self, outputs, inputs, outType, inType): count = 0 for outS in outputs: if not issubclass(eval(outS.type), eval(outType)): continue for inS in inputs: if not issubclass(eval(inType), eval(inS.type)): continue if issubclass(eval(outS.type), eval(inS.type)): count+= 1
if not issubclass(eval(outS.type), eval(outType)): continue
if not issubclass(outInstance.getOutputType(outS.name), outType): continue
def countCompatibleConnections(self, outputs, inputs, outType, inType): count = 0 for outS in outputs: if not issubclass(eval(outS.type), eval(outType)): continue for inS in inputs: if not issubclass(eval(inType), eval(inS.type)): continue if issubclass(eval(outS.type), eval(inS.type)): count+= 1
if not issubclass(eval(inType), eval(inS.type)): continue if issubclass(eval(outS.type), eval(inS.type)): count+= 1
if not issubclass(inType, inInstance.getInputType(inS.name)): continue if issubclass(outInstance.getOutputType(outS.name), inInstance.getInputType(inS.name)): count+= 1
def countCompatibleConnections(self, outputs, inputs, outType, inType): count = 0 for outS in outputs: if not issubclass(eval(outS.type), eval(outType)): continue for inS in inputs: if not issubclass(eval(inType), eval(inS.type)): continue if issubclass(eval(outS.type), eval(inS.type)): count+= 1
elif self.countCompatibleConnections(nonMinorOutputs, nonMinorInputs, outS.type, inS.type) > 1:
elif self.countCompatibleConnections(nonMinorOutputs, nonMinorInputs, self.outWidget.instance, self.inWidget.instance, outType, inType) > 1:
def addDefaultLinks(self): canConnect = 0 addedInLinks = [] addedOutLinks = [] self.multiplePossibleConnections = 0 # can we connect some signal with more than one widget
elif self.countCompatibleConnections(allOutputs, allInputs, outS.type, inS.type) > 1:
elif self.countCompatibleConnections(allOutputs, allInputs, self.outWidget.instance, self.inWidget.instance, outType, inType) > 1:
def addDefaultLinks(self): canConnect = 0 addedInLinks = [] addedOutLinks = [] self.multiplePossibleConnections = 0 # can we connect some signal with more than one widget
box=OWGUI.widgetBox(self.controlArea,"Show Info")
box=OWGUI.widgetBox(self.controlArea,"Show info")
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager,"CN2 Rules Viewer") self.inputs=[("CN2UnorderedClassifier", orngCN2.CN2UnorderedClassifier, self.data)] self.outputs=[("Examples", ExampleTable), ("Classified Examples", ExampleTableWithClass)] self.RuleLen=1 self.RuleQ=...
items=["Rule length", "Rule quality", "Coverage", "Predicted class",
items=["No sorting", "Rule length", "Rule quality", "Coverage", "Predicted class",
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager,"CN2 Rules Viewer") self.inputs=[("CN2UnorderedClassifier", orngCN2.CN2UnorderedClassifier, self.data)] self.outputs=[("Examples", ExampleTable), ("Classified Examples", ExampleTableWithClass)] self.RuleLen=1 self.RuleQ=...
l=[str(int(float(r.complexity))), "%.3f" % r.quality, str(len(self.classifier.examples.filterref(r.filter))),
l=[i,str(int(float(r.complexity))), "%.3f" % r.quality, "%.1f"%r.classDistribution.abs,
def showRules(self): self.clear() text=[] items=[] for i, r in enumerate(self.rules): l=[str(int(float(r.complexity))), "%.3f" % r.quality, str(len(self.classifier.examples.filterref(r.filter))), str(r.classifier.defaultValue), self.distText(r), self.ruleText(r),r] text.append(l) self.distText(r) self.text=text #self.i...
t.setText(text[0])
t.setText(text[1])
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
t.setText(text[1])
t.setText(text[2])
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
t.setText(text[2])
t.setText(text[3])
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
t.setText(text[3])
t.setText(text[4])
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
t.setText(text[4])
t.setText(text[5])
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
t=DistBar(text[4],self.Dist,self.canvas)
t=DistBar(text[5],self.Dist,self.canvas)
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
t.setText(text[5])
t.setText(text[6])
def drawRules(self): self.oldSelection=[r.rule for r in self.selRect] self.sort() self.clear() for r in self.rectObj: r.setCanvas(None) self.rectObj=[] text=self.text filter=[self.RuleLen, self.RuleQ, self.Coverage, self.Class, self.Dist or self.DistBar,self.Rule] l=[] #a=["Length","Quality","Coverage","Class","Distrib...
e=self.classifier.examples.filterref(r.filter) d=orange.Distribution(r.classifier.classVar,self.classifier.examples.filterref(r.filter))
d=r.classDistribution
def distText(self,r): e=self.classifier.examples.filterref(r.filter) d=orange.Distribution(r.classifier.classVar,self.classifier.examples.filterref(r.filter)) s=str(d).strip("<>") return "<"+",".join(["%.1f" % float(f) for f in s.split(",")])+">"
if max(a[-1].classDistribution)/sum(a[-1].classDistribution) \ < max(b[-1].classDistribution)/sum(b[-1].classDistribution): return -1 elif max(a[-1].classDistribution)/sum(a[-1].classDistribution) \ > max(b[-1].classDistribution)/sum(b[-1].classDistribution):
if max(a[-1].classDistribution)/a[-1].classDistribution.abs \ > max(b[-1].classDistribution)/b[-1].classDistribution.abs:
def compareDist(self,a,b): if max(a[-1].classDistribution)/sum(a[-1].classDistribution) \ < max(b[-1].classDistribution)/sum(b[-1].classDistribution): return -1 elif max(a[-1].classDistribution)/sum(a[-1].classDistribution) \ > max(b[-1].classDistribution)/sum(b[-1].classDistribution): return 1 else: return -1
if self.Sort==4:
if self.Sort==5:
def sort(self): text=[] if self.Sort==4: self.text.sort(self.compareDist) elif self.Sort==2 or self.Sort==0: self.text.sort(lambda a,b:int(a[self.Sort])-int(b[self.Sort])) else: if self.Sort>5: self.sortBy=self.Sort+1 else: self.sortBy=self.Sort self.text.sort(self.compare) #print self.text if self.Sort>=1 and self.Sor...
elif self.Sort==2 or self.Sort==0: self.text.sort(lambda a,b:int(a[self.Sort])-int(b[self.Sort])) else: if self.Sort>5:
elif self.Sort==3 or self.Sort==1: self.text.sort(lambda a,b:-cmp(float(a[self.Sort]),float(b[self.Sort]))) elif self.Sort==0: self.text.sort(lambda a,b:cmp(a[0],b[0])) else: if self.Sort>6:
def sort(self): text=[] if self.Sort==4: self.text.sort(self.compareDist) elif self.Sort==2 or self.Sort==0: self.text.sort(lambda a,b:int(a[self.Sort])-int(b[self.Sort])) else: if self.Sort>5: self.sortBy=self.Sort+1 else: self.sortBy=self.Sort self.text.sort(self.compare) #print self.text if self.Sort>=1 and self.Sor...
if self.Sort>=1 and self.Sort!=3 and self.Sort !=5:
if self.Sort>=2 and self.Sort!=4 and self.Sort !=6:
def sort(self): text=[] if self.Sort==4: self.text.sort(self.compareDist) elif self.Sort==2 or self.Sort==0: self.text.sort(lambda a,b:int(a[self.Sort])-int(b[self.Sort])) else: if self.Sort>5: self.sortBy=self.Sort+1 else: self.sortBy=self.Sort self.text.sort(self.compare) #print self.text if self.Sort>=1 and self.Sor...
return val/float(s), (acc, prediction, list(currentClassDistribution))
return val/max(1, float(s)), (acc, prediction, list(currentClassDistribution))
def computeAccuracyFromResults(self, table, results): prediction = [0.0 for i in range(len(table.domain.classVar.values))] countsByFold = [0 for i in range(results.numberOfIterations)]
return [filter(None, attrList)]
return [attrList]
def getAttributeSubsetUsingGammaDistribution(self, attrCount): maxTries = 50 triedDict = self.evaluationData.get("triedCombinations", {}) projCountWidth = len(triedDict.keys()) / 1000 if self.attrCont == CONT_MEAS_S2NMIX or self.attrSubsetSelection == GAMMA_SINGLE: numClasses = len(self.data.domain.classVar.values) at...
paded, derivativeID, metaIDs = orngPade.createQTable(self, data, self.dimensions,
paded, derivativeID, metaIDs, classID = orngPade.createQTable(self, data, self.dimensions,
def apply(self): data = self.data if not data: self.send("Examples", None) return
OWGUI.comboBox(self.stopping, self, "StressFunc", box="Stress Function", items=[a[0] for a in self.stressFunc], callback=lambda: not self.mds.getStress(self.stressFunc[self.StressFunc][1]) and self.graph.setLines(True) and self.graph.replot())
OWGUI.comboBox(self.stopping, self, "StressFunc", box="Stress Function", items=[a[0] for a in self.stressFunc], callback=self.updateStress)
def __init__(self, parent=None, signalManager=None, name="Multi Dimensional Scaling"): OWWidget.__init__(self, parent, signalManager, name)
st=time.clock()
def smacofStep(self): for i in range(self.NumIter): self.mds.SMACOFstep() if self.computeStress: self.mds.getStress(self.stressFunc[self.StressFunc][1]) self.stress=self.getAvgStress(self.stressFunc[self.StressFunc][1]) st=time.clock() if self.ReDraw: self.graph.updateData() #print "Update:", time.clock()-st
if self.mds: self.mds.Torgerson() if self.computeStress: self.mds.getStress(self.stressFunc[self.StressFunc][1]) self.stress=self.getAvgStress(self.stressFunc[self.StressFunc][1]) self.graph.updateData()
if not getattr(self, "mds", None): return self.mds.Torgerson() if self.computeStress: self.mds.getStress(self.stressFunc[self.StressFunc][1]) self.stress=self.getAvgStress(self.stressFunc[self.StressFunc][1]) self.graph.updateData()
def torgerson(self): if self.mds: self.mds.Torgerson() if self.computeStress: self.mds.getStress(self.stressFunc[self.StressFunc][1]) self.stress=self.getAvgStress(self.stressFunc[self.StressFunc][1]) self.graph.updateData()
if (constype!="ABSTRACT"): addClassDef(classdefs, typename, parsedFile, "constructor", ConstructorDefinition(arguments=doc, type=constype))
if constype=="ABSTRACT": classdefs[typename].abstract = True else: addClassDef(classdefs, typename, parsedFile, "constructor", ConstructorDefinition(arguments=doc, type=constype, allows_empty_args = True))
def detectConstructors(line, classdefs): found=constrdef_mac.search(line) if not found: found=constrdef_mac_call3.search(line) if found: typename, basename, constype, doc=found.group("typename", "basename", "constype", "doc") printV2("%s (%s): Macro constructor %s", (typename, basename, constype)) addClassDef(classdefs...
return 1 found = nopickle.search(line) if found: typename = found.group("typename") addClassDef(classdefs, typename, parsedFile) classdefs[typename].methods["__reduce__"] = MethodDefinition(argkw="METH_NOARGS", cname="*yieldNoPickleError") return 1
def detectConstructors(line, classdefs): found=constrdef_mac.search(line) if not found: found=constrdef_mac_call3.search(line) if found: typename, basename, constype, doc=found.group("typename", "basename", "constype", "doc") printV2("%s (%s): Macro constructor %s", (typename, basename, constype)) addClassDef(classdefs...
found=methoddef.search(line) if found: typename, cname, methodname, argkw, doc = found.group("typename", "cname", "methodname", "argkw", "doc")
else: found=methoddef.search(line) if found: typename, cname, methodname, argkw, doc = found.group("typename", "cname", "methodname", "argkw", "doc") if typename:
def detectMethods(line, classdefs): # The below if is to avoid methods, like, for instance, map's clear to be recognized # also as a special method. Special methods never include PYARGS... if line.find("PYARGS")<0: found=specialmethoddef.search(line) if found: typename, methodname = found.group("typename", "methodname"...
addClassDef(classdefs, typename, parsedFile, "constructor", ConstructorDefinition(arguments=doc, type="MANUAL"))
addClassDef(classdefs, typename, parsedFile, "constructor", ConstructorDefinition(arguments=doc, type="MANUAL", allows_empty_args=allows_empty_args))
def detectHierarchy(line, classdefs): found=datastructuredef.search(line) if found: typename, structurename, dictfield = found.group("typename", "structurename", "dictfield") addClassDef(classdefs, typename, parsedFile, "datastructure", structurename) addClassDef(classdefs, typename, parsedFile, "dictfield", dictfield,...
outfile.write(' {"'+methodname+'", (binaryfunc)'+type+"_"+method.cname+", "+method.argkw+", \""+method.arguments+"\"},\n")
outfile.write(' {"'+methodname+'", (binaryfunc)'+cname+", "+method.argkw+", \""+method.arguments+"\"},\n")
def writeAppendix(filename, targetname, classdefs, aliases): if ( not recreate and os.path.isfile(targetname) and (os.path.getmtime(targetname)>=os.path.getmtime(filename)) and (os.path.getmtime(targetname)>=os.path.getmtime("aliases.txt"))): printV1("\nFile unchanged, skipping.") return usedbases={} classdefi=cla...
outfile.write(' {"'+methodname+'", (binaryfunc)'+type+"_"+method.cname+", "+method.argkw+"},\n")
outfile.write(' {"'+methodname+'", (binaryfunc)'+cname+", "+method.argkw+"},\n")
def writeAppendix(filename, targetname, classdefs, aliases): if ( not recreate and os.path.isfile(targetname) and (os.path.getmtime(targetname)>=os.path.getmtime(filename)) and (os.path.getmtime(targetname)>=os.path.getmtime("aliases.txt"))): printV1("\nFile unchanged, skipping.") return usedbases={} classdefi=cla...
outfile.write(' "'+type+'",\n')
outfile.write(' "%s.%s",\n' % (modulename, type))
def write0(innulls): outfile.write(innulls and ' 0,' or ' 0,') return 1
PyObject *%(modulename)sModule;
extern %(MODULENAME)s_API PyObject *%(modulename)sModule;
#ifdef _MSC_VER #define WIN32_LEAN_AND_MEAN #include <windows.h> BOOL APIENTRY DllMain( HANDLE, DWORD ul_reason_for_call, LPVOID) { return TRUE; }
def printV0(str="", tup=()): print "%20s:%4i:" % (parsedFile, lineno),
def printV0(str="", tup=(), printLine = True): if printLine: print "%20s:%4i:" % (parsedFile, lineno),
def printV0(str="", tup=()): print "%20s:%4i:" % (parsedFile, lineno), print str % tup
def printV2(str="", tup=()):
def printV2(str="", tup=(), printLine = True):
def printV2(str="", tup=()): if verbose==2: printV0(str, tup)
printV0(str, tup)
printV0(str, tup, printLine)
def printV2(str="", tup=()): if verbose==2: printV0(str, tup)
def printV1(str="", tup=()):
def printV1(str="", tup=(), printLine = True):
def printV1(str="", tup=()): if verbose>=1: print str % tup
print str % tup
printV0(str, tup, printLine)
def printV1(str="", tup=()): if verbose>=1: print str % tup
filename = QFileDialog.getSaveFileName(startfile, 'Tab-delimited files (*.tab)\nHeaderless tab-delimited (*.txt)\nComma separated (*.csv)\nC4.5 files (*.data)\nAssistant files (*.dat)\nRetis files (*.rda *.rdo)\nAll files(*.*)', None,'Orange Data File')
dlg = QFileDialog(startfile, 'Tab-delimited files (*.tab)\nHeaderless tab-delimited (*.txt)\nComma separated (*.csv)\nC4.5 files (*.data)\nAssistant files (*.dat)\nRetis files (*.rda *.rdo)\nAll files(*.*)', None, "Orange Data File", True) dlg.exec_loop() filename = str(dlg.selectedFile()) ext = lower(os.path.splitext...
def browseFile(self): if self.recentFiles: startfile = self.recentFiles[0] else: startfile = "." filename = QFileDialog.getSaveFileName(startfile, 'Tab-delimited files (*.tab)\nHeaderless tab-delimited (*.txt)\nComma separated (*.csv)\nC4.5 files (*.data)\nAssistant files (*.dat)\nRetis files (*.rda *.rdo)\nAll files(*...
savers = {".txt": orange.saveTxt, ".tab": orange.saveTabDelimited, ".names": orange.saveC45, ".test": orange.saveC45, ".data": orange.saveC45, ".rda": orange.saveRetis, ".rdo": orange.saveRetis, ".csv": orange.saveCsv}
def browseFile(self): if self.recentFiles: startfile = self.recentFiles[0] else: startfile = "." filename = QFileDialog.getSaveFileName(startfile, 'Tab-delimited files (*.tab)\nHeaderless tab-delimited (*.txt)\nComma separated (*.csv)\nC4.5 files (*.data)\nAssistant files (*.dat)\nRetis files (*.rda *.rdo)\nAll files(*...
if data or not self.data:
else:
def sendDataAndImputer(self): self.constructImputer() self.send("Imputer", self.imputer) if self.data and self.imputer: constructed = self.imputer(self.data) try: data = constructed(self.data) except: self.error("Imputation failed; this is typically due to unsuitable model.") data = None self.send("Classified Examples"...
elif graph[i,k][VALUE] == tooDistantValue: for n in graph.getNeighbours(k): if graph[k,n][VALUE] == differentClassValue: otherClassPoints.append(n)
elif graph[i,merged[k]][VALUE] == tooDistantValue or graph[j,merged[k]][VALUE] == tooDistantValue: for n in graph.getNeighbours(merged[k]): if graph[merged[k],n][VALUE] == differentClassValue and n not in otherClassPoints: otherClassPoints.append(n)
def computeClosure(graph, edgesDict, minimumValidIndex, innerEdgeValue, outerEdgeValue, differentClassValue, tooDistantValue): closureDict = {} for key in edgesDict.keys(): closureDict[key] = [] # create dictionary where each cluster will contain all edges that lie on the closure for (i,j) in graph.getEdges(): if grap...
if points < 3: continue
if points < 2: continue points += len(closureDict[key])/float(2) if points < 5: continue
def evaluateClusters(self, data): #fullgraph = orange.triangulate(data,3) graph = orange.triangulate(data,3) graph.returnIndices = 1 computeDistances(graph) removeEdgesToDifferentClasses(graph, -3) # None removeSingleLines(graph, None, None, None, 0, -1) edgesDict, clusterDict, verticesDict, count = enumerateCluster...
for v in otherClassDict[index]:
for v in allOtherClass: if graph.objects[v].getclass() == graph.objects[i].getclass(): continue
def evaluateClusters(self, data): #fullgraph = orange.triangulate(data,3) graph = orange.triangulate(data,3) graph.returnIndices = 1 computeDistances(graph) removeEdgesToDifferentClasses(graph, -3) # None removeSingleLines(graph, None, None, None, 0, -1) edgesDict, clusterDict, verticesDict, count = enumerateCluster...
diffClass = [i*i for i in diffClass[:5]] dist = sum(diffClass) / float(max(1, len(diffClass)))
dist = sum(diffClass[:3]) / float(len(diffClass[:3]))
def evaluateClusters(self, data): #fullgraph = orange.triangulate(data,3) graph = orange.triangulate(data,3) graph.returnIndices = 1 computeDistances(graph) removeEdgesToDifferentClasses(graph, -3) # None removeSingleLines(graph, None, None, None, 0, -1) edgesDict, clusterDict, verticesDict, count = enumerateCluster...
otherDict[key] = (graph.objects[polygonVerticesDict[key][0]].getclass().value, value, points, dist, area)
otherDict[key] = (graph.objects[polygonVerticesDict[key][0]].getclass().value, value, points, dist, aveDistDict[key])
def evaluateClusters(self, data): #fullgraph = orange.triangulate(data,3) graph = orange.triangulate(data,3) graph.returnIndices = 1 computeDistances(graph) removeEdgesToDifferentClasses(graph, -3) # None removeSingleLines(graph, None, None, None, 0, -1) edgesDict, clusterDict, verticesDict, count = enumerateCluster...
self.send(widgetFrom, signalNameFrom, None, None)
widgetTo.updateNewSignalData(widgetFrom, signalNameTo, None, None)
def removeLink(self, widgetFrom, widgetTo, signalNameFrom, signalNameTo): # no need to update topology, just remove the link for (widget, signalFrom, signalTo, enabled) in self.links[widgetFrom]: if widget == widgetTo and signalFrom == signalNameFrom and signalTo == signalNameTo: #print "signal Manager - remove link. r...
if polygonVerticesDict[key] < 6: continue
def updateData(self, labels, **args): self.removeDrawingCurves() # my function, that doesn't delete selection curves #self.removeCurves() self.removeMarkers()
classIndex = self.attributeNames.index(self.rawdata.domain.classVar.name) if self.rawdata.domain.classVar.varType == orange.VarTypes.Discrete: classList = Numeric.compress(validData, (self.noJitteringScaledData[classIndex]*2*len(self.rawdata.domain.classVar.values)- 1 )/2.0) else: ...
classList = Numeric.transpose(self.rawdata.toNumeric("c")[0])[0] classList = Numeric.compress(validData, classList)
def createProjectionAsNumericArray(self, attrIndices, validData = None, classList = None, sum_i = None, XAnchors = None, YAnchors = None, scaleFactor = 1.0, jitterSize = 0.0): if not validData: validData = self.getValidList(attrIndices)
classList = Numeric.compress(validData, (self.noJitteringScaledData[classIndex]*2*len(self.rawdata.domain.classVar.values)- 1 )/2.0)
classList = Numeric.transpose(self.rawdata.toNumeric("c")[0])[0] classList = Numeric.compress(validData, classList)
def getOptimalClusters(self, attributes, minLength, maxLength, addResultFunct): dataSize = len(self.rawdata) lastTime = time.time()
self.parentWidget.hiddenAttribsLB.insertItem(t[2])
def removeHidden(self): rad2 = (self.graph.hideRadius/10)**2 rem = 0 newAnchorData = [] for i, t in enumerate(self.graph.anchorData): if t[0]**2 + t[1]**2 < rad2: self.parentWidget.shownAttribsLB.removeItem(i-rem) self.parentWidget.hiddenAttribsLB.insertItem(t[2]) rem += 1 else: newAnchorData.append(t) self.graph.ancho...
steps = 0
def optimize(self, nrOfSteps = -1): self.optimizeButton.hide() self.stopButton.show() self.cancelOptimization = 0
while self.cancelOptimization != 1 and nrOfSteps != totalSteps:
while not self.cancelOptimization and nrOfSteps != totalSteps:
def optimize(self, nrOfSteps = -1): self.optimizeButton.hide() self.stopButton.show() self.cancelOptimization = 0
steps += 1
def optimize(self, nrOfSteps = -1): self.optimizeButton.hide() self.stopButton.show() self.cancelOptimization = 0
if steps >= self.stepsBeforeUpdate:
if not totalSteps % self.stepsBeforeUpdate:
def optimize(self, nrOfSteps = -1): self.optimizeButton.hide() self.stopButton.show() self.cancelOptimization = 0
x_positions = projData[0] y_positions = projData[1] classData = projData[2]
x_positions = projData[0]; x_positions2 = Numeric.array(x_positions) y_positions = projData[1]; y_positions2 = Numeric.array(y_positions) classData = projData[2] ; classData2 = Numeric.array(classData)
def optimizationStep(self, attrIndices, anchorData): dataSize = len(self.rawdata) validData = self.graph.getValidList(attrIndices) selectedData = Numeric.compress(validData, Numeric.take(self.graph.noJitteringScaledData, attrIndices))
x_positions2 = Numeric.array(x_positions) y_positions2 = Numeric.array(y_positions) classData2 = Numeric.array(classData)
def optimizationStep(self, attrIndices, anchorData): dataSize = len(self.rawdata) validData = self.graph.getValidList(attrIndices) selectedData = Numeric.compress(validData, Numeric.take(self.graph.noJitteringScaledData, attrIndices))
Numeric.putmask(F, classDiff, 100*self.attractG*rs2) Numeric.putmask(F, 1-classDiff, -self.repelG/rs)
Numeric.putmask(F, classDiff, 150*self.attractG*rs2) Numeric.putmask(F, 1-classDiff, -self.repelG/rs2)
def optimizationStep(self, attrIndices, anchorData): dataSize = len(self.rawdata) validData = self.graph.getValidList(attrIndices) selectedData = Numeric.compress(validData, Numeric.take(self.graph.noJitteringScaledData, attrIndices))
m = max(max(GXs), max(GYs))
m = max(max(abs(GXs)), max(abs(GYs)))
def optimizationStep(self, attrIndices, anchorData): dataSize = len(self.rawdata) validData = self.graph.getValidList(attrIndices) selectedData = Numeric.compress(validData, Numeric.take(self.graph.noJitteringScaledData, attrIndices))
xcoeffs = [0.0]*(len(svs[0])-1)
ll = -1 for i in xrange(classifier.model["total_sv"]): ll = max(ll,svs[i][-1][0]) xcoeffs = [0.0]*(ll)
def __call__(self,classifier,examples, buckets): if classifier.model['kernel_type'] != 0: raise "Use SVM with a linear kernel." if classifier.model["svm_type"] != 0: raise "Use ordinary SVM classification." if classifier.model["nr_class"] != 2: raise "This is not SVM with a binary class."
settings = cPickle.load(file) if hasattr(self, "settingsList"): self.setSettings(settings) contextHandlers = getattr(self, "contextHandlers", {}) for contextHandler in contextHandlers.values(): if not getattr(contextHandler, "globalContexts", False): contexts = settings.get(contextHandler.localContextName, False) if ...
try: settings = cPickle.load(file) except: settings = None if settings: if hasattr(self, "settingsList"): self.setSettings(settings) contextHandlers = getattr(self, "contextHandlers", {}) for contextHandler in contextHandlers.values(): if not getattr(contextHandler, "globalContexts", False): contexts = settings.get(...
def loadSettings(self, file = None): file = self.getSettingsFile(file) if file: settings = cPickle.load(file)
settings = cPickle.load(file) if settings.has_key("savedContextSettings"): self.__class__.savedContextSettings = settings["savedContextSettings"] return
try: settings = cPickle.load(file) except: settings = None if settings: if settings.has_key("savedContextSettings"): self.__class__.savedContextSettings = settings["savedContextSettings"] return
def loadContextSettings(self, file = None): if not hasattr(self.__class__, "savedContextSettings"): file = self.getSettingsFile(file) if file: settings = cPickle.load(file) if settings.has_key("savedContextSettings"): self.__class__.savedContextSettings = settings["savedContextSettings"] return self.__class__.savedCont...
OWGUI.button(self.controlArea, self, "Save As", callback=self.saveGraph)
OWGUI.button(self.controlArea, self, "Save As", callback=self.saveGraph, debuggingEnabled = 0)
def __init__(self, parent=None, signalManager = None, name='ClassificationTreeViewer2D'): OWTreeViewer2D.__init__(self, parent, signalManager, name) self.settingsList=self.settingsList+["ShowPies","TargetClassIndex"] self.inputs = [("Classification Tree", orange.TreeClassifier, self.ctree)] self.outputs = [("Examples"...
h_proj = m - Numeric.dot(Numeric.reshape(h_dist,(len(examples),1)),Numeric.reshape(n,(1,len(coeffs))))
h_proj = m - Numeric.dot(Numeric.reshape(h_dist,(len(examples),1)),Numeric.reshape(n,(1,len(coeffs))))/Numeric.dot(n,n)
def __init__(self, examples, classifier, dimensions = 2, buckets = 3, getpies = 0, getexamples = 1): # error detection if len(examples.domain.classVar.values) != 2: raise "The domain does not have a binary class. Binary class is required."
basis_proj = basis - Numeric.dot(Numeric.reshape(basis_dist,(len(coeffs),1)),Numeric.reshape(n,(1,len(coeffs))))
basis_proj = basis - Numeric.dot(Numeric.reshape(basis_dist,(len(coeffs),1)),Numeric.reshape(n,(1,len(coeffs))))/Numeric.dot(n,n)
def __init__(self, examples, classifier, dimensions = 2, buckets = 3, getpies = 0, getexamples = 1): # error detection if len(examples.domain.classVar.values) != 2: raise "The domain does not have a binary class. Binary class is required."
return "<MD>"
existing = open(filename, "rb") currmd = md5.new() currmd.update(existing.read()) existing.close() return currmd
def computeMD(filename): return "<MD>"
outf.write('FileWrite $6 "%s:%s=%s$\\r$\\n"\n' % whatsDownEntries[fle])
outf.write('FileWrite $6 "%s=%s:%s$\\r$\\n"\n' % whatsDownEntries[fle])
def buildListLow(root_dir, here_dir, there_dir, regexp, outf, recursive): if not os.path.exists(root_dir+here_dir): return whatsDownEntries = None directories = [] for fle in os.listdir(root_dir+here_dir): tfle = root_dir+here_dir+fle #print there_dir+fle if fle == "CVS" or ("orange\\"+there_dir+fle).lower() in exclud...
self.mwidget = OWGUI.lineEdit(box, self, 'm', label='Parameter for m-estimate:', labelWidth=width, orientation='horizontal', box=None, space=None, tooltip=None, callback=None, valueType = str, validator = mValid)
self.mwidget = OWGUI.lineEdit(box, self, 'm', label='Parameter for m-estimate:', labelWidth=width, orientation='horizontal', box=None, tooltip=None, callback=None, valueType = str, validator = mValid)
def __init__(self, parent=None, signalManager = None, name='NaiveBayes'): OWWidget.__init__(self, parent, signalManager, name)
labelWidth=width, orientation='horizontal', box=None, space=None, tooltip='Proportion of examples used for local learning in loess. Use 0 to learn from few local instances (3) and 1 to learn from all in the data set (this kind of learning is not local anymore).',
labelWidth=width, orientation='horizontal', box=None, tooltip='Proportion of examples used for local learning in loess. Use 0 to learn from few local instances (3) and 1 to learn from all in the data set (this kind of learning is not local anymore).',
def __init__(self, parent=None, signalManager = None, name='NaiveBayes'): OWWidget.__init__(self, parent, signalManager, name)
return (beta, coeffs, coeff_names, basis, m, lambda x:math.exp(x)/(1.0+math.exp(x)), 0)
return (beta, coeffs, coeff_names, basis, m, lambda x:math.exp(x)/(1.0+math.exp(x)))
def __call__(self,classifier,examples, buckets): # todo todo - support for loess for i in xrange(len(examples.domain.attributes)): for j in xrange(len(examples)): if examples[j][i].isSpecial(): raise "A missing value found in instance %d, attribute %s. Missing values are not allowed."%(j,examples.domain.attributes[i].n...
return (beta, coeffs, coeff_names, basis, m, lambda x:math.exp(x)/(1.0+math.exp(x)),0)
return (beta, coeffs, coeff_names, basis, m, lambda x:math.exp(x)/(1.0+math.exp(x)))
def __call__(self,classifier,examples, buckets): # skip domain translation and masking robustc = classifier.classifier primitivec = robustc.classifier beta = -primitivec.beta[0]
if classifier.model["label"][0] == 0: beta = -beta xcoeffs = [-x for x in xcoeffs] flip = 1 else: flip = 0
def __call__(self,classifier,examples, buckets): if classifier.model['kernel_type'] != 0: raise "Use SVM with a linear kernel." if classifier.model["svm_type"] != 0: raise "Use ordinary SVM classification." if classifier.model["nr_class"] != 2: raise "This is not SVM with a binary class."
return (beta, coeffs, coeff_names, basis, m, _treshold, flip)
return (beta, coeffs, coeff_names, basis, m, _treshold)
def __call__(self,classifier,examples, buckets): if classifier.model['kernel_type'] != 0: raise "Use SVM with a linear kernel." if classifier.model["svm_type"] != 0: raise "Use ordinary SVM classification." if classifier.model["nr_class"] != 2: raise "This is not SVM with a binary class."