# Changeset 8756:839916280472 in orange

Ignore:
Timestamp:
08/24/11 13:01:26 (3 years ago)
Branch:
default
Convert:
1b92d7e1feb4c8738f4f85c78a5d752f898d9afc
Message:

Enabled vizrank for sphereviz and linproj3d

Location:
orange
Files:
4 edited

Unmodified
Removed
• ## orange/Orange/preprocess/scaling.py

 r8735 @deprecated_keywords({"numOfAttr": "num_of_attr"}) def create_anchors(self, num_of_attr, labels=None): def create_anchors(self, num_of_attrs, labels=None): """ Create anchors on the sphere. # Golden Section Spiral algorithm approximates even distribution of points on a sphere # (read more here http://www.softimageblog.com/archives/115) n = num_of_attr n = num_of_attrs xanchors = [] yanchors = [] yanchors.append(y) zanchors.append(math.sin(phi)*r) r = numpy.ones(len(xanchors), numpy.float) self.anchor_dict[num_of_attrs] = [xanchors, yanchors, zanchors] if labels: return [(xanchors[i], yanchors[i], zanchors[i], labels[i]) for i in range(num_of_attr)] else: return [(xanchors[i], yanchors[i], zanchors[i]) for i in range(num_of_attr)] return [(xanchors[i], yanchors[i], zanchors[i], labels[i]) for i in range(num_of_attrs)] else: return [(xanchors[i], yanchors[i], zanchors[i]) for i in range(num_of_attrs)] createAnchors = create_anchors @deprecated_keywords({"numOfAttrs": "num_of_attrs"}) def create_xanchors(self, num_of_attrs): if not self.anchor_dict.has_key(num_of_attrs): self.create_anchors(num_of_attrs) return self.anchor_dict[num_of_attrs][0] createXAnchors = create_xanchors @deprecated_keywords({"numOfAttrs": "num_of_attrs"}) def create_yanchors(self, num_of_attrs): if not self.anchor_dict.has_key(num_of_attrs): self.create_anchors(num_of_attrs) return self.anchor_dict[num_of_attrs][1] createYAnchors = create_yanchors @deprecated_keywords({"numOfAttrs": "num_of_attrs"}) def create_zanchors(self, num_of_attrs): if not self.anchor_dict.has_key(num_of_attrs): self.create_anchors(num_of_attrs) return self.anchor_dict[num_of_attrs][2] createZAnchors = create_zanchors @deprecated_keywords({"fileName": "filename", "attrList": "attrlist",
• ## orange/OrangeWidgets/Visualize Qt/OWLinProj3DPlot.py

 r8754 def replot(self): pass def saveToFile(self): pass
• ## orange/OrangeWidgets/Visualize Qt/OWLinProjQt.py

 r8752 self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) elif "sphereviz" in name_lower: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SPHEREVIZ3D, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) elif "3d" in name_lower: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION3D, name) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) else: self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name)
• ## orange/orngVizRank.py

 r8735 POLYVIZ = 4 SCATTERPLOT3D = 5 SPHEREVIZ3D = 6 LINEAR_PROJECTION3D = 7 KNN_IN_ORIGINAL_SPACE = 10 permutations = self.getNextPermutations() elif self.visualizationMethod in (SPHEREVIZ3D, LINEAR_PROJECTION3D): if self.projOptimizationMethod != 0: self.freeviz.useGeneralizedEigenvectors = 1 self.graph.normalize_examples = 0 # variables and domain for the table domain = orange.Domain([orange.FloatVariable("xVar"), orange.FloatVariable("yVar"), orange.FloatVariable("zVar"), orange.EnumVariable(self.graph.data_domain.classVar.name, values = getVariableValuesSorted(self.graph.data_domain.classVar))]) minLength = (self.optimizationType == EXACT_NUMBER_OF_ATTRS and self.attributeCount) or 3 maxLength = self.attributeCount classListFull = self.graph.original_data[self.graph.data_class_index] # each call to selectNextAttributeSubset gets a new combination of attributes in a range from minLength to maxLength. if we return None for a given number of attributes this # doesn't mean yet that there are no more possible combinations. it may be just that we wanted a combination of 6 attributes in a domain with 4 attributes. therefore we have # to try maxLength-minLength+1 times and if we fail every time then there are no more valid projections newProjectionsExist = 1 while newProjectionsExist: for experiment in range(maxLength-minLength+1): if self.selectNextAttributeSubset(minLength, maxLength): break newProjectionsExist = 0 permutations = self.getNextPermutations() while permutations: attrIndices = permutations[0] # if we use SPCA, PLS if self.projOptimizationMethod != 0: projections = self.freeviz.findProjection(self.projOptimizationMethod, attrIndices, set_anchors = 0, percentDataUsed = self.percentDataUsed) if projections != None: xanchors, yanchors, zanchors, (attrNames, newIndices) = projections table = self.graph.create_projection_as_example_table(newIndices, domain = domain, XAnchors = xanchors, YAnchors = yanchors, ZAnchors = zanchors) if len(table) < self.minNumOfExamples: continue self.evaluatedProjectionsCount += 1 accuracy, other_results = self.evaluateProjection(table) generalDict = {"XAnchors": list(xanchors), "YAnchors": list(yanchors), "ZAnchors": list(zanchors), "Results": self.evaluationResults} if self.saveEvaluationResults else {"XAnchors": list(xanchors), "YAnchors": list(yanchors), "ZAnchors": list(zanchors)} self.addResult(accuracy, other_results, len(table), attrNames, self.evaluatedProjectionsCount, generalDict = generalDict) if self.isEvaluationCanceled(): return self.evaluatedProjectionsCount if self.__class__ != VizRank: self.setStatusBarText("Evaluated %s projections..." % (orngVisFuncts.createStringFromNumber(self.evaluatedProjectionsCount))) else: XAnchors = self.graph.create_xanchors(len(attrIndices)) YAnchors = self.graph.create_yanchors(len(attrIndices)) ZAnchors = self.graph.create_zanchors(len(attrIndices)) validData = self.graph.get_valid_list(attrIndices) if numpy.sum(validData) >= self.minNumOfExamples: classList = numpy.compress(validData, classListFull) selectedData = numpy.compress(validData, numpy.take(self.graph.no_jittering_scaled_data, attrIndices, axis = 0), axis = 1) sum_i = self.graph._getSum_i(selectedData) tempList = [] # for every permutation compute how good it separates different classes for permutation in permutations: if self.evaluatedProjectionsCount % 10 == 0 and self.isEvaluationCanceled(): continue table = self.graph.create_projection_as_example_table(permutation, validData = validData, classList = classList, sum_i = sum_i, XAnchors = XAnchors, YAnchors = YAnchors, ZAnchors = ZAnchors, domain = domain) accuracy, other_results = self.evaluateProjection(table) # save the permutation if self.storeEachPermutation: generalDict = {"Results": self.evaluationResults} if self.saveEvaluationResults else {} self.addResult(accuracy, other_results, len(table), [self.graph.attribute_names[i] for i in permutation], self.evaluatedProjectionsCount, generalDict) else: tempList.append((accuracy, other_results, len(table), [self.graph.attribute_names[i] for i in permutation])) self.evaluatedProjectionsCount += 1 if self.__class__ != VizRank: self.setStatusBarText("Evaluated %s projections..." % (orngVisFuncts.createStringFromNumber(self.evaluatedProjectionsCount))) qApp.processEvents()        # allow processing of other events if not self.storeEachPermutation and len(tempList) > 0:   # return only the best attribute placements (acc, other_results, lenTable, attrList) = maxFunct(tempList) generalDict = {"Results": self.evaluationResults} if self.saveEvaluationResults else {} self.addResult(acc, other_results, lenTable, attrList, self.evaluatedProjectionsCount, generalDict=generalDict) if self.isEvaluationCanceled(): return self.evaluatedProjectionsCount permutations = self.getNextPermutations() elif self.visualizationMethod == SCATTERPLOT3D: evaluatedAttributes = self.getEvaluatedAttributes() for testProj in testProjections: table = self.graph.create_projection_as_example_table(testProj, domain = domain) if len(table) < self.minNumOfExamples: continue acc, other_results = self.evaluateProjection(table) if hasattr(self, "setStatusBarText") and self.optimizedProjectionsCount % 10 == 0: self.setStatusBarText("Evaluated %s projections. Last accuracy was: %2.2f%%" % (orngVisFuncts.createStringFromNumber(self.optimizedProjectionsCount), acc)) if acc > accuracy: self.addResult(acc, other_results, len(table), [self.graph.attribute_names[i] for i in testProj], projIndex) self.insertTempProjection(projections, acc, testProj) tempDict[tuple(testProj)] = 1 if min(acc, accuracy) != 0 and max(acc, accuracy) > 1.005 *min(acc, accuracy):  significantImprovement = 1 self.optimizedProjectionsCount += 1 if self.__class__ != VizRank: qApp.processEvents()        # allow processing of other events if self.optimizedProjectionsCount % 10 == 0 and self.isOptimizationCanceled(): return self.optimizedProjectionsCount if significantImprovement: break elif self.visualizationMethod == SCATTERPLOT3D: classListFull = self.graph.original_data[self.graph.data_class_index] tempDict = {} projIndex = 0 while len(projections) > 0: (accuracy, projection) = projections.pop(0) projIndex -= 1 significantImprovement = 0 strTotalAtts = orngVisFuncts.createStringFromNumber(lenOfAttributes) for (attrIndex, attr) in enumerate(attributes): if attr in projection: continue testProjections = [] if not tempDict.has_key((projection[0], attr)) and not tempDict.has_key((attr, projection[0])): testProjections.append([projection[0], attr]) if not tempDict.has_key((projection[1], attr)) and not tempDict.has_key((attr, projection[1])): testProjections.append([attr, projection[1]]) for testProj in testProjections: table = self.graph.create_projection_as_example_table_3D(testProj, domain = domain) if len(table) < self.minNumOfExamples: continue acc, other_results = self.evaluateProjection(table)
Note: See TracChangeset for help on using the changeset viewer.