Ignore:
Timestamp:
02/06/12 10:56:22 (2 years ago)
Author:
markotoplak
Branch:
default
Message:

Orange.distance renames.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/distance/__init__.py

    r9663 r9719  
    11import Orange 
     2 
     3#ExampleDistance -> Distance 
     4#ExampleDistanceConstructor -> DistanceConstructor 
     5#Hamming -> HammingDistance 
     6#DTW -> DTWDistance 
     7#Euclidean -> EuclideanDistance 
     8#Manhattan -> ... 
     9#Maximal -> ... 
     10#Relief -> .. 
     11#DTWConstructor 
     12#EuclideanConstructor 
     13#HammingConstructor 
     14#ManhattanConstructor 
     15#MaximalConstructor 
     16#ReliefConstructor 
     17#PearsonRConstructor -> PearsonR 
     18#PearsonR -> PearsonRDistance 
     19#SpearmanRConstructor -> SpearmanR 
     20#SpearmanR -> SpearmanRDistance 
     21#MahalanobisConstructor ->  Mahalanobis 
     22#Mahalanobis -> MahalanobisDistance 
     23#ExamplesDistance_Normalized -> Distance_Normalized 
    224 
    325from Orange.core import \ 
     
    830     ExampleDistBySorting, \ 
    931     ExampleDistVector, \ 
    10      ExamplesDistance, \ 
    11      ExamplesDistance_Normalized, \ 
    12      ExamplesDistanceConstructor 
    13  
    14 from Orange.core import ExamplesDistance_Hamming as Hamming 
    15 from Orange.core import ExamplesDistance_DTW as DTW 
    16 from Orange.core import ExamplesDistance_Euclidean as Euclidean 
    17 from Orange.core import ExamplesDistance_Manhattan as Manhattan 
    18 from Orange.core import ExamplesDistance_Maximal as Maximal 
    19 from Orange.core import ExamplesDistance_Relief as Relief 
    20  
    21 from Orange.core import ExamplesDistanceConstructor_DTW as DTWConstructor 
    22 from Orange.core import ExamplesDistanceConstructor_Euclidean as EuclideanConstructor 
    23 from Orange.core import ExamplesDistanceConstructor_Hamming as HammingConstructor 
    24 from Orange.core import ExamplesDistanceConstructor_Manhattan as ManhattanConstructor 
    25 from Orange.core import ExamplesDistanceConstructor_Maximal as MaximalConstructor 
    26 from Orange.core import ExamplesDistanceConstructor_Relief as ReliefConstructor 
     32     ExamplesDistance as Distance, \ 
     33     ExamplesDistance_Normalized as DistanceNormalized, \ 
     34     ExamplesDistanceConstructor as DistanceConstructor 
     35 
     36from Orange.core import ExamplesDistance_Hamming as HammingDistance 
     37from Orange.core import ExamplesDistance_DTW as DTWDistance 
     38from Orange.core import ExamplesDistance_Euclidean as EuclideanDistance 
     39from Orange.core import ExamplesDistance_Manhattan as ManhattanDistance 
     40from Orange.core import ExamplesDistance_Maximal as MaximalDistance 
     41from Orange.core import ExamplesDistance_Relief as ReliefDistance 
     42 
     43from Orange.core import ExamplesDistanceConstructor_DTW as DTW 
     44from Orange.core import ExamplesDistanceConstructor_Euclidean as Euclidean 
     45from Orange.core import ExamplesDistanceConstructor_Hamming as Hamming 
     46from Orange.core import ExamplesDistanceConstructor_Manhattan as Manhattan 
     47from Orange.core import ExamplesDistanceConstructor_Maximal as Maximal 
     48from Orange.core import ExamplesDistanceConstructor_Relief as Relief 
    2749 
    2850import statc 
     
    3052from numpy import linalg 
    3153 
    32 class PearsonRConstructor(ExamplesDistanceConstructor): 
    33     """Constructs an instance of PearsonR. Not all the data needs to be given.""" 
     54class PearsonR(DistanceConstructor): 
     55    """Constructs an instance of :obj:`PearsonRDistance`. Not all the data needs to be given.""" 
    3456     
    3557    def __new__(cls, data=None, **argkw): 
     
    4466        indxs = [i for i, a in enumerate(table.domain.attributes) \ 
    4567                 if a.varType==Orange.data.Type.Continuous] 
    46         return PearsonR(domain=table.domain, indxs=indxs) 
    47  
    48 class PearsonR(ExamplesDistance): 
     68        return PearsonRDistance(domain=table.domain, indxs=indxs) 
     69 
     70class PearsonRDistance(Distance): 
    4971    """ 
    5072    `Pearson correlation coefficient 
     
    7799            return 1.0 
    78100 
    79 class SpearmanRConstructor(ExamplesDistanceConstructor): 
     101class SpearmanR(DistanceConstructor): 
    80102    """Constructs an instance of SpearmanR. Not all the data needs to be given.""" 
    81103     
    82104    def __new__(cls, data=None, **argkw): 
    83         self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     105        self = DistanceConstructor.__new__(cls, **argkw) 
    84106        self.__dict__.update(argkw) 
    85107        if data: 
     
    91113        indxs = [i for i, a in enumerate(table.domain.attributes) \ 
    92114                 if a.varType==Orange.data.Type.Continuous] 
    93         return SpearmanR(domain=table.domain, indxs=indxs) 
    94  
    95 class SpearmanR(ExamplesDistance):   
     115        return SpearmanRDistance(domain=table.domain, indxs=indxs) 
     116 
     117class SpearmanRDistance(Distance):   
    96118 
    97119    """`Spearman's rank correlation coefficient 
     
    122144            return 1.0 
    123145 
    124 class MahalanobisConstructor(ExamplesDistanceConstructor): 
     146class Mahalanobis(DistanceConstructor): 
    125147    """ Construct instance of Mahalanobis. """ 
    126148     
     
    149171        inverse_covariance_matrix = linalg.pinv(covariance_matrix, rcond=1e-10) 
    150172         
    151         return Mahalanobis(domain=newdomain, icm=inverse_covariance_matrix) 
    152  
    153 class Mahalanobis(ExamplesDistance): 
     173        return MahalanobisDistance(domain=newdomain, icm=inverse_covariance_matrix) 
     174 
     175class MahalanobisDistance(Distance): 
    154176    """`Mahalanobis distance 
    155177    <http://en.wikipedia.org/wiki/Mahalanobis_distance>`_""" 
     
    178200     
    179201     
    180 class PearsonRAbsoluteConstructor(PearsonRConstructor): 
     202class PearsonRAbsolute(PearsonRConstructor): 
    181203    """ Construct an instance of PearsonRAbsolute example distance estimator. 
    182204    """ 
     
    184206        indxs = [i for i, a in enumerate(data.domain.attributes) \ 
    185207                 if a.varType==Orange.data.Type.Continuous] 
    186         return PearsonRAbsolute(domain=data.domain, indxs=indxs) 
    187      
    188      
    189 class PearsonRAbsolute(PearsonR): 
     208        return PearsonRAbsoluteDistance(domain=data.domain, indxs=indxs) 
     209     
     210     
     211class PearsonRAbsoluteDistance(PearsonR): 
    190212    """ An example distance estimator using absolute value of Pearson 
    191213    correlation coefficient. 
     
    213235         
    214236         
    215 class SpearmanRAbsoluteConstructor(SpearmanRConstructor): 
     237class SpearmanRAbsolute(SpearmanRConstructor): 
    216238    """ Construct an instance of SpearmanRAbsolute example distance estimator. 
    217239    """ 
     
    219241        indxs = [i for i, a in enumerate(data.domain.attributes) \ 
    220242                 if a.varType==Orange.data.Type.Continuous] 
    221         return SpearmanRAbsolute(domain=data.domain, indxs=indxs) 
    222      
    223      
    224 class SpearmanRAbsolute(SpearmanR): 
     243        return SpearmanRAbsoluteDistance(domain=data.domain, indxs=indxs) 
     244     
     245     
     246class SpearmanRAbsoluteDistance(SpearmanR): 
    225247    def __call__(self, e1, e2): 
    226248        """ 
Note: See TracChangeset for help on using the changeset viewer.