Changeset 7780:bdfd837386f0 in orange
 Timestamp:
 03/25/11 14:17:44 (3 years ago)
 Branch:
 default
 Convert:
 d1a0acbe8a162afd4ca03ab19be64ec8523b2d46
 Location:
 orange
 Files:

 4 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

orange/Orange/preprocess/__init__.py
r6852 r7780 1 """ 2 .. automodule:: Orange.preprocess.outliers 3 """ 4 1 5 from orange import \ 2 6 DomainContinuizer, \ … … 76 80 RemoveRedundantOneValue, \ 77 81 RemoveUnusedValues 82 83 import outliers 
orange/doc/Orange/rst/index.rst
r7765 r7780 31 31 Orange.optimization 32 32 33 Orange.preprocess 34 33 35 Orange.projection 34 36 
orange/orngOutlier.py
r6538 r7780 1 import orange 2 import statc 3 4 class OutlierDetection: 5 6 def __init__(self): 7 self.clear() 8 self.setKNN() 9 10 def clear(self): 11 #distmatrix not calculated yet 12 self.distmatrixC = 0 13 14 #using distance measurment 15 self.distance = None 16 17 self.examples = None 18 self.distmatrix = None 19 20 def setExamples(self, examples, distance = None): 21 self.clear() 22 self.examples = examples 23 if (distance == None): 24 distance = orange.ExamplesDistanceConstructor_Manhattan(self.examples) 25 self.distance = distance 26 27 def setDistanceMatrix(self, distances): 28 self.clear() 29 self.distmatrix = distances 30 self.distmatrixC = 1 31 32 def setKNN(self, knn=0): 33 self.knn = knn 34 35 def calcDistanceMatrix(self): 36 #other distance measures 37 self.distmatrix = orange.SymMatrix(len(self.examples)) 38 for i in range(len(self.examples)): 39 for j in range(i+1): 40 self.distmatrix[i, j] = self.distance(self.examples[i], self.examples[j]) 41 self.distmatrixC = 1 42 43 def distanceMatrix(self): 44 if (self.distmatrixC == 0): 45 self.calcDistanceMatrix() 46 return self.distmatrix 47 48 def averageMeans(self): 49 means = [] 50 dm = self.distanceMatrix() 51 for i,dist in enumerate(dm): 52 nearest = self.findNearestLimited(i, dist, self.knn) 53 means.append(self.average(nearest)) 54 return means 55 56 def average(self, list): 57 av = 0.0 58 for el in list: 59 av = av + el 60 return av/len(list) 61 62 def findNearestLimited(self, i, dist, knn): 63 copy = [] 64 for el in dist: 65 copy.append(el) 66 #remove distance to same element 67 copy[i:i+1] = [] 68 if (knn == 0): 69 return copy 70 else: 71 takelimit = min(len(dist)1, knn) 72 copy.sort() 73 return copy[:takelimit] 74 75 def zValues(self): 76 list = self.averageMeans() 77 return [statc.z(list, e) for e in list] 1 from Orange.preprocess.outliers import *
Note: See TracChangeset
for help on using the changeset viewer.