Changeset 9663:74b63c8ea80c in orange


Ignore:
Timestamp:
02/06/12 09:42:50 (2 years ago)
Author:
markotoplak
Branch:
default
Children:
9664:6638cc93015a, 9719:782cfec5fe88
rebase_source:
a78d1d75a2cac951721701298920fd6faa82902a
Message:

Orange.distance.instances -> Orange.distance

Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/Orange.distance.rst

    r9372 r9663  
    1 ######################### 
     1.. automodule:: Orange.distance 
     2 
     3########################################## 
    24Distance (``distance``) 
    3 ######################### 
     5########################################## 
    46 
    5 .. toctree:: 
     7This page describes a bunch of classes for different metrics for measure 
     8distances (dissimilarities) between instances. 
    69 
    7   Orange.distance.instances 
     10Typical (although not all) measures of distance between instances require 
     11some "learning" - adjusting the measure to the data. For instance, when 
     12the dataset contains continuous features, the distances between continuous 
     13values should be normalized, e.g. by dividing the distance with the range 
     14of possible values or with some interquartile distance to ensure that all 
     15features have, in principle, similar impacts. 
    816 
     17Different measures of distance thus appear in pairs - a class that measures 
     18the distance and a class that constructs it based on the data. The abstract 
     19classes representing such a pair are `ExamplesDistance` and 
     20`ExamplesDistanceConstructor`. 
     21 
     22Since most measures work on normalized distances between corresponding 
     23features, there is an abstract intermediate class 
     24`ExamplesDistance_Normalized` that takes care of normalizing. 
     25The remaining classes correspond to different ways of defining the distances, 
     26such as Manhattan or Euclidean distance. 
     27 
     28Unknown values are treated correctly only by Euclidean and Relief distance. 
     29For other measure of distance, a distance between unknown and known or between 
     30two unknown values is always 0.5. 
     31 
     32.. class:: ExamplesDistance 
     33 
     34    .. method:: __call__(instance1, instance2) 
     35 
     36        Returns a distance between the given instances as floating point number. 
     37 
     38.. class:: ExamplesDistanceConstructor 
     39 
     40    .. method:: __call__([instances, weightID][, distributions][, basic_var_stat]) 
     41 
     42        Constructs an instance of ExamplesDistance. 
     43        Not all the data needs to be given. Most measures can be constructed 
     44        from basic_var_stat; if it is not given, they can help themselves 
     45        either by instances or distributions. 
     46        Some (e.g. ExamplesDistance_Hamming) even do not need any arguments. 
     47 
     48.. class:: ExamplesDistance_Normalized 
     49 
     50    This abstract class provides a function which is given two instances 
     51    and returns a list of normalized distances between values of their 
     52    features. Many distance measuring classes need such a function and are 
     53    therefore derived from this class 
     54 
     55    .. attribute:: normalizers 
     56 
     57        A precomputed list of normalizing factors for feature values 
     58 
     59        - If a factor positive, differences in feature's values 
     60          are multiplied by it; for continuous features the factor 
     61          would be 1/(max_value-min_value) and for ordinal features 
     62          the factor is 1/number_of_values. If either (or both) of 
     63          features are unknown, the distance is 0.5 
     64        - If a factor is -1, the feature is nominal; the distance 
     65          between two values is 0 if they are same (or at least 
     66          one is unknown) and 1 if they are different. 
     67        - If a factor is 0, the feature is ignored. 
     68 
     69    .. attribute:: bases, averages, variances 
     70 
     71        The minimal values, averages and variances 
     72        (continuous features only) 
     73 
     74    .. attribute:: domainVersion 
     75 
     76        Stores a domain version for which the normalizers were computed. 
     77        The domain version is increased each time a domain description is 
     78        changed (i.e. features are added or removed); this is used for a quick 
     79        check that the user is not attempting to measure distances between 
     80        instances that do not correspond to normalizers. 
     81        Since domains are practicably immutable (especially from Python), 
     82        you don't need to care about this anyway. 
     83 
     84    .. method:: attributeDistances(instance1, instance2) 
     85 
     86        Returns a list of floats representing distances between pairs of 
     87        feature values of the two instances. 
     88 
     89 
     90.. class:: HammingConstructor 
     91.. class:: Hamming 
     92 
     93    Hamming distance between two instances is defined as the number of 
     94    features in which the two instances differ. Note that this measure 
     95    is not really appropriate for instances that contain continuous features. 
     96 
     97 
     98.. class:: MaximalConstructor 
     99.. class:: Maximal 
     100 
     101    The maximal between two instances is defined as the maximal distance 
     102    between two feature values. If dist is the result of 
     103    ExamplesDistance_Normalized.attributeDistances, 
     104    then Maximal returns max(dist). 
     105 
     106 
     107.. class:: ManhattanConstructor 
     108.. class:: Manhattan 
     109 
     110    Manhattan distance between two instances is a sum of absolute values 
     111    of distances between pairs of features, e.g. ``sum(abs(x) for x in dist)`` 
     112    where dist is the result of ExamplesDistance_Normalized.attributeDistances. 
     113 
     114.. class:: EuclideanConstructor 
     115.. class:: Euclidean 
     116 
     117    Euclidean distance is a square root of sum of squared per-feature distances, 
     118    i.e. ``sqrt(sum(x*x for x in dist))``, where dist is the result of 
     119    ExamplesDistance_Normalized.attributeDistances. 
     120 
     121    .. method:: distributions 
     122 
     123        An object of type 
     124        :obj:`~Orange.statistics.distribution.Distribution` that holds 
     125        the distributions for all discrete features used for 
     126        computation of distances between known and unknown values. 
     127 
     128    .. method:: bothSpecialDist 
     129 
     130        A list containing the distance between two unknown values for each 
     131        discrete feature. 
     132 
     133    This measure of distance deals with unknown values by computing the 
     134    expected square of distance based on the distribution obtained from the 
     135    "training" data. Squared distance between 
     136 
     137        - A known and unknown continuous attribute equals squared distance 
     138          between the known and the average, plus variance 
     139        - Two unknown continuous attributes equals double variance 
     140        - A known and unknown discrete attribute equals the probability 
     141          that the unknown attribute has different value than the known 
     142          (i.e., 1 - probability of the known value) 
     143        - Two unknown discrete attributes equals the probability that two 
     144          random chosen values are equal, which can be computed as 
     145          1 - sum of squares of probabilities. 
     146 
     147    Continuous cases can be handled by averages and variances inherited from 
     148    ExamplesDistance_normalized. The data for discrete cases are stored in 
     149    distributions (used for unknown vs. known value) and in bothSpecial 
     150    (the precomputed distance between two unknown values). 
     151 
     152.. class:: ReliefConstructor 
     153.. class:: Relief 
     154 
     155    Relief is similar to Manhattan distance, but incorporates a more 
     156    correct treatment of undefined values, which is used by ReliefF measure. 
     157 
     158This class is derived directly from ExamplesDistance, not from ExamplesDistance_Normalized. 
     159 
     160 
     161.. autoclass:: PearsonR 
     162    :members: 
     163 
     164.. autoclass:: SpearmanR 
     165    :members: 
     166 
     167.. autoclass:: PearsonRConstructor 
     168    :members: 
     169 
     170.. autoclass:: SpearmanRConstructor 
     171    :members: 
  • docs/reference/rst/code/distances-test.py

    r9638 r9663  
    55 
    66# Euclidean distance constructor 
    7 d2Constr = Orange.distance.instances.EuclideanConstructor() 
     7d2Constr = Orange.distance.EuclideanConstructor() 
    88d2 = d2Constr(iris) 
    99 
    1010# Constructs  
    11 dPears = Orange.distance.instances.PearsonRConstructor(iris) 
     11dPears = Orange.distance.PearsonRConstructor(iris) 
    1212 
    1313#reference instance 
  • docs/reference/rst/code/mds-euclid-torgerson-3d.py

    r9372 r9663  
    1111 
    1212# Construct a distance matrix using Euclidean distance 
    13 dist = Orange.distance.instances.EuclideanConstructor(table) 
     13dist = Orange.distance.EuclideanConstructor(table) 
    1414matrix = Orange.core.SymMatrix(len(table)) 
    1515matrix.setattr('items', table) 
  • docs/reference/rst/code/mds-scatterplot.py

    r9372 r9663  
    1111 
    1212# Construct a distance matrix using Euclidean distance 
    13 euclidean = Orange.distance.instances.EuclideanConstructor(table) 
     13euclidean = Orange.distance.EuclideanConstructor(table) 
    1414distance = Orange.core.SymMatrix(len(table)) 
    1515for i in range(len(table)): 
  • docs/reference/rst/code/outlier2.py

    r9372 r9663  
    33data = Orange.data.Table("bridges") 
    44outlier_det = Orange.preprocess.outliers.OutlierDetection() 
    5 outlier_det.set_examples(data, Orange.distance.instances.EuclideanConstructor(data)) 
     5outlier_det.set_examples(data, Orange.distance.EuclideanConstructor(data)) 
    66outlier_det.set_knn(3) 
    77z_values = outlier_det.z_values() 
  • docs/reference/rst/code/svm-custom-kernel.py

    r9372 r9663  
    33 
    44from Orange.classification.svm import SVMLearner, kernels 
    5 from Orange.distance.instances import EuclideanConstructor 
    6 from Orange.distance.instances import HammingConstructor 
     5from Orange.distance import EuclideanConstructor 
     6from Orange.distance import HammingConstructor 
    77 
    88table = data.Table("iris.tab") 
  • orange/Orange/__init__.py

    r9550 r9663  
    8484 
    8585_import("distance") 
    86 _import("distance.instances") 
    8786 
    8887_import("wrappers") 
  • orange/Orange/clustering/hierarchical.py

    r9237 r9663  
    321321    matrix = Orange.core.SymMatrix(len(data)) 
    322322    matrix.setattr("objects", data) 
    323     distance = Orange.distance.instances.EuclideanConstructor(data) 
     323    distance = Orange.distance.EuclideanConstructor(data) 
    324324    for i1, instance1 in enumerate(data): 
    325325        for i2 in range(i1+1, len(data)): 
     
    484484    :type data: :class:`Orange.data.Table` 
    485485    :param distance_constructor: Instance distance constructor 
    486     :type distance_constructor: :class:`Orange.distance.instances.ExamplesDistanceConstructor` 
     486    :type distance_constructor: :class:`Orange.distance.ExamplesDistanceConstructor` 
    487487    :param linkage: Linkage flag. Must be one of global module level flags: 
    488488     
     
    15201520     
    15211521    :param distance_constructor: An ExamplesDistance_Constructor instance. 
    1522     :type distance_constructor: :class:`Orange.distance.instances.ExampleDistConstructor` 
     1522    :type distance_constructor: :class:`Orange.distance.ExampleDistConstructor` 
    15231523     
    15241524    :param progress_callback: A function (taking one argument) to use for 
  • orange/Orange/distance/__init__.py

    r8059 r9663  
    1 import instances 
     1import Orange 
     2 
     3from Orange.core import \ 
     4     AlignmentList, \ 
     5     DistanceMap, \ 
     6     DistanceMapConstructor, \ 
     7     ExampleDistConstructor, \ 
     8     ExampleDistBySorting, \ 
     9     ExampleDistVector, \ 
     10     ExamplesDistance, \ 
     11     ExamplesDistance_Normalized, \ 
     12     ExamplesDistanceConstructor 
     13 
     14from Orange.core import ExamplesDistance_Hamming as Hamming 
     15from Orange.core import ExamplesDistance_DTW as DTW 
     16from Orange.core import ExamplesDistance_Euclidean as Euclidean 
     17from Orange.core import ExamplesDistance_Manhattan as Manhattan 
     18from Orange.core import ExamplesDistance_Maximal as Maximal 
     19from Orange.core import ExamplesDistance_Relief as Relief 
     20 
     21from Orange.core import ExamplesDistanceConstructor_DTW as DTWConstructor 
     22from Orange.core import ExamplesDistanceConstructor_Euclidean as EuclideanConstructor 
     23from Orange.core import ExamplesDistanceConstructor_Hamming as HammingConstructor 
     24from Orange.core import ExamplesDistanceConstructor_Manhattan as ManhattanConstructor 
     25from Orange.core import ExamplesDistanceConstructor_Maximal as MaximalConstructor 
     26from Orange.core import ExamplesDistanceConstructor_Relief as ReliefConstructor 
     27 
     28import statc 
     29import numpy 
     30from numpy import linalg 
     31 
     32class PearsonRConstructor(ExamplesDistanceConstructor): 
     33    """Constructs an instance of PearsonR. Not all the data needs to be given.""" 
     34     
     35    def __new__(cls, data=None, **argkw): 
     36        self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     37        self.__dict__.update(argkw) 
     38        if data: 
     39            return self.__call__(data) 
     40        else: 
     41            return self 
     42 
     43    def __call__(self, table): 
     44        indxs = [i for i, a in enumerate(table.domain.attributes) \ 
     45                 if a.varType==Orange.data.Type.Continuous] 
     46        return PearsonR(domain=table.domain, indxs=indxs) 
     47 
     48class PearsonR(ExamplesDistance): 
     49    """ 
     50    `Pearson correlation coefficient 
     51    <http://en.wikipedia.org/wiki/Pearson_product-moment\ 
     52    _correlation_coefficient>`_ 
     53    """ 
     54 
     55    def __init__(self, **argkw): 
     56        self.__dict__.update(argkw) 
     57         
     58    def __call__(self, e1, e2): 
     59        """ 
     60        :param e1: data instances. 
     61        :param e2: data instances. 
     62         
     63        Returns Pearson's disimilarity between e1 and e2, 
     64        i.e. (1-r)/2 where r is Sprearman's rank coefficient. 
     65        """ 
     66        X1 = [] 
     67        X2 = [] 
     68        for i in self.indxs: 
     69            if not(e1[i].isSpecial() or e2[i].isSpecial()): 
     70                X1.append(float(e1[i])) 
     71                X2.append(float(e2[i])) 
     72        if not X1: 
     73            return 1.0 
     74        try: 
     75            return (1.0 - statc.pearsonr(X1, X2)[0]) / 2. 
     76        except: 
     77            return 1.0 
     78 
     79class SpearmanRConstructor(ExamplesDistanceConstructor): 
     80    """Constructs an instance of SpearmanR. Not all the data needs to be given.""" 
     81     
     82    def __new__(cls, data=None, **argkw): 
     83        self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     84        self.__dict__.update(argkw) 
     85        if data: 
     86            return self.__call__(data) 
     87        else: 
     88            return self 
     89 
     90    def __call__(self, table): 
     91        indxs = [i for i, a in enumerate(table.domain.attributes) \ 
     92                 if a.varType==Orange.data.Type.Continuous] 
     93        return SpearmanR(domain=table.domain, indxs=indxs) 
     94 
     95class SpearmanR(ExamplesDistance):   
     96 
     97    """`Spearman's rank correlation coefficient 
     98    <http://en.wikipedia.org/wiki/Spearman%27s_rank_\ 
     99    correlation_coefficient>`_""" 
     100 
     101    def __init__(self, **argkw): 
     102        self.__dict__.update(argkw) 
     103         
     104    def __call__(self, e1, e2): 
     105        """ 
     106        :param e1: data instances. 
     107        :param e2: data instances. 
     108         
     109        Returns Sprearman's disimilarity between e1 and e2, 
     110        i.e. (1-r)/2 where r is Sprearman's rank coefficient. 
     111        """ 
     112        X1 = []; X2 = [] 
     113        for i in self.indxs: 
     114            if not(e1[i].isSpecial() or e2[i].isSpecial()): 
     115                X1.append(float(e1[i])) 
     116                X2.append(float(e2[i])) 
     117        if not X1: 
     118            return 1.0 
     119        try: 
     120            return (1.0 - statc.spearmanr(X1, X2)[0]) / 2. 
     121        except: 
     122            return 1.0 
     123 
     124class MahalanobisConstructor(ExamplesDistanceConstructor): 
     125    """ Construct instance of Mahalanobis. """ 
     126     
     127    def __new__(cls, data=None, **argkw): 
     128        self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     129        self.__dict__.update(argkw) 
     130        if data: 
     131            return self.__call__(data) 
     132        else: 
     133            return self 
     134     
     135    # Check attributtes a, b, c 
     136    def __call__(self, table, a=None, b=None, c=None, **argkw): 
     137        # Process data 
     138        dc = Orange.core.DomainContinuizer() 
     139        dc.classTreatment = Orange.core.DomainContinuizer.Ignore 
     140        dc.continuousTreatment = Orange.core.DomainContinuizer.NormalizeBySpan 
     141        dc.multinomialTreatment = Orange.core.DomainContinuizer.NValues 
     142         
     143        newdomain = dc(table) 
     144        newtable = table.translate(newdomain) 
     145         
     146        data, cls, _ = newtable.to_numpy() 
     147         
     148        covariance_matrix = numpy.cov(data, rowvar=0, bias=1) 
     149        inverse_covariance_matrix = linalg.pinv(covariance_matrix, rcond=1e-10) 
     150         
     151        return Mahalanobis(domain=newdomain, icm=inverse_covariance_matrix) 
     152 
     153class Mahalanobis(ExamplesDistance): 
     154    """`Mahalanobis distance 
     155    <http://en.wikipedia.org/wiki/Mahalanobis_distance>`_""" 
     156 
     157    def __init__(self, domain, icm, **argkw): 
     158        self.domain = domain 
     159        self.icm = icm 
     160        self.__dict__.update(argkw) 
     161         
     162    def __call__(self, e1, e2): 
     163        """ 
     164        :param e1: data instances. 
     165        :param e2: data instances. 
     166         
     167        Returns Mahalanobis distance between e1 and e2. 
     168        """ 
     169        e1 = Orange.data.Instance(self.domain, e1) 
     170        e2 = Orange.data.Instance(self.domain, e2) 
     171         
     172        diff = [] 
     173        for i in range(len(self.domain.attributes)): 
     174            diff.append(e1[i].value - e2[i].value) if not(e1[i].isSpecial() or e2[i].isSpecial()) else 0.0 
     175        diff = numpy.asmatrix(diff) 
     176        res = diff * self.icm * diff.transpose() 
     177        return res[0,0]**0.5 
     178     
     179     
     180class PearsonRAbsoluteConstructor(PearsonRConstructor): 
     181    """ Construct an instance of PearsonRAbsolute example distance estimator. 
     182    """ 
     183    def __call__(self, data): 
     184        indxs = [i for i, a in enumerate(data.domain.attributes) \ 
     185                 if a.varType==Orange.data.Type.Continuous] 
     186        return PearsonRAbsolute(domain=data.domain, indxs=indxs) 
     187     
     188     
     189class PearsonRAbsolute(PearsonR): 
     190    """ An example distance estimator using absolute value of Pearson 
     191    correlation coefficient. 
     192    """ 
     193    def __call__(self, e1, e2): 
     194        """ 
     195        Return absolute Pearson's dissimilarity between e1 and e2, 
     196        i.e. 
     197         
     198        .. math:: (1 - abs(r))/2 
     199         
     200        where r is Pearson's correlation coefficient. 
     201        """ 
     202        X1 = []; X2 = [] 
     203        for i in self.indxs: 
     204            if not(e1[i].isSpecial() or e2[i].isSpecial()): 
     205                X1.append(float(e1[i])) 
     206                X2.append(float(e2[i])) 
     207        if not X1: 
     208            return 1.0 
     209        try: 
     210            return (1.0 - abs(statc.pearsonr(X1, X2)[0])) 
     211        except: 
     212            return 1.0 
     213         
     214         
     215class SpearmanRAbsoluteConstructor(SpearmanRConstructor): 
     216    """ Construct an instance of SpearmanRAbsolute example distance estimator. 
     217    """ 
     218    def __call__(self, data): 
     219        indxs = [i for i, a in enumerate(data.domain.attributes) \ 
     220                 if a.varType==Orange.data.Type.Continuous] 
     221        return SpearmanRAbsolute(domain=data.domain, indxs=indxs) 
     222     
     223     
     224class SpearmanRAbsolute(SpearmanR): 
     225    def __call__(self, e1, e2): 
     226        """ 
     227        Return absolute Spearman's dissimilarity between e1 and e2, 
     228        i.e. 
     229          
     230        .. math:: (1 - abs(r))/2 
     231         
     232        where r is Spearman's correlation coefficient. 
     233        """ 
     234        X1 = []; X2 = [] 
     235        for i in self.indxs: 
     236            if not(e1[i].isSpecial() or e2[i].isSpecial()): 
     237                X1.append(float(e1[i])) 
     238                X2.append(float(e2[i])) 
     239        if not X1: 
     240            return 1.0 
     241        try: 
     242            return (1.0 - abs(statc.spearmanr(X1, X2)[0])) 
     243        except: 
     244            return 1.0 
     245     
     246     
     247def distance_matrix(data, distance_constructor, progress_callback=None): 
     248    """ A helper function that computes an obj:`Orange.core.SymMatrix` of all 
     249    pairwise distances between instances in `data`. 
     250     
     251    :param data: A data table 
     252    :type data: :obj:`Orange.data.Table` 
     253     
     254    :param distance_constructor: An ExamplesDistance_Constructor instance. 
     255    :type distance_constructor: :obj:`Orange.distances.ExampleDistConstructor` 
     256     
     257    """ 
     258    from Orange.misc import progressBarMilestones as progress_milestones 
     259    matrix = Orange.core.SymMatrix(len(data)) 
     260    dist = distance_constructor(data) 
     261     
     262    msize = len(data)*(len(data) - 1)/2 
     263    milestones = progress_milestones(msize, 100) 
     264    count = 0 
     265    for i in range(len(data)): 
     266        for j in range(i + 1, len(data)): 
     267            matrix[i, j] = dist(data[i], data[j]) 
     268             
     269            if progress_callback and count in milestones: 
     270                progress_callback(100.0 * count / msize) 
     271            count += 1 
     272             
     273    return matrix 
  • orange/Orange/evaluation/reliability.py

    r9525 r9663  
    529529    def __call__(self, examples, learner): 
    530530        nearest_neighbours_constructor = Orange.classification.knn.FindNearestConstructor() 
    531         nearest_neighbours_constructor.distanceConstructor = Orange.distance.instances.EuclideanConstructor() 
     531        nearest_neighbours_constructor.distanceConstructor = Orange.distance.EuclideanConstructor() 
    532532         
    533533        distance_id = Orange.data.new_meta_id() 
     
    596596    def __call__(self, examples, learner): 
    597597        nearest_neighbours_constructor = Orange.classification.knn.FindNearestConstructor() 
    598         nearest_neighbours_constructor.distanceConstructor = Orange.distance.instances.EuclideanConstructor() 
     598        nearest_neighbours_constructor.distanceConstructor = Orange.distance.EuclideanConstructor() 
    599599         
    600600        distance_id = Orange.data.new_meta_id() 
     
    642642    def __call__(self, examples, *args): 
    643643        nnm = Orange.classification.knn.FindNearestConstructor() 
    644         nnm.distanceConstructor = Orange.distance.instances.MahalanobisConstructor() 
     644        nnm.distanceConstructor = Orange.distance.MahalanobisConstructor() 
    645645         
    646646        mid = Orange.data.new_meta_id() 
     
    685685        example_avg = numpy.average(X, 0) 
    686686         
    687         distance_constructor = Orange.distance.instances.MahalanobisConstructor() 
     687        distance_constructor = Orange.distance.MahalanobisConstructor() 
    688688        distance = distance_constructor(new_examples) 
    689689         
  • orange/Orange/misc/testing.py

    r9019 r9663  
    484484         
    485485         
    486 from Orange.distance.instances import distance_matrix 
     486from Orange.distance import distance_matrix 
    487487from Orange.misc import member_set 
    488488 
  • orange/Orange/preprocess/outliers.py

    r9349 r9663  
    7373        self.examples = examples 
    7474        if (distance == None): 
    75           distance = Orange.distance.instances.ManhattanConstructor(self.examples) 
     75          distance = Orange.distance.ManhattanConstructor(self.examples) 
    7676        self.distance = distance 
    7777 
  • orange/fixes/fix_changed_names.py

    r9654 r9663  
    102102           "orange.ImputerConstructor_average": "Orange.feature.imputation.ImputerConstructor_average", 
    103103 
    104            "orange.ExamplesDistance_Normalized": "Orange.distance.instances.ExamplesDistance_Normalized", 
    105            "orange.ExamplesDistanceConstructor": "Orange.distance.instances.ExamplesDistanceConstructor", 
    106            "orange.ExamplesDistance_Hamming": "Orange.distance.instances.Hamming", 
    107            "orange.ExamplesDistance_DTW": "Orange.distance.instances.DTW", 
    108            "orange.ExamplesDistance_Euclidean": "Orange.distance.instances.Euclidean", 
    109            "orange.ExamplesDistance_Manhattan": "Orange.distance.instances.Manhattan", 
    110            "orange.ExamplesDistance_Maximal": "Orange.distance.instances.Maximal", 
    111            "orange.ExamplesDistance_Relief": "Orange.distance.instances.Relief", 
    112  
    113            "orange.ExamplesDistanceConstructor_DTW": "Orange.distance.instances.DTWConstructor", 
    114            "orange.ExamplesDistanceConstructor_Euclidean": "Orange.distance.instances.EuclideanConstructor", 
    115            "orange.ExamplesDistanceConstructor_Hamming": "Orange.distance.instances.HammingConstructor", 
    116            "orange.ExamplesDistanceConstructor_Manhattan": "Orange.distance.instances.ManhattanConstructor", 
    117            "orange.ExamplesDistanceConstructor_Maximal": "Orange.distance.instances.MaximalConstructor", 
    118            "orange.ExamplesDistanceConstructor_Relief": "Orange.distance.instances.ReliefConstructor", 
    119  
    120            "orngClustering.ExamplesDistanceConstructor_PearsonR": "Orange.distance.instances.PearsonRConstructor", 
    121            "orngClustering.ExamplesDistance_PearsonR": "Orange.distance.instances.PearsonR", 
    122            "orngClustering.ExamplesDistanceConstructor_SpearmanR": "Orange.distance.instances.SpearmanRConstructor", 
    123            "orngClustering.ExamplesDistance_SpearmanR": "Orange.distance.instances.SpearmanR", 
     104           "orange.ExamplesDistance_Normalized": "Orange.distance.ExamplesDistance_Normalized", 
     105           "orange.ExamplesDistanceConstructor": "Orange.distance.ExamplesDistanceConstructor", 
     106           "orange.ExamplesDistance_Hamming": "Orange.distance.Hamming", 
     107           "orange.ExamplesDistance_DTW": "Orange.distance.DTW", 
     108           "orange.ExamplesDistance_Euclidean": "Orange.distance.Euclidean", 
     109           "orange.ExamplesDistance_Manhattan": "Orange.distance.Manhattan", 
     110           "orange.ExamplesDistance_Maximal": "Orange.distance.Maximal", 
     111           "orange.ExamplesDistance_Relief": "Orange.distance.Relief", 
     112 
     113           "orange.ExamplesDistanceConstructor_DTW": "Orange.distance.DTWConstructor", 
     114           "orange.ExamplesDistanceConstructor_Euclidean": "Orange.distance.EuclideanConstructor", 
     115           "orange.ExamplesDistanceConstructor_Hamming": "Orange.distance.HammingConstructor", 
     116           "orange.ExamplesDistanceConstructor_Manhattan": "Orange.distance.ManhattanConstructor", 
     117           "orange.ExamplesDistanceConstructor_Maximal": "Orange.distance.MaximalConstructor", 
     118           "orange.ExamplesDistanceConstructor_Relief": "Orange.distance.ReliefConstructor", 
     119 
     120           "orngClustering.ExamplesDistanceConstructor_PearsonR": "Orange.distance.PearsonRConstructor", 
     121           "orngClustering.ExamplesDistance_PearsonR": "Orange.distance.PearsonR", 
     122           "orngClustering.ExamplesDistanceConstructor_SpearmanR": "Orange.distance.SpearmanRConstructor", 
     123           "orngClustering.ExamplesDistance_SpearmanR": "Orange.distance.SpearmanR", 
    124124 
    125125           "orngClustering.KMeans": "Orange.clustering.kmeans.Clustering", 
  • orange/orngClustering.py

    r8059 r9663  
    22# from Orange.cluster.hierarchical import *  
    33 
    4 from Orange.distance.instances import \ 
     4from Orange.distance import \ 
    55     AlignmentList, \ 
    66     DistanceMap, \ 
     
    1313     ExamplesDistanceConstructor 
    1414 
    15 from Orange.distance.instances import Hamming as ExamplesDistance_Hamming 
    16 from Orange.distance.instances import DTW as ExamplesDistance_DTW 
    17 from Orange.distance.instances import Euclidean as ExamplesDistance_Euclidean 
    18 from Orange.distance.instances import Manhattan as ExamplesDistance_Manhattan 
    19 from Orange.distance.instances import Maximal as ExamplesDistance_Maximal 
    20 from Orange.distance.instances import Relief as ExamplesDistance_Relief 
    21  
    22 from Orange.distance.instances import DTWConstructor as ExamplesDistanceConstructor_DTW 
    23 from Orange.distance.instances import EuclideanConstructor as ExamplesDistanceConstructor_Euclidean 
    24 from Orange.distance.instances import HammingConstructor as ExamplesDistanceConstructor_Hamming 
    25 from Orange.distance.instances import ManhattanConstructor as ExamplesDistanceConstructor_Manhattan 
    26 from Orange.distance.instances import MaximalConstructor as ExamplesDistanceConstructor_Maximal  
    27 from Orange.distance.instances import ReliefConstructor as ExamplesDistanceConstructor_Relief 
    28  
    29 from Orange.distance.instances import PearsonRConstructor as ExamplesDistanceConstructor_PearsonR 
    30 from Orange.distance.instances import PearsonR as ExamplesDistance_PearsonR 
    31 from Orange.distance.instances import SpearmanRConstructor as ExamplesDistanceConstructor_SpearmanR 
    32 from Orange.distance.instances import SpearmanR as ExamplesDistance_SpearmanR 
     15from Orange.distance import Hamming as ExamplesDistance_Hamming, \ 
     16    DTW as ExamplesDistance_DTW, \ 
     17    Euclidean as ExamplesDistance_Euclidean, \ 
     18    Manhattan as ExamplesDistance_Manhattan, \ 
     19    Maximal as ExamplesDistance_Maximal, \ 
     20    Relief as ExamplesDistance_Relief, \ 
     21    DTWConstructor as ExamplesDistanceConstructor_DTW, \ 
     22    EuclideanConstructor as ExamplesDistanceConstructor_Euclidean, \ 
     23    HammingConstructor as ExamplesDistanceConstructor_Hamming, \ 
     24    ManhattanConstructor as ExamplesDistanceConstructor_Manhattan, \ 
     25    MaximalConstructor as ExamplesDistanceConstructor_Maximal, \ 
     26    ReliefConstructor as ExamplesDistanceConstructor_Relief, \ 
     27    PearsonRConstructor as ExamplesDistanceConstructor_PearsonR, \ 
     28    PearsonR as ExamplesDistance_PearsonR, \ 
     29    SpearmanRConstructor as ExamplesDistanceConstructor_SpearmanR, \ 
     30    SpearmanR as ExamplesDistance_SpearmanR 
    3331 
    3432 
Note: See TracChangeset for help on using the changeset viewer.