Ignore:
Files:
1 deleted
64 edited

Legend:

Unmodified
Added
Removed
  • Orange/classification/knn.py

    r9671 r9724  
    3030 
    3131        component that constructs the object for measuring distances between 
    32         instances. Defaults to :class:`~Orange.distance.instances.EuclideanConstructor`. 
     32        instances. Defaults to :class:`~Orange.distance.Euclidean`. 
    3333 
    3434    .. attribute:: weight_id 
  • Orange/clustering/__init__.py

    r9671 r9725  
    1414import orange 
    1515import random 
    16 import statc 
     16from Orange import statc 
    1717     
    1818__docformat__ = 'restructuredtext' 
  • Orange/clustering/hierarchical.py

    r9671 r9724  
    310310The most common things to cluster are certainly examples. To show how to 
    311311this is done, we shall now load the Iris data set, initialize a distance 
    312 matrix with the distances measure by :class:`ExamplesDistance_Euclidean` 
     312matrix with the distances measure by :class:`Euclidean` 
    313313and cluster it with average linkage. Since we don't need the matrix, 
    314314we shall let the clustering overwrite it (not that it's needed for 
     
    321321    matrix = Orange.core.SymMatrix(len(data)) 
    322322    matrix.setattr("objects", data) 
    323     distance = Orange.distance.EuclideanConstructor(data) 
     323    distance = Orange.distance.Euclidean(data) 
    324324    for i1, instance1 in enumerate(data): 
    325325        for i2 in range(i1+1, len(data)): 
     
    475475 
    476476def clustering(data, 
    477                distance_constructor=orange.ExamplesDistanceConstructor_Euclidean, 
     477               distance_constructor=Orange.distance.Euclidean, 
    478478               linkage=AVERAGE, 
    479479               order=False, 
     
    484484    :type data: :class:`Orange.data.Table` 
    485485    :param distance_constructor: Instance distance constructor 
    486     :type distance_constructor: :class:`Orange.distance.ExamplesDistanceConstructor` 
     486    :type distance_constructor: :class:`Orange.distance.DistanceConstructor` 
    487487    :param linkage: Linkage flag. Must be one of global module level flags: 
    488488     
     
    15111511 
    15121512def instance_distance_matrix(data, 
    1513             distance_constructor=orange.ExamplesDistanceConstructor_Euclidean, 
     1513            distance_constructor=Orange.distance.Euclidean, 
    15141514            progress_callback=None): 
    15151515    """ A helper function that computes an :class:`Orange.core.SymMatrix` of all 
     
    15191519    :type data: :class:`Orange.data.Table` 
    15201520     
    1521     :param distance_constructor: An ExamplesDistance_Constructor instance. 
    1522     :type distance_constructor: :class:`Orange.distance.ExampleDistConstructor` 
     1521    :param distance_constructor: An DistanceConstructor instance. 
     1522    :type distance_constructor: :class:`Orange.distance.DistanceConstructor` 
    15231523     
    15241524    :param progress_callback: A function (taking one argument) to use for 
  • Orange/clustering/kmeans.py

    r9671 r9725  
    120120import orange 
    121121import random 
    122 import statc 
     122from Orange import statc 
    123123 
    124124import Orange.clustering.hierarchical 
     
    294294    :param k: the number of clusters. 
    295295    :type k: integer 
    296     :param distfun: a distance function. 
    297     :type distfun: :class:`orange.ExamplesDistance` 
    298      """ 
     296    """ 
    299297    return data.getitems(random.sample(range(len(data)), k)) 
    300298 
     
    307305    :type k: integer 
    308306    :param distfun: a distance function. 
    309     :type distfun: :class:`orange.ExamplesDistance` 
     307    :type distfun: :class:`Orange.distance.Distance` 
    310308    """ 
    311309    center = data_center(data) 
     
    338336        :type k: integer 
    339337        :param distfun: a distance function. 
    340         :type distfun: :class:`orange.ExamplesDistance` 
     338        :type distfun: :class:`Orange.distance.Distance` 
    341339        """ 
    342340        sample = orange.ExampleTable(random.sample(data, min(self.n, len(data)))) 
     
    393391    def __init__(self, data=None, centroids=3, maxiters=None, minscorechange=None, 
    394392                 stopchanges=0, nstart=1, initialization=init_random, 
    395                  distance=orange.ExamplesDistanceConstructor_Euclidean, 
     393                 distance=Orange.distance.Euclidean, 
    396394                 scoring=score_distance_to_centroids, inner_callback = None, 
    397395                 outer_callback = None): 
     
    404402        :type nstart: integer 
    405403        :param distance: an example distance constructor, which measures the distance between two instances. 
    406         :type distance: :class:`orange.ExamplesDistanceConstructor` 
     404        :type distance: :class:`Orange.distance.DistanceConstructor` 
    407405        :param initialization: a function to select centroids given data instances, k and a example distance function. This module implements different approaches (:func:`init_random`, :func:`init_diversity`, :class:`init_hclustering`).  
    408406        :param scoring: a function that takes clustering object and returns the clustering score. It could be used, for instance, in procedure that repeats the clustering nstart times, returning the clustering with the lowest score. 
  • Orange/data/variable.py

    r9671 r9727  
    1 """ 
    2 ======================== 
    3 Variables (``variable``) 
    4 ======================== 
    5  
    6 Data instances in Orange can contain several types of variables: 
    7 :ref:`discrete <discrete>`, :ref:`continuous <continuous>`, 
    8 :ref:`strings <string>`, and :ref:`Python <Python>` and types derived from it. 
    9 The latter represent arbitrary Python objects. 
    10 The names, types, values (where applicable), functions for computing the 
    11 variable value from values of other variables, and other properties of the 
    12 variables are stored in descriptor classes defined in this module. 
    13  
    14 Variable descriptors 
    15 -------------------- 
    16  
    17 Variable descriptors can be constructed either directly, using  
    18 constructors and passing attributes as parameters, or by a  
    19 factory function :func:`Orange.data.variable.make`, which either  
    20 retrieves an existing descriptor or constructs a new one. 
    21  
    22 .. class:: Variable 
    23  
    24     An abstract base class for variable descriptors. 
    25  
    26     .. attribute:: name 
    27  
    28         The name of the variable. Variable names do not need to be unique since two 
    29         variables are considered the same only if they have the same descriptor 
    30         (e.g. even multiple variables in the same table can have the same name). 
    31         This should, however, be avoided since it may result in unpredictable 
    32         behavior. 
    33      
    34     .. attribute:: var_type 
    35         
    36         Variable type; it can be Orange.data.Type.Discrete, 
    37         Orange.data.Type.Continuous, Orange.data.Type.String or 
    38         Orange.data.Type.Other.   
    39  
    40     .. attribute:: get_value_from 
    41  
    42         A function (an instance of :obj:`Orange.classification.Classifier`) which computes 
    43         a value of the variable from values of one or more other variables. This 
    44         is used, for instance, in discretization where the variables describing 
    45         the discretized variable are computed from the original variable.  
    46  
    47     .. attribute:: ordered 
    48      
    49         A flag telling whether the values of a discrete variable are ordered. At 
    50         the moment, no built-in method treats ordinal variables differently than 
    51         nominal ones. 
    52      
    53     .. attribute:: distributed 
    54      
    55         A flag telling whether the values of the variables are distributions. 
    56         As for the flag ordered, no methods treat such variables in any special 
    57         manner. 
    58      
    59     .. attribute:: random_generator 
    60      
    61         A local random number generator used by method 
    62         :obj:`Variable.random_value`. 
    63      
    64     .. attribute:: default_meta_id 
    65      
    66         A proposed (but not guaranteed) meta id to be used for that variable. 
    67         This is used, for instance, by the data loader for tab-delimited file 
    68         format instead of assigning an arbitrary new value, or by 
    69         :obj:`Orange.data.new_meta_id` if the variable is passed as an argument.  
    70          
    71     .. attribute:: attributes 
    72          
    73         A dictionary which allows the user to store additional information 
    74         about the variable. All values should be strings. See the section  
    75         about :ref:`storing additional information <attributes>`. 
    76  
    77     .. method:: __call__(obj) 
    78      
    79            Convert a string, number, or other suitable object into a variable 
    80            value. 
    81             
    82            :param obj: An object to be converted into a variable value 
    83            :type o: any suitable 
    84            :rtype: :class:`Orange.data.Value` 
    85         
    86     .. method:: randomvalue() 
    87  
    88            Return a random value for the variable. 
    89         
    90            :rtype: :class:`Orange.data.Value` 
    91         
    92     .. method:: compute_value(inst) 
    93  
    94            Compute the value of the variable given the instance by calling 
    95            obj:`~Variable.get_value_from` through a mechanism that prevents deadlocks by 
    96            circular calls. 
    97  
    98            :rtype: :class:`Orange.data.Value` 
    99  
    100 .. _discrete: 
    101 .. class:: Discrete 
    102  
    103     Bases: :class:`Variable` 
    104     
    105     Descriptor for discrete variables. 
    106      
    107     .. attribute:: values 
    108      
    109         A list with symbolic names for variables' values. Values are stored as 
    110         indices referring to this list. Therefore, modifying this list  
    111         instantly changes the (symbolic) names of values as they are printed out or 
    112         referred to by user. 
    113      
    114         .. note:: 
    115          
    116             The size of the list is also used to indicate the number of 
    117             possible values for this variable. Changing the size - especially 
    118             shrinking the list - can have disastrous effects and is therefore not 
    119             really recommended. Also, do not add values to the list by 
    120             calling its append or extend method: call the :obj:`add_value` 
    121             method instead. 
    122  
    123             It is also assumed that this attribute is always defined (but can 
    124             be empty), so never set it to None. 
    125      
    126     .. attribute:: base_value 
    127  
    128             Stores the base value for the variable as an index in `values`. 
    129             This can be, for instance, a "normal" value, such as "no 
    130             complications" as opposed to abnormal "low blood pressure". The 
    131             base value is used by certain statistics, continuization etc. 
    132             potentially, learning algorithms. The default is -1 which means that 
    133             there is no base value. 
    134      
    135     .. method:: add_value 
    136      
    137             Add a value to values. Always call this function instead of 
    138             appending to values. 
    139  
    140 .. _continuous: 
    141 .. class:: Continuous 
    142  
    143     Bases: :class:`Variable` 
    144  
    145     Descriptor for continuous variables. 
    146      
    147     .. attribute:: number_of_decimals 
    148      
    149         The number of decimals used when the value is printed out, converted to 
    150         a string or saved to a file. 
    151      
    152     .. attribute:: scientific_format 
    153      
    154         If ``True``, the value is printed in scientific format whenever it 
    155         would have more than 5 digits. In this case, :obj:`number_of_decimals` is 
    156         ignored. 
    157  
    158     .. attribute:: adjust_decimals 
    159      
    160         Tells Orange to monitor the number of decimals when the value is 
    161         converted from a string (when the values are read from a file or 
    162         converted by, e.g. ``inst[0]="3.14"``):  
    163         0: the number of decimals is not adjusted automatically; 
    164         1: the number of decimals is (and has already) been adjusted; 
    165         2: automatic adjustment is enabled, but no values have been converted yet. 
    166  
    167         By default, adjustment of the number of decimals goes as follows: 
    168      
    169         If the variable was constructed when data was read from a file, it will  
    170         be printed with the same number of decimals as the largest number of  
    171         decimals encountered in the file. If scientific notation occurs in the  
    172         file, :obj:`scientific_format` will be set to ``True`` and scientific format  
    173         will be used for values too large or too small.  
    174      
    175         If the variable is created in a script, it will have, by default, three 
    176         decimal places. This can be changed either by setting the value 
    177         from a string (e.g. ``inst[0]="3.14"``, but not ``inst[0]=3.14``) or by 
    178         manually setting the :obj:`number_of_decimals`. 
    179  
    180     .. attribute:: start_value, end_value, step_value 
    181      
    182         The range used for :obj:`randomvalue`. 
    183  
    184 .. _String: 
    185 .. class:: String 
    186  
    187     Bases: :class:`Variable` 
    188  
    189     Descriptor for variables that contain strings. No method can use them for  
    190     learning; some will complain and others will silently ignore them when they  
    191     encounter them. They can be, however, useful for meta-attributes; if  
    192     instances in a dataset have unique IDs, the most efficient way to store them  
    193     is to read them as meta-attributes. In general, never use discrete  
    194     attributes with many (say, more than 50) values. Such attributes are  
    195     probably not of any use for learning and should be stored as string 
    196     attributes. 
    197  
    198     When converting strings into values and back, empty strings are treated  
    199     differently than usual. For other types, an empty string can be used to 
    200     denote undefined values, while :obj:`String` will take empty strings 
    201     as empty strings -- except when loading or saving into file. 
    202     Empty strings in files are interpreted as undefined; to specify an empty 
    203     string, enclose the string in double quotes; these are removed when the 
    204     string is loaded. 
    205  
    206 .. _Python: 
    207 .. class:: Python 
    208  
    209     Bases: :class:`Variable` 
    210  
    211     Base class for descriptors defined in Python. It is fully functional 
    212     and can be used as a descriptor for attributes that contain arbitrary Python 
    213     values. Since this is an advanced topic, PythonVariables are described on a  
    214     separate page. !!TODO!! 
    215      
    216      
    217 Variables computed from other variables 
    218 --------------------------------------- 
    219  
    220 Values of variables are often computed from other variables, such as in 
    221 discretization. The mechanism described below usually functions behind the scenes, 
    222 so understanding it is required only for implementing specific transformations. 
    223  
    224 Monk 1 is a well-known dataset with target concept ``y := a==b or e==1``. 
    225 It can help the learning algorithm if the four-valued attribute ``e`` is 
    226 replaced with a binary attribute having values `"1"` and `"not 1"`. The 
    227 new variable will be computed from the old one on the fly.  
    228  
    229 .. literalinclude:: code/variable-get_value_from.py 
    230     :lines: 7-17 
    231      
    232 The new variable is named ``e2``; we define it with a descriptor of type  
    233 :obj:`Discrete`, with appropriate name and values ``"not 1"`` and ``1`` (we  
    234 chose this order so that the ``not 1``'s index is ``0``, which can be, if  
    235 needed, interpreted as ``False``). Finally, we tell e2 to use  
    236 ``checkE`` to compute its value when needed, by assigning ``checkE`` to  
    237 ``e2.get_value_from``.  
    238  
    239 ``checkE`` is a function that is passed an instance and another argument we  
    240 do not care about here. If the instance's ``e`` equals ``1``, the function  
    241 returns value ``1``, otherwise it returns ``not 1``. Both are returned as  
    242 values, not plain strings. 
    243  
    244 In most circumstances the value of ``e2`` can be computed on the fly - we can  
    245 pretend that the variable exists in the data, although it does not (but  
    246 can be computed from it). For instance, we can compute the information gain of 
    247 variable ``e2`` or its distribution without actually constructing data containing 
    248 the new variable. 
    249  
    250 .. literalinclude:: code/variable-get_value_from.py 
    251     :lines: 19-22 
    252  
    253 There are methods which cannot compute values on the fly because it would be 
    254 too complex or time consuming. In such cases, the data need to be converted 
    255 to a new :obj:`Orange.data.Table`:: 
    256  
    257     new_domain = Orange.data.Domain([data.domain["a"], data.domain["b"], e2, data.domain.class_var]) 
    258     new_data = Orange.data.Table(new_domain, data)  
    259  
    260 Automatic computation is useful when the data is split into training and  
    261 testing examples. Training instances can be modified by adding, removing  
    262 and transforming variables (in a typical setup, continuous variables  
    263 are discretized prior to learning, therefore the original variables are  
    264 replaced by new ones). Test instances, on the other hand, are left as they  
    265 are. When they are classified, the classifier automatically converts the  
    266 testing instances into the new domain, which includes recomputation of  
    267 transformed variables.  
    268  
    269 .. literalinclude:: code/variable-get_value_from.py 
    270     :lines: 24- 
    271  
    272 .. _attributes: 
    273  
    274 Storing additional variables 
    275 ----------------------------- 
    276  
    277 All variables have a field :obj:`~Variable.attributes`, a dictionary 
    278 which can contain strings. Although the current implementation allows all 
    279 types of value we strongly advise to use only strings. An example: 
    280  
    281 .. literalinclude:: code/attributes.py 
    282  
    283 These attributes can only be saved to a .tab file. They are listed in the 
    284 third line in <name>=<value> format, after other attribute specifications 
    285 (such as "meta" or "class"), and are separated by spaces.  
    286  
    287 .. _variable_descriptor_reuse: 
    288  
    289 Reuse of descriptors 
    290 -------------------- 
    291  
    292 There are situations when variable descriptors need to be reused. Typically, the  
    293 user loads some training examples, trains a classifier, and then loads a separate 
    294 test set. For the classifier to recognize the variables in the second data set, 
    295 the descriptors, not just the names, need to be the same.  
    296  
    297 When constructing new descriptors for data read from a file or during unpickling, 
    298 Orange checks whether an appropriate descriptor (with the same name and, in case 
    299 of discrete variables, also values) already exists and reuses it. When new 
    300 descriptors are constructed by explicitly calling the above constructors, this 
    301 always creates new descriptors and thus new variables, although a variable with 
    302 the same name may already exist. 
    303  
    304 The search for an existing variable is based on four attributes: the variable's name, 
    305 type, ordered values, and unordered values. As for the latter two, the values can  
    306 be explicitly ordered by the user, e.g. in the second line of the tab-delimited  
    307 file. For instance, sizes can be ordered as small, medium, or big. 
    308  
    309 The search for existing variables can end with one of the following statuses. 
    310  
    311 .. data:: Orange.data.variable.MakeStatus.NotFound (4) 
    312  
    313     The variable with that name and type does not exist.  
    314  
    315 .. data:: Orange.data.variable.MakeStatus.Incompatible (3) 
    316  
    317     There are variables with matching name and type, but their 
    318     values are incompatible with the prescribed ordered values. For example, 
    319     if the existing variable already has values ["a", "b"] and the new one 
    320     wants ["b", "a"], the old variable cannot be reused. The existing list can, 
    321     however be appended with the new values, so searching for ["a", "b", "c"] would 
    322     succeed. Likewise a search for ["a"] would be successful, since the extra existing value 
    323     does not matter. The formal rule is thus that the values are compatible iff ``existing_values[:len(ordered_values)] == ordered_values[:len(existing_values)]``. 
    324  
    325 .. data:: Orange.data.variable.MakeStatus.NoRecognizedValues (2) 
    326  
    327     There is a matching variable, yet it has none of the values that the new 
    328     variable will have (this is obviously possible only if the new variable has 
    329     no prescribed ordered values). For instance, we search for a variable 
    330     "sex" with values "male" and "female", while there is a variable of the same  
    331     name with values "M" and "F" (or, well, "no" and "yes" :). Reuse of this  
    332     variable is possible, though this should probably be a new variable since it  
    333     obviously comes from a different data set. If we do decide to reuse the variable, the  
    334     old variable will get some unneeded new values and the new one will inherit  
    335     some from the old. 
    336  
    337 .. data:: Orange.data.variable.MakeStatus.MissingValues (1) 
    338  
    339     There is a matching variable with some of the values that the new one  
    340     requires, but some values are missing. This situation is neither uncommon  
    341     nor suspicious: in case of separate training and testing data sets there may 
    342     be values which occur in one set but not in the other. 
    343  
    344 .. data:: Orange.data.variable.MakeStatus.OK (0) 
    345  
    346     There is a perfect match which contains all the prescribed values in the 
    347     correct order. The existing variable may have some extra values, though. 
    348  
    349 Continuous variables can obviously have only two statuses,  
    350 :obj:`~Orange.data.variable.MakeStatus.NotFound` or :obj:`~Orange.data.variable.MakeStatus.OK`. 
    351  
    352 When loading the data using :obj:`Orange.data.Table`, Orange takes the safest  
    353 approach and, by default, reuses everything that is compatible up to  
    354 and including :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`. Unintended reuse would be obvious from the 
    355 variable having too many values, which the user can notice and fix. More on that  
    356 in the page on `loading data`. !!TODO!! 
    357  
    358 There are two functions for reusing the variables instead of creating new ones. 
    359  
    360 .. function:: Orange.data.variable.make(name, type, ordered_values, unordered_values[, create_new_on]) 
    361  
    362     Find and return an existing variable or create a new one if none of the existing 
    363     variables matches the given name, type and values. 
    364      
    365     The optional `create_new_on` specifies the status at which a new variable is 
    366     created. The status must be at most :obj:`~Orange.data.variable.MakeStatus.Incompatible` since incompatible (or 
    367     non-existing) variables cannot be reused. If it is set lower, for instance  
    368     to :obj:`~Orange.data.variable.MakeStatus.MissingValues`, a new variable is created even if there exists 
    369     a variable which is only missing the same values. If set to :obj:`~Orange.data.variable.MakeStatus.OK`, the function 
    370     always creates a new variable. 
    371      
    372     The function returns a tuple containing a variable descriptor and the 
    373     status of the best matching variable. So, if ``create_new_on`` is set to 
    374     :obj:`~Orange.data.variable.MakeStatus.MissingValues`, and there exists a variable whose status is, say, 
    375     :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`, a variable would be created, while the second  
    376     element of the tuple would contain :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`. If, on the other 
    377     hand, there exists a variable which is perfectly OK, its descriptor is  
    378     returned and the returned status is :obj:`~Orange.data.variable.MakeStatus.OK`. The function returns no  
    379     indicator whether the returned variable is reused or not. This can be, 
    380     however, read from the status code: if it is smaller than the specified 
    381     ``create_new_on``, the variable is reused, otherwise a new descriptor has been constructed. 
    382  
    383     The exception to the rule is when ``create_new_on`` is OK. In this case, the  
    384     function does not search through the existing variables and cannot know the  
    385     status, so the returned status in this case is always :obj:`~Orange.data.variable.MakeStatus.OK`. 
    386  
    387     :param name: Variable name 
    388     :param type: Variable type 
    389     :type type: Orange.data.variable.Type 
    390     :param ordered_values: a list of ordered values 
    391     :param unordered_values: a list of values, for which the order does not 
    392         matter 
    393     :param create_new_on: gives the condition for constructing a new variable instead 
    394         of using the new one 
    395      
    396     :return_type: a tuple (:class:`Orange.data.variable.Variable`, int) 
    397      
    398 .. function:: Orange.data.variable.retrieve(name, type, ordered_values, onordered_values[, create_new_on]) 
    399  
    400     Find and return an existing variable, or :obj:`None` if no match is found. 
    401      
    402     :param name: variable name. 
    403     :param type: variable type. 
    404     :type type: Orange.data.variable.Type 
    405     :param ordered_values: a list of ordered values 
    406     :param unordered_values: a list of values, for which the order does not 
    407         matter 
    408     :param create_new_on: gives the condition for constructing a new variable instead 
    409         of using the new one 
    410  
    411     :return_type: :class:`Orange.data.variable.Variable` 
    412      
    413 These following examples (from :download:`variable-reuse.py <code/variable-reuse.py>`) give the shown results if 
    414 executed only once (in a Python session) and in this order. 
    415  
    416 :func:`Orange.data.variable.make` can be used for the construction of new variables. :: 
    417      
    418     >>> v1, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["a", "b"]) 
    419     >>> print s, v1.values 
    420     4 <a, b> 
    421  
    422 No surprises here: a new variable is created and the status is :obj:`~Orange.data.variable.MakeStatus.NotFound`. :: 
    423  
    424     >>> v2, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["a"], ["c"]) 
    425     >>> print s, v2 is v1, v1.values 
    426     1 True <a, b, c> 
    427  
    428 The status is 1 (:obj:`~Orange.data.variable.MakeStatus.MissingValues`), yet the variable is reused (``v2 is v1``). 
    429 ``v1`` gets a new value, ``"c"``, which was given as an unordered value. It does 
    430 not matter that the new variable does not need the value ``b``. :: 
    431  
    432     >>> v3, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["a", "b", "c", "d"]) 
    433     >>> print s, v3 is v1, v1.values 
    434     1 True <a, b, c, d> 
    435  
    436 This is like before, except that the new value, ``d`` is not among the 
    437 ordered values. :: 
    438  
    439     >>> v4, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["b"]) 
    440     >>> print s, v4 is v1, v1.values, v4.values 
    441     3, False, <b>, <a, b, c, d> 
    442  
    443 The new variable needs to have ``b`` as the first value, so it is incompatible  
    444 with the existing variables. The status is thus 3 (:obj:`~Orange.data.variable.MakeStatus.Incompatible`), the two  
    445 variables are not equal and have different lists of values. :: 
    446  
    447     >>> v5, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, None, ["c", "a"]) 
    448     >>> print s, v5 is v1, v1.values, v5.values 
    449     0 True <a, b, c, d> <a, b, c, d> 
    450  
    451 The new variable has values ``c`` and ``a``, but the order is not important,  
    452 so the existing attribute is :obj:`~Orange.data.variable.MakeStatus.OK`. :: 
    453  
    454     >>> v6, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, None, ["e"]) "a"]) 
    455     >>> print s, v6 is v1, v1.values, v6.values 
    456     2 True <a, b, c, d, e> <a, b, c, d, e> 
    457  
    458 The new variable has different values than the existing variable (status is 2, 
    459 :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`), but the existing one is nonetheless reused. Note that we 
    460 gave ``e`` in the list of unordered values. If it was among the ordered, the 
    461 reuse would fail. :: 
    462  
    463     >>> v7, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, None, 
    464             ["f"], Orange.data.variable.MakeStatus.NoRecognizedValues))) 
    465     >>> print s, v7 is v1, v1.values, v7.values 
    466     2 False <a, b, c, d, e> <f> 
    467  
    468 This is the same as before, except that we prohibited reuse when there are no 
    469 recognized values. Hence a new variable is created, though the returned status is  
    470 the same as before:: 
    471  
    472     >>> v8, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, 
    473             ["a", "b", "c", "d", "e"], None, Orange.data.variable.MakeStatus.OK) 
    474     >>> print s, v8 is v1, v1.values, v8.values 
    475     0 False <a, b, c, d, e> <a, b, c, d, e> 
    476  
    477 Finally, this is a perfect match, but any reuse is prohibited, so a new  
    478 variable is created. 
    479  
    480 """ 
    4811from orange import Variable 
    4822from orange import EnumVariable as Discrete 
  • Orange/distance/__init__.py

    r9671 r9725  
    11import Orange 
    22 
     3#%s/ExamplesDistanceConstructor/DistanceConstructor/gc 
     4#%s/ExamplesDistance_Normalized/DistanceNormalized/gc 
     5#ExampleDistance -> Distance 
     6#Hamming -> HammingDistance 
     7#DTW -> DTWDistance 
     8#Euclidean -> EuclideanDistance 
     9#Manhattan -> ... 
     10#Maximal -> ... 
     11#Relief -> .. 
     12#DTWConstructor 
     13#EuclideanConstructor 
     14#HammingConstructor 
     15#ManhattanConstructor 
     16#MaximalConstructor 
     17#ReliefConstructor 
     18#PearsonRConstructor -> PearsonR 
     19#PearsonR -> PearsonRDistance 
     20#SpearmanRConstructor -> SpearmanR 
     21#SpearmanR -> SpearmanRDistance 
     22#MahalanobisConstructor ->  Mahalanobis 
     23#Mahalanobis -> MahalanobisDistance 
     24 
    325from Orange.core import \ 
    4      AlignmentList, \ 
    5      DistanceMap, \ 
    6      DistanceMapConstructor, \ 
    7      ExampleDistConstructor, \ 
    8      ExampleDistBySorting, \ 
    9      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 
    27  
    28 import statc 
     26    DistanceMap, \ 
     27    DistanceMapConstructor, \ 
     28    ExamplesDistance as Distance, \ 
     29    ExamplesDistance_Normalized as DistanceNormalized, \ 
     30    ExamplesDistanceConstructor as DistanceConstructor, \ 
     31    ExamplesDistance_Hamming as HammingDistance, \ 
     32    ExamplesDistance_DTW as DTWDistance, \ 
     33    ExamplesDistance_Euclidean as EuclideanDistance, \ 
     34    ExamplesDistance_Manhattan as ManhattanDistance, \ 
     35    ExamplesDistance_Maximal as MaximalDistance, \ 
     36    ExamplesDistance_Relief as ReliefDistance, \ 
     37    ExamplesDistanceConstructor_DTW as DTW, \ 
     38    ExamplesDistanceConstructor_Euclidean as Euclidean, \ 
     39    ExamplesDistanceConstructor_Hamming as Hamming, \ 
     40    ExamplesDistanceConstructor_Manhattan as Manhattan, \ 
     41    ExamplesDistanceConstructor_Maximal as Maximal, \ 
     42    ExamplesDistanceConstructor_Relief as Relief 
     43 
     44from Orange import statc 
    2945import numpy 
    3046from numpy import linalg 
    3147 
    32 class PearsonRConstructor(ExamplesDistanceConstructor): 
    33     """Constructs an instance of PearsonR. Not all the data needs to be given.""" 
     48class PearsonR(DistanceConstructor): 
     49    """Constructs an instance of :obj:`PearsonRDistance`. Not all the data needs to be given.""" 
    3450     
    3551    def __new__(cls, data=None, **argkw): 
    36         self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     52        self = DistanceConstructor.__new__(cls, **argkw) 
    3753        self.__dict__.update(argkw) 
    3854        if data: 
     
    4460        indxs = [i for i, a in enumerate(table.domain.attributes) \ 
    4561                 if a.varType==Orange.data.Type.Continuous] 
    46         return PearsonR(domain=table.domain, indxs=indxs) 
    47  
    48 class PearsonR(ExamplesDistance): 
     62        return PearsonRDistance(domain=table.domain, indxs=indxs) 
     63 
     64class PearsonRDistance(Distance): 
    4965    """ 
    5066    `Pearson correlation coefficient 
     
    7793            return 1.0 
    7894 
    79 class SpearmanRConstructor(ExamplesDistanceConstructor): 
     95class SpearmanR(DistanceConstructor): 
    8096    """Constructs an instance of SpearmanR. Not all the data needs to be given.""" 
    8197     
    8298    def __new__(cls, data=None, **argkw): 
    83         self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     99        self = DistanceConstructor.__new__(cls, **argkw) 
    84100        self.__dict__.update(argkw) 
    85101        if data: 
     
    91107        indxs = [i for i, a in enumerate(table.domain.attributes) \ 
    92108                 if a.varType==Orange.data.Type.Continuous] 
    93         return SpearmanR(domain=table.domain, indxs=indxs) 
    94  
    95 class SpearmanR(ExamplesDistance):   
     109        return SpearmanRDistance(domain=table.domain, indxs=indxs) 
     110 
     111class SpearmanRDistance(Distance):   
    96112 
    97113    """`Spearman's rank correlation coefficient 
     
    122138            return 1.0 
    123139 
    124 class MahalanobisConstructor(ExamplesDistanceConstructor): 
     140class Mahalanobis(DistanceConstructor): 
    125141    """ Construct instance of Mahalanobis. """ 
    126142     
    127143    def __new__(cls, data=None, **argkw): 
    128         self = ExamplesDistanceConstructor.__new__(cls, **argkw) 
     144        self = DistanceConstructor.__new__(cls, **argkw) 
    129145        self.__dict__.update(argkw) 
    130146        if data: 
     
    149165        inverse_covariance_matrix = linalg.pinv(covariance_matrix, rcond=1e-10) 
    150166         
    151         return Mahalanobis(domain=newdomain, icm=inverse_covariance_matrix) 
    152  
    153 class Mahalanobis(ExamplesDistance): 
     167        return MahalanobisDistance(domain=newdomain, icm=inverse_covariance_matrix) 
     168 
     169class MahalanobisDistance(Distance): 
    154170    """`Mahalanobis distance 
    155171    <http://en.wikipedia.org/wiki/Mahalanobis_distance>`_""" 
     
    178194     
    179195     
    180 class PearsonRAbsoluteConstructor(PearsonRConstructor): 
     196class PearsonRAbsolute(PearsonR): 
    181197    """ Construct an instance of PearsonRAbsolute example distance estimator. 
    182198    """ 
     
    184200        indxs = [i for i, a in enumerate(data.domain.attributes) \ 
    185201                 if a.varType==Orange.data.Type.Continuous] 
    186         return PearsonRAbsolute(domain=data.domain, indxs=indxs) 
    187      
    188      
    189 class PearsonRAbsolute(PearsonR): 
     202        return PearsonRAbsoluteDistance(domain=data.domain, indxs=indxs) 
     203     
     204     
     205class PearsonRAbsoluteDistance(PearsonRDistance): 
    190206    """ An example distance estimator using absolute value of Pearson 
    191207    correlation coefficient. 
     
    213229         
    214230         
    215 class SpearmanRAbsoluteConstructor(SpearmanRConstructor): 
     231class SpearmanRAbsolute(SpearmanR): 
    216232    """ Construct an instance of SpearmanRAbsolute example distance estimator. 
    217233    """ 
     
    219235        indxs = [i for i, a in enumerate(data.domain.attributes) \ 
    220236                 if a.varType==Orange.data.Type.Continuous] 
    221         return SpearmanRAbsolute(domain=data.domain, indxs=indxs) 
    222      
    223      
    224 class SpearmanRAbsolute(SpearmanR): 
     237        return SpearmanRAbsoluteDistance(domain=data.domain, indxs=indxs) 
     238     
     239     
     240class SpearmanRAbsoluteDistance(SpearmanRDistance): 
    225241    def __call__(self, e1, e2): 
    226242        """ 
     
    252268    :type data: :obj:`Orange.data.Table` 
    253269     
    254     :param distance_constructor: An ExamplesDistance_Constructor instance. 
    255     :type distance_constructor: :obj:`Orange.distances.ExampleDistConstructor` 
     270    :param distance_constructor: An DistanceConstructor instance. 
     271    :type distance_constructor: :obj:`Orange.distances.DistanceConstructor` 
    256272     
    257273    """ 
  • Orange/ensemble/bagging.py

    r9671 r9733  
    3030            :class:`Orange.ensemble.bagging.BaggedLearner` 
    3131    """ 
    32     def __new__(cls, learner, instances=None, weightId=None, **kwargs): 
     32    def __new__(cls, learner, instances=None, weight_id=None, **kwargs): 
    3333        self = orange.Learner.__new__(cls, **kwargs) 
    3434        if instances is not None: 
    3535            self.__init__(self, learner, **kwargs) 
    36             return self.__call__(instances, weightId) 
     36            return self.__call__(instances, weight_id) 
    3737        else: 
    3838            return self 
     
    6767            classifiers.append(self.learner(data, weight)) 
    6868        return BaggedClassifier(classifiers = classifiers, name=self.name,\ 
    69                     classVar=instances.domain.classVar) 
     69                    class_var=instances.domain.class_var) 
     70BaggedLearner = Orange.misc.deprecated_members({"weightId":"weight_id", "examples":"instances"})(BaggedLearner) 
    7071 
    7172class BaggedClassifier(orange.Classifier): 
     
    8485    :type name: str 
    8586     
    86     :param classVar: the class feature. 
    87     :type classVar: :class:`Orange.data.variable.Variable` 
     87    :param class_var: the class feature. 
     88    :type class_var: :class:`Orange.data.variable.Variable` 
    8889 
    8990    """ 
    9091 
    91     def __init__(self, classifiers, name, classVar, **kwds): 
     92    def __init__(self, classifiers, name, class_var, **kwds): 
    9293        self.classifiers = classifiers 
    9394        self.name = name 
    94         self.classVar = classVar 
     95        self.class_var = class_var 
    9596        self.__dict__.update(kwds) 
    9697 
    97     def __call__(self, instance, resultType = orange.GetValue): 
     98    def __call__(self, instance, result_type = orange.GetValue): 
    9899        """ 
    99100        :param instance: instance to be classified. 
     
    107108              :class:`Orange.statistics.Distribution` or a tuple with both 
    108109        """ 
    109         if self.classVar.varType == Orange.data.Type.Discrete: 
    110             freq = [0.] * len(self.classVar.values) 
     110        if self.class_var.var_type == Orange.data.Type.Discrete: 
     111            freq = [0.] * len(self.class_var.values) 
    111112            for c in self.classifiers: 
    112113                freq[int(c(instance))] += 1 
    113114            index = freq.index(max(freq)) 
    114             value = Orange.data.Value(self.classVar, index) 
    115             if resultType == orange.GetValue: 
     115            value = Orange.data.Value(self.class_var, index) 
     116            if result_type == orange.GetValue: 
    116117                return value 
    117118            for i in range(len(freq)): 
    118119                freq[i] = freq[i]/len(self.classifiers) 
    119120            freq = Orange.statistics.distribution.Discrete(freq) 
    120             if resultType == orange.GetProbabilities: 
     121            if result_type == orange.GetProbabilities: 
    121122                return freq 
    122             elif resultType == orange.GetBoth: 
     123            elif result_type == orange.GetBoth: 
    123124                return (value, freq) 
    124125            else: 
    125126                return value 
    126127             
    127         elif self.classVar.varType ==Orange.data.Type.Continuous: 
    128             votes = [c(instance, orange.GetBoth if resultType==\ 
    129                 orange.GetProbabilities else resultType) \ 
     128        elif self.class_var.var_type ==Orange.data.Type.Continuous: 
     129            votes = [c(instance, orange.GetBoth if result_type==\ 
     130                orange.GetProbabilities else result_type) \ 
    130131                for c in self.classifiers] 
    131132            wsum = float(len(self.classifiers)) 
    132             if resultType in [orange.GetBoth, orange.GetProbabilities]: 
     133            if result_type in [orange.GetBoth, orange.GetProbabilities]: 
    133134                pred = sum([float(c) for c, p in votes]) / wsum 
    134135#               prob = sum([float(p.modus()) for c, p in votes]) / wsum 
     
    140141                     
    141142                prob = Orange.statistics.distribution.Continuous(prob) 
    142                 return (self.classVar(pred), prob) if resultType == orange.GetBoth\ 
     143                return (self.class_var(pred), prob) if result_type == orange.GetBoth\ 
    143144                    else prob 
    144             elif resultType == orange.GetValue: 
     145            elif result_type == orange.GetValue: 
    145146                pred = sum([float(c) for c in votes]) / wsum 
    146                 return self.classVar(pred) 
     147                return self.class_var(pred) 
    147148             
    148149    def __reduce__(self): 
    149         return type(self), (self.classifiers, self.name, self.classVar), dict(self.__dict__) 
    150      
     150        return type(self), (self.classifiers, self.name, self.class_var), dict(self.__dict__) 
     151BaggedClassifier = Orange.misc.deprecated_members({"example":"instance", "classVar":"class_var","resultType":"result_type"})(BaggedClassifier) 
  • Orange/ensemble/boosting.py

    r9671 r9733  
    2727            :class:`Orange.ensemble.boosting.BoostedLearner` 
    2828    """ 
    29     def __new__(cls, learner, instances=None, weightId=None, **kwargs): 
     29    def __new__(cls, learner, instances=None, weight_id=None, **kwargs): 
    3030        self = orange.Learner.__new__(cls, **kwargs) 
    3131        if instances is not None: 
    3232            self.__init__(self, learner, **kwargs) 
    33             return self.__call__(instances, weightId) 
     33            return self.__call__(instances, weight_id) 
    3434        else: 
    3535            return self 
     
    4040        self.learner = learner 
    4141 
    42     def __call__(self, instances, origWeight = 0): 
     42    def __call__(self, instances, orig_weight = 0): 
    4343        """ 
    4444        Learn from the given table of data instances. 
     
    4646        :param instances: data instances to learn from. 
    4747        :type instances: Orange.data.Table 
    48         :param origWeight: weight. 
    49         :type origWeight: int 
     48        :param orig_weight: weight. 
     49        :type orig_weight: int 
    5050        :rtype: :class:`Orange.ensemble.boosting.BoostedClassifier` 
    5151         
     
    5353        import math 
    5454        weight = Orange.data.new_meta_id() 
    55         if origWeight: 
     55        if orig_weight: 
    5656            for i in instances: 
    57                 i.setweight(weight, i.getweight(origWeight)) 
     57                i.setweight(weight, i.getweight(orig_weight)) 
    5858        else: 
    5959            instances.addMetaAttribute(weight, 1.0) 
     
    8080                instances.removeMetaAttribute(weight) 
    8181                return BoostedClassifier(classifiers = classifiers,  
    82                     name=self.name, classVar=instances.domain.classVar) 
     82                    name=self.name, class_var=instances.domain.class_var) 
    8383            beta = epsilon/(1-epsilon) 
    8484            for e in range(n): 
     
    9191        instances.removeMetaAttribute(weight) 
    9292        return BoostedClassifier(classifiers = classifiers, name=self.name,  
    93             classVar=instances.domain.classVar) 
     93            class_var=instances.domain.class_var) 
     94BoostedLearner = Orange.misc.deprecated_members({"examples":"instances", "classVar":"class_var", "weightId":"weigth_id", "origWeight":"orig_weight"})(BoostedLearner) 
    9495 
    9596class BoostedClassifier(orange.Classifier): 
     
    108109    :type name: str 
    109110     
    110     :param classVar: the class feature. 
    111     :type classVar: :class:`Orange.data.variable.Variable` 
     111    :param class_var: the class feature. 
     112    :type class_var: :class:`Orange.data.variable.Variable` 
    112113     
    113114    """ 
    114115 
    115     def __init__(self, classifiers, name, classVar, **kwds): 
     116    def __init__(self, classifiers, name, class_var, **kwds): 
    116117        self.classifiers = classifiers 
    117118        self.name = name 
    118         self.classVar = classVar 
     119        self.class_var = class_var 
    119120        self.__dict__.update(kwds) 
    120121 
    121     def __call__(self, instance, resultType = orange.GetValue): 
     122    def __call__(self, instance, result_type = orange.GetValue): 
    122123        """ 
    123124        :param instance: instance to be classified. 
     
    131132              :class:`Orange.statistics.Distribution` or a tuple with both 
    132133        """ 
    133         votes = Orange.statistics.distribution.Discrete(self.classVar) 
     134        votes = Orange.statistics.distribution.Discrete(self.class_var) 
    134135        for c, e in self.classifiers: 
    135136            votes[int(c(instance))] += e 
    136         index = Orange.misc.selection.selectBestIndex(votes) 
     137        index = Orange.misc.selection.select_best_index(votes) 
    137138        # TODO 
    138         value = Orange.data.Value(self.classVar, index) 
    139         if resultType == orange.GetValue: 
     139        value = Orange.data.Value(self.class_var, index) 
     140        if result_type == orange.GetValue: 
    140141            return value 
    141142        sv = sum(votes) 
    142143        for i in range(len(votes)): 
    143144            votes[i] = votes[i]/sv 
    144         if resultType == orange.GetProbabilities: 
     145        if result_type == orange.GetProbabilities: 
    145146            return votes 
    146         elif resultType == orange.GetBoth: 
     147        elif result_type == orange.GetBoth: 
    147148            return (value, votes) 
    148149        else: 
     
    150151         
    151152    def __reduce__(self): 
    152         return type(self), (self.classifiers, self.name, self.classVar), dict(self.__dict__) 
    153      
     153        return type(self), (self.classifiers, self.name, self.class_var), dict(self.__dict__) 
     154 
     155BoostedClassifier = Orange.misc.deprecated_members({"classVar":"class_var", "resultType":"result_type"})(BoostedClassifier) 
  • Orange/ensemble/forest.py

    r9697 r9733  
    55import random 
    66import copy 
     7from Orange.misc import deprecated_keywords 
    78 
    89def _default_small_learner(attributes=None, rand=None, base=None): 
     
    2930  
    3031class _RandomForestSimpleTreeLearner(Orange.core.Learner): 
    31     """ A learner which wraps an ordinary SimpleTreeLearner.  Sets the 
     32    """A learner which wraps an ordinary SimpleTreeLearner.  Sets the 
    3233    skip_prob so that the number of randomly chosen features for each 
    33     split is  (on average) as specified.  """ 
    34  
    35     def __new__(cls, examples = None, weightID = 0, **argkw): 
     34    split is  (on average) as specified.""" 
     35 
     36    def __new__(cls, instances = None, weight_id = 0, **argkw): 
    3637        self = Orange.core.Learner.__new__(cls, **argkw) 
    37         if examples: 
     38        if instances: 
    3839            self.__init__(**argkw) 
    39             return self.__call__(examples, weightID) 
     40            return self.__call__(instances, weight_id) 
    4041        else: 
    4142            return self 
     
    4647        self.rand = rand 
    4748     
    48     def __call__(self, examples, weight=0): 
     49    def __call__(self, instances, weight=0): 
    4950        osp,orand = self.base.skip_prob, self.base.random_generator 
    50         self.base.skip_prob = 1-float(self.attributes)/len(examples.domain.attributes) 
     51        self.base.skip_prob = 1-float(self.attributes)/len(instances.domain.attributes) 
    5152        self.base.random_generator = self.rand 
    52         r = self.base(examples, weight) 
     53        r = self.base(instances, weight) 
    5354        self.base.skip_prob, self.base.random_generator = osp, orand 
    5455        return r 
     56_RandomForestSimpleTreeLearner = Orange.misc.deprecated_members({"weightID":"weight_id", "examples":"instances"})(_RandomForestSimpleTreeLearner) 
    5557    
    5658class RandomForestLearner(orange.Learner): 
     
    170172        return RandomForestClassifier(classifiers = classifiers, name=self.name,\ 
    171173                    domain=instances.domain, class_var=instances.domain.class_var) 
    172   
     174RandomForestLearner = Orange.misc.deprecated_members({"examples":"instances"})(RandomForestLearner) 
    173175 
    174176class RandomForestClassifier(orange.Classifier): 
     
    202204        self.__dict__.update(kwds) 
    203205 
    204     def __call__(self, instance, resultType = orange.GetValue): 
     206    def __call__(self, instance, result_type = orange.GetValue): 
    205207        """ 
    206208        :param instance: instance to be classified. 
     
    221223         
    222224            # voting for class probabilities 
    223             if resultType == orange.GetProbabilities or resultType == orange.GetBoth: 
     225            if result_type == orange.GetProbabilities or result_type == orange.GetBoth: 
    224226                prob = [0.] * len(self.domain.class_var.values) 
    225227                for c in self.classifiers: 
     
    234236            # this may not be the same class as one obtaining the 
    235237            # highest probability through probability voting 
    236             if resultType == orange.GetValue or resultType == orange.GetBoth: 
     238            if result_type == orange.GetValue or result_type == orange.GetBoth: 
    237239                cfreq = [0] * len(self.domain.class_var.values) 
    238240                for c in self.classifiers: 
     
    241243                cvalue = Orange.data.Value(self.domain.class_var, index) 
    242244     
    243             if resultType == orange.GetValue: return cvalue 
    244             elif resultType == orange.GetProbabilities: return cprob 
     245            if result_type == orange.GetValue: return cvalue 
     246            elif result_type == orange.GetProbabilities: return cprob 
    245247            else: return (cvalue, cprob) 
    246248         
     
    249251         
    250252            # voting for class probabilities 
    251             if resultType == orange.GetProbabilities or resultType == orange.GetBoth: 
     253            if result_type == orange.GetProbabilities or result_type == orange.GetBoth: 
    252254                probs = [c(instance, orange.GetBoth) for c in self.classifiers] 
    253255                cprob = dict() 
     
    262264                 
    263265            # gather average class value 
    264             if resultType == orange.GetValue or resultType == orange.GetBoth: 
     266            if result_type == orange.GetValue or result_type == orange.GetBoth: 
    265267                values = [c(instance).value for c in self.classifiers] 
    266268                cvalue = Orange.data.Value(self.domain.class_var, sum(values) / len(self.classifiers)) 
    267269             
    268             if resultType == orange.GetValue: return cvalue 
    269             elif resultType == orange.GetProbabilities: return cprob 
     270            if result_type == orange.GetValue: return cvalue 
     271            elif result_type == orange.GetProbabilities: return cprob 
    270272            else: return (cvalue, cprob) 
    271273             
    272274    def __reduce__(self): 
    273275        return type(self), (self.classifiers, self.name, self.domain, self.class_var), dict(self.__dict__) 
    274  
     276RandomForestClassifier = Orange.misc.deprecated_members({"resultType":"result_type", "classVar":"class_var", "example":"instance"})(RandomForestClassifier) 
    275277### MeasureAttribute_randomForests 
    276278 
     
    326328        else: 
    327329            self.learner = learner 
    328    
    329     def __call__(self, feature, instances, apriorClass=None): 
     330 
     331    @deprecated_keywords({"apriorClass":"aprior_class"}) 
     332    def __call__(self, feature, instances, aprior_class=None): 
    330333        """ 
    331334        Return importance of a given feature. 
     
    339342        :type instances: :class:`Orange.data.Table` 
    340343         
    341         :param apriorClass: not used! 
     344        :param aprior_class: not used! 
    342345         
    343346        """ 
     
    354357        else: 
    355358          raise Exception("MeasureAttribute_rf can not be called with (\ 
    356                 contingency,classDistribution, apriorClass) as fuction arguments.") 
     359                contingency,classDistribution, aprior_class) as fuction arguments.") 
    357360 
    358361        self._buffer(instances) 
     
    482485    a new split constructor. 
    483486    """ 
    484  
    485     def __new__(cls, examples = None, weightID = 0, **argkw): 
     487    @deprecated_keywords({"weightID":"weight_id", "examples":"instances"}) 
     488    def __new__(cls, instances = None, weight_id = 0, **argkw): 
    486489        self = Orange.core.Learner.__new__(cls, **argkw) 
    487         if examples: 
     490        if instances: 
    488491            self.__init__(**argkw) 
    489             return self.__call__(examples, weightID) 
     492            return self.__call__(instances, weight_id) 
    490493        else: 
    491494            return self 
     
    497500        if not self.rand: #for all the built trees 
    498501            self.rand = random.Random(0) 
    499      
    500     def __call__(self, examples, weight=0): 
     502 
     503    @deprecated_keywords({"examples":"instances"}) 
     504    def __call__(self, instances, weight=0): 
    501505        """ A current tree learner is copied, modified and then used. 
    502506        Modification: set a different split constructor, which uses 
     
    508512        if not bcopy.measure: 
    509513            bcopy.measure = Orange.feature.scoring.Gini() \ 
    510                 if isinstance(examples.domain.class_var, Orange.data.variable.Discrete) \ 
     514                if isinstance(instances.domain.class_var, Orange.data.variable.Discrete) \ 
    511515                else Orange.feature.scoring.MSE() 
    512516 
     
    514518            bcopy.split, self.attributes, self.rand) 
    515519 
    516         return bcopy(examples, weight=weight) 
     520        return bcopy(instances, weight=weight) 
    517521 
    518522class SplitConstructor_AttributeSubset(orange.TreeSplitConstructor): 
     
    524528            self.rand = random.Random(0) 
    525529 
    526     def __call__(self, gen, weightID, contingencies, apriori, candidates, clsfr): 
     530    @deprecated_keywords({"weightID":"weight_id"}) 
     531    def __call__(self, gen, weight_id, contingencies, apriori, candidates, clsfr): 
    527532        # if number of features for subset is not set, use square root 
    528533        cand = [1]*int(self.attributes) + [0]*(len(candidates) - int(self.attributes)) 
     
    530535        # instead with all features, we will invoke split constructor  
    531536        # only for the subset of a features 
    532         t = self.scons(gen, weightID, contingencies, apriori, cand, clsfr) 
     537        t = self.scons(gen, weight_id, contingencies, apriori, cand, clsfr) 
    533538        return t 
  • Orange/evaluation/reliability.py

    r9697 r9725  
    22 
    33import random 
    4 import statc 
     4from Orange import statc 
    55import math 
    66import warnings 
     
    400400    def __call__(self, instances, learner): 
    401401        nearest_neighbours_constructor = Orange.classification.knn.FindNearestConstructor() 
    402         nearest_neighbours_constructor.distanceConstructor = Orange.distance.EuclideanConstructor() 
     402        nearest_neighbours_constructor.distanceConstructor = Orange.distance.Euclidean() 
    403403         
    404404        distance_id = Orange.data.new_meta_id() 
     
    467467    def __call__(self, instances, learner): 
    468468        nearest_neighbours_constructor = Orange.classification.knn.FindNearestConstructor() 
    469         nearest_neighbours_constructor.distanceConstructor = Orange.distance.EuclideanConstructor() 
     469        nearest_neighbours_constructor.distanceConstructor = Orange.distance.Euclidean() 
    470470         
    471471        distance_id = Orange.data.new_meta_id() 
     
    514514    def __call__(self, instances, *args): 
    515515        nnm = Orange.classification.knn.FindNearestConstructor() 
    516         nnm.distanceConstructor = Orange.distance.MahalanobisConstructor() 
     516        nnm.distanceConstructor = Orange.distance.Mahalanobis() 
    517517         
    518518        mid = Orange.data.new_meta_id() 
     
    558558        instance_avg = numpy.average(X, 0) 
    559559         
    560         distance_constructor = Orange.distance.MahalanobisConstructor() 
     560        distance_constructor = Orange.distance.Mahalanobis() 
    561561        distance = distance_constructor(new_instances) 
    562562         
  • Orange/evaluation/scoring.py

    r9671 r9725  
    449449""" 
    450450 
    451 import statc, operator, math 
     451import operator, math 
    452452from operator import add 
    453453import numpy 
    454454 
    455455import Orange 
     456from Orange import statc 
    456457 
    457458 
  • Orange/fixes/fix_changed_names.py

    r9697 r9722  
    102102           "orange.ImputerConstructor_average": "Orange.feature.imputation.ImputerConstructor_average", 
    103103 
    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", 
     104           "orange.ExampleDistance": "Orange.distance.Distance", 
     105           "orange.ExamplesDistance_Normalized": "Orange.distance.DistanceNormalized", 
     106           "orange.ExamplesDistanceConstructor": "Orange.distance.DistanceConstructor", 
     107           "orange.ExamplesDistance_Hamming": "Orange.distance.HammingDistance", 
     108           "orange.ExamplesDistance_DTW": "Orange.distance.DTWDistance", 
     109           "orange.ExamplesDistance_Euclidean": "Orange.distance.EuclideanDistance", 
     110           "orange.ExamplesDistance_Manhattan": "Orange.distance.ManhattanDistance", 
     111           "orange.ExamplesDistance_Maximal": "Orange.distance.MaximalDistance", 
     112           "orange.ExamplesDistance_Relief": "Orange.distance.ReliefDistance", 
     113 
     114           "orange.ExamplesDistanceConstructor_DTW": "Orange.distance.DTW", 
     115           "orange.ExamplesDistanceConstructor_Euclidean": "Orange.distance.Euclidean", 
     116           "orange.ExamplesDistanceConstructor_Hamming": "Orange.distance.Hamming", 
     117           "orange.ExamplesDistanceConstructor_Manhattan": "Orange.distance.Manhattan", 
     118           "orange.ExamplesDistanceConstructor_Maximal": "Orange.distance.Maximal", 
     119           "orange.ExamplesDistanceConstructor_Relief": "Orange.distance.Relief", 
     120 
     121           "orngClustering.ExamplesDistanceConstructor_PearsonR": "Orange.distance.PearsonR", 
     122           "orngClustering.ExamplesDistance_PearsonR": "Orange.distance.PearsonRDistance", 
     123           "orngClustering.ExamplesDistanceConstructor_SpearmanR": "Orange.distance.SpearmanR", 
     124           "orngClustering.ExamplesDistance_SpearmanR": "Orange.distance.SpearmanRDistance", 
    124125 
    125126           "orngClustering.KMeans": "Orange.clustering.kmeans.Clustering", 
  • Orange/misc/environ.py

    r9691 r9725  
    277277def add_orange_directories_to_path(): 
    278278    """Add orange directory paths to sys.path.""" 
     279 
     280    return 
    279281    paths_to_add = [install_dir] 
    280282 
  • Orange/misc/selection.py

    r9671 r9732  
    103103     
    104104    def __init__(self, compare=cmp, seed = 0, call_compare_on_1st = False): 
    105         self.randomGenerator = random.Random(seed) 
     105        self.randomGenerator = random.RandomGenerator(seed) 
    106106        self.compare=compare 
    107107        self.wins=0 
     
    134134            elif cmpr==0: 
    135135                self.wins=self.wins+1 
    136                 if not self.randomGenerator.randint(0, self.wins-1): 
     136                if not self.randomGenerator(self.wins): 
    137137                    self.best=x 
    138138                    self.bestIndex=self.index 
  • Orange/misc/visfuncts.py

    r9706 r9725  
    1 import orange, statc, random 
     1import orange, random 
    22from Orange.feature import scoring 
    33from Orange.misc import progress_bar_milestones 
     4from Orange import statc 
    45import copy 
    56from math import ceil 
  • Orange/multilabel/multiknn.py

    r9671 r9724  
    6868    def _build_knn(self, instances): 
    6969        nnc = Orange.classification.knn.FindNearestConstructor() 
    70         nnc.distanceConstructor = Orange.core.ExamplesDistanceConstructor_Euclidean() 
     70        nnc.distanceConstructor = Orange.distance.Euclidean() 
    7171         
    7272        weight_id = Orange.data.new_meta_id() 
  • Orange/orng/orngClustering.py

    r9671 r9723  
    22# from Orange.cluster.hierarchical import *  
    33 
    4 from Orange.distance import \ 
    5      AlignmentList, \ 
     4from Orange.core import \ 
    65     DistanceMap, \ 
    76     DistanceMapConstructor, \ 
    8      ExampleDistConstructor, \ 
    9      ExampleDistBySorting, \ 
    10      ExampleDistVector, \ 
    117     ExamplesDistance, \ 
    128     ExamplesDistance_Normalized, \ 
    139     ExamplesDistanceConstructor 
    1410 
    15 from 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 
    31  
     11from Orange.distance import HammingDistance as ExamplesDistance_Hamming, \ 
     12    DTWDistance as ExamplesDistance_DTW, \ 
     13    EuclideanDistance as ExamplesDistance_Euclidean, \ 
     14    ManhattanDistance as ExamplesDistance_Manhattan, \ 
     15    MaximalDistance as ExamplesDistance_Maximal, \ 
     16    ReliefDistance as ExamplesDistance_Relief, \ 
     17    DTW as ExamplesDistanceConstructor_DTW, \ 
     18    Euclidean as ExamplesDistanceConstructor_Euclidean, \ 
     19    Hamming as ExamplesDistanceConstructor_Hamming, \ 
     20    Manhattan as ExamplesDistanceConstructor_Manhattan, \ 
     21    Maximal as ExamplesDistanceConstructor_Maximal, \ 
     22    Relief as ExamplesDistanceConstructor_Relief, \ 
     23    PearsonR as ExamplesDistanceConstructor_PearsonR, \ 
     24    PearsonRDistance as ExamplesDistance_PearsonR, \ 
     25    SpearmanR as ExamplesDistanceConstructor_SpearmanR, \ 
     26    SpearmanRDistance as ExamplesDistance_SpearmanR 
    3227 
    3328from Orange.clustering.kmeans import Clustering as KMeans 
  • Orange/preprocess/outliers.py

    r9671 r9725  
    3636 
    3737import Orange 
    38 import statc 
     38from Orange import statc 
    3939 
    4040class OutlierDetection: 
  • Orange/projection/linear.py

    r9707 r9725  
    6464 
    6565import Orange 
    66 import orangeom 
     66from Orange import orangeom 
    6767import math 
    6868import random 
  • Orange/projection/mds.py

    r9671 r9725  
    102102 
    103103import Orange.core 
    104 import orangeom as orangemds 
     104from Orange import orangeom as orangemds 
    105105from Orange.misc import deprecated_keywords 
    106106from Orange.misc import deprecated_members 
  • Orange/regression/linear.py

    r9671 r9725  
    5757    from scipy import stats 
    5858except ImportError: 
    59     import statc as stats 
     59    import Orange.statc as stats 
    6060 
    6161from numpy import dot, sqrt 
  • Orange/testing/regression/results_modules/classification-rules2.py.txt

    r9689 r9711  
    77IF status=['crew'] AND sex=['female'] THEN survived=yes<3.000, 20.000> 
    88IF status=['second'] THEN survived=yes<13.000, 80.000> 
    9 IF status=['third'] AND sex=['male'] AND age=['adult'] THEN survived=no<387.000, 75.000> 
     9IF sex=['male'] AND status=['third'] AND age=['adult'] THEN survived=no<387.000, 75.000> 
    1010IF status=['crew'] THEN survived=no<670.000, 192.000> 
    1111IF age=['child'] AND sex=['male'] THEN survived=no<35.000, 13.000> 
  • Orange/testing/regression/results_modules/classification_rules1.py.txt

    r9689 r9711  
    77IF status=['crew'] AND sex=['female'] THEN survived=yes<3.000, 20.000> 
    88IF status=['second'] THEN survived=yes<13.000, 80.000> 
    9 IF status=['third'] AND sex=['male'] AND age=['adult'] THEN survived=no<387.000, 75.000> 
     9IF sex=['male'] AND status=['third'] AND age=['adult'] THEN survived=no<387.000, 75.000> 
    1010IF status=['crew'] THEN survived=no<670.000, 192.000> 
    1111IF age=['child'] AND sex=['male'] THEN survived=no<35.000, 13.000> 
     
    1919IF status=['crew'] AND sex=['male'] THEN survived=no<670.000, 192.000> 
    2020IF status=['second'] THEN survived=yes<13.000, 104.000> 
    21 IF sex=['male'] THEN survived=no<153.000, 75.000> 
     21IF status=['third'] AND sex=['male'] THEN survived=no<35.000, 13.000> 
     22IF status=['first'] AND age=['adult'] THEN survived=no<118.000, 57.000> 
    2223IF status=['crew'] THEN survived=yes<3.000, 20.000> 
    23 IF age=['child'] THEN survived=no<17.000, 14.000> 
    24 IF TRUE THEN survived=no<89.000, 76.000> 
     24IF sex=['female'] THEN survived=no<106.000, 90.000> 
     25IF TRUE THEN survived=yes<0.000, 5.000> 
    2526**** 
    2627IF status=['second'] AND sex=['male'] AND age=['adult'] THEN survived=no<154.000, 14.000> 
  • Orange/testing/regression/results_modules/ensemble2.py.txt

    r9689 r9712  
    11Learner  CA     Brier  AUC 
    2 tree     0.594  0.812  0.584 
    3 forest   0.716  0.403  0.753 
     2tree     0.588  0.823  0.578 
     3forest   0.704  0.406  0.751 
  • Orange/testing/regression/results_modules/ensemble4.py.txt

    r9689 r9713  
    22 
    33different random seed 
    4 first: 2.32, second: 0.76 
     4first: 2.61, second: 0.72 
    55 
    66All importances: 
    7    sepal length:   2.32 
    8     sepal width:   0.76 
    9    petal length:  32.67 
    10     petal width:  23.30 
     7   sepal length:   2.61 
     8    sepal width:   0.72 
     9   petal length:  32.66 
     10    petal width:  23.73 
  • Orange/testing/regression/results_modules/fss7.py.txt

    r9689 r9714  
    11 
    22Learner         Accuracy  #Atts 
    3 disc bayes      0.854     14.40 
    4 bayes & fss     0.854      4.00 
     3disc bayes      0.858     15.00 
     4bayes & fss     0.854      4.10 
    55 
    66Attribute usage (in how many folds attribute was used?): 
     710 x A10 
     8 2 x A12 
     9 1 x A5 
     10 1 x A4 
     11 8 x A7 
     12 9 x A6 
    71310 x A9 
    8 10 x A6 
    9  9 x A10 
    10 10 x A7 
    11  1 x A12 
  • Orange/testing/regression/results_modules/hclust-colored-dendrogram.py.txt

    r9689 r9715  
    11[[5.1, 3.5, 1.4, 0.2, 'Iris-setosa'], [4.9, 3.0, 1.4, 0.2, 'Iris-setosa'], [4.7, 3.2, 1.3, 0.2, 'Iris-setosa'], [4.6, 3.1, 1.5, 0.2, 'Iris-setosa'], [5.0, 3.6, 1.4, 0.2, 'Iris-setosa'], [5.4, 3.9, 1.7, 0.4, 'Iris-setosa'], [4.6, 3.4, 1.4, 0.3, 'Iris-setosa'], [5.0, 3.4, 1.5, 0.2, 'Iris-setosa'], [4.4, 2.9, 1.4, 0.2, 'Iris-setosa'], [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'], [5.4, 3.7, 1.5, 0.2, 'Iris-setosa'], [4.8, 3.4, 1.6, 0.2, 'Iris-setosa'], [4.8, 3.0, 1.4, 0.1, 'Iris-setosa'], [4.3, 3.0, 1.1, 0.1, 'Iris-setosa'], [5.8, 4.0, 1.2, 0.2, 'Iris-setosa'], [5.7, 4.4, 1.5, 0.4, 'Iris-setosa'], [5.4, 3.9, 1.3, 0.4, 'Iris-setosa'], [5.1, 3.5, 1.4, 0.3, 'Iris-setosa'], [5.7, 3.8, 1.7, 0.3, 'Iris-setosa'], [5.1, 3.8, 1.5, 0.3, 'Iris-setosa'], [5.4, 3.4, 1.7, 0.2, 'Iris-setosa'], [5.1, 3.7, 1.5, 0.4, 'Iris-setosa'], [4.6, 3.6, 1.0, 0.2, 'Iris-setosa'], [5.1, 3.3, 1.7, 0.5, 'Iris-setosa'], [4.8, 3.4, 1.9, 0.2, 'Iris-setosa'], [5.0, 3.0, 1.6, 0.2, 'Iris-setosa'], [5.0, 3.4, 1.6, 0.4, 'Iris-setosa'], [5.2, 3.5, 1.5, 0.2, 'Iris-setosa'], [5.2, 3.4, 1.4, 0.2, 'Iris-setosa'], [4.7, 3.2, 1.6, 0.2, 'Iris-setosa'], [4.8, 3.1, 1.6, 0.2, 'Iris-setosa'], [5.4, 3.4, 1.5, 0.4, 'Iris-setosa'], [5.2, 4.1, 1.5, 0.1, 'Iris-setosa'], [5.5, 4.2, 1.4, 0.2, 'Iris-setosa'], [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'], [5.0, 3.2, 1.2, 0.2, 'Iris-setosa'], [5.5, 3.5, 1.3, 0.2, 'Iris-setosa'], [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'], [4.4, 3.0, 1.3, 0.2, 'Iris-setosa'], [5.1, 3.4, 1.5, 0.2, 'Iris-setosa'], [5.0, 3.5, 1.3, 0.3, 'Iris-setosa'], [4.5, 2.3, 1.3, 0.3, 'Iris-setosa'], [4.4, 3.2, 1.3, 0.2, 'Iris-setosa'], [5.0, 3.5, 1.6, 0.6, 'Iris-setosa'], [5.1, 3.8, 1.9, 0.4, 'Iris-setosa'], [4.8, 3.0, 1.4, 0.3, 'Iris-setosa'], [5.1, 3.8, 1.6, 0.2, 'Iris-setosa'], [4.6, 3.2, 1.4, 0.2, 'Iris-setosa'], [5.3, 3.7, 1.5, 0.2, 'Iris-setosa'], [5.0, 3.3, 1.4, 0.2, 'Iris-setosa'], [7.0, 3.2, 4.7, 1.4, 'Iris-versicolor'], [6.4, 3.2, 4.5, 1.5, 'Iris-versicolor'], [6.9, 3.1, 4.9, 1.5, 'Iris-versicolor'], [5.5, 2.3, 4.0, 1.3, 'Iris-versicolor'], [6.5, 2.8, 4.6, 1.5, 'Iris-versicolor'], [5.7, 2.8, 4.5, 1.3, 'Iris-versicolor'], [6.3, 3.3, 4.7, 1.6, 'Iris-versicolor'], [4.9, 2.4, 3.3, 1.0, 'Iris-versicolor'], [6.6, 2.9, 4.6, 1.3, 'Iris-versicolor'], [5.2, 2.7, 3.9, 1.4, 'Iris-versicolor'], [5.0, 2.0, 3.5, 1.0, 'Iris-versicolor'], [5.9, 3.0, 4.2, 1.5, 'Iris-versicolor'], [6.0, 2.2, 4.0, 1.0, 'Iris-versicolor'], [6.1, 2.9, 4.7, 1.4, 'Iris-versicolor'], [5.6, 2.9, 3.6, 1.3, 'Iris-versicolor'], [6.7, 3.1, 4.4, 1.4, 'Iris-versicolor'], [5.6, 3.0, 4.5, 1.5, 'Iris-versicolor'], [5.8, 2.7, 4.1, 1.0, 'Iris-versicolor'], [6.2, 2.2, 4.5, 1.5, 'Iris-versicolor'], [5.6, 2.5, 3.9, 1.1, 'Iris-versicolor'], [5.9, 3.2, 4.8, 1.8, 'Iris-versicolor'], [6.1, 2.8, 4.0, 1.3, 'Iris-versicolor'], [6.3, 2.5, 4.9, 1.5, 'Iris-versicolor'], [6.1, 2.8, 4.7, 1.2, 'Iris-versicolor'], [6.4, 2.9, 4.3, 1.3, 'Iris-versicolor'], [6.6, 3.0, 4.4, 1.4, 'Iris-versicolor'], [6.8, 2.8, 4.8, 1.4, 'Iris-versicolor'], [6.7, 3.0, 5.0, 1.7, 'Iris-versicolor'], [6.0, 2.9, 4.5, 1.5, 'Iris-versicolor'], [5.7, 2.6, 3.5, 1.0, 'Iris-versicolor'], [5.5, 2.4, 3.8, 1.1, 'Iris-versicolor'], [5.5, 2.4, 3.7, 1.0, 'Iris-versicolor'], [5.8, 2.7, 3.9, 1.2, 'Iris-versicolor'], [6.0, 2.7, 5.1, 1.6, 'Iris-versicolor'], [5.4, 3.0, 4.5, 1.5, 'Iris-versicolor'], [6.0, 3.4, 4.5, 1.6, 'Iris-versicolor'], [6.7, 3.1, 4.7, 1.5, 'Iris-versicolor'], [6.3, 2.3, 4.4, 1.3, 'Iris-versicolor'], [5.6, 3.0, 4.1, 1.3, 'Iris-versicolor'], [5.5, 2.5, 4.0, 1.3, 'Iris-versicolor'], [5.5, 2.6, 4.4, 1.2, 'Iris-versicolor'], [6.1, 3.0, 4.6, 1.4, 'Iris-versicolor'], [5.8, 2.6, 4.0, 1.2, 'Iris-versicolor'], [5.0, 2.3, 3.3, 1.0, 'Iris-versicolor'], [5.6, 2.7, 4.2, 1.3, 'Iris-versicolor'], [5.7, 3.0, 4.2, 1.2, 'Iris-versicolor'], [5.7, 2.9, 4.2, 1.3, 'Iris-versicolor'], [6.2, 2.9, 4.3, 1.3, 'Iris-versicolor'], [5.1, 2.5, 3.0, 1.1, 'Iris-versicolor'], [5.7, 2.8, 4.1, 1.3, 'Iris-versicolor'], [6.3, 3.3, 6.0, 2.5, 'Iris-virginica'], [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'], [7.1, 3.0, 5.9, 2.1, 'Iris-virginica'], [6.3, 2.9, 5.6, 1.8, 'Iris-virginica'], [6.5, 3.0, 5.8, 2.2, 'Iris-virginica'], [7.6, 3.0, 6.6, 2.1, 'Iris-virginica'], [4.9, 2.5, 4.5, 1.7, 'Iris-virginica'], [7.3, 2.9, 6.3, 1.8, 'Iris-virginica'], [6.7, 2.5, 5.8, 1.8, 'Iris-virginica'], [7.2, 3.6, 6.1, 2.5, 'Iris-virginica'], [6.5, 3.2, 5.1, 2.0, 'Iris-virginica'], [6.4, 2.7, 5.3, 1.9, 'Iris-virginica'], [6.8, 3.0, 5.5, 2.1, 'Iris-virginica'], [5.7, 2.5, 5.0, 2.0, 'Iris-virginica'], [5.8, 2.8, 5.1, 2.4, 'Iris-virginica'], [6.4, 3.2, 5.3, 2.3, 'Iris-virginica'], [6.5, 3.0, 5.5, 1.8, 'Iris-virginica'], [7.7, 3.8, 6.7, 2.2, 'Iris-virginica'], [7.7, 2.6, 6.9, 2.3, 'Iris-virginica'], [6.0, 2.2, 5.0, 1.5, 'Iris-virginica'], [6.9, 3.2, 5.7, 2.3, 'Iris-virginica'], [5.6, 2.8, 4.9, 2.0, 'Iris-virginica'], [7.7, 2.8, 6.7, 2.0, 'Iris-virginica'], [6.3, 2.7, 4.9, 1.8, 'Iris-virginica'], [6.7, 3.3, 5.7, 2.1, 'Iris-virginica'], [7.2, 3.2, 6.0, 1.8, 'Iris-virginica'], [6.2, 2.8, 4.8, 1.8, 'Iris-virginica'], [6.1, 3.0, 4.9, 1.8, 'Iris-virginica'], [6.4, 2.8, 5.6, 2.1, 'Iris-virginica'], [7.2, 3.0, 5.8, 1.6, 'Iris-virginica'], [7.4, 2.8, 6.1, 1.9, 'Iris-virginica'], [7.9, 3.8, 6.4, 2.0, 'Iris-virginica'], [6.4, 2.8, 5.6, 2.2, 'Iris-virginica'], [6.3, 2.8, 5.1, 1.5, 'Iris-virginica'], [6.1, 2.6, 5.6, 1.4, 'Iris-virginica'], [7.7, 3.0, 6.1, 2.3, 'Iris-virginica'], [6.3, 3.4, 5.6, 2.4, 'Iris-virginica'], [6.4, 3.1, 5.5, 1.8, 'Iris-virginica'], [6.0, 3.0, 4.8, 1.8, 'Iris-virginica'], [6.9, 3.1, 5.4, 2.1, 'Iris-virginica'], [6.7, 3.1, 5.6, 2.4, 'Iris-virginica'], [6.9, 3.1, 5.1, 2.3, 'Iris-virginica'], [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'], [6.8, 3.2, 5.9, 2.3, 'Iris-virginica'], [6.7, 3.3, 5.7, 2.5, 'Iris-virginica'], [6.7, 3.0, 5.2, 2.3, 'Iris-virginica'], [6.3, 2.5, 5.0, 1.9, 'Iris-virginica'], [6.5, 3.0, 5.2, 2.0, 'Iris-virginica'], [6.2, 3.4, 5.4, 2.3, 'Iris-virginica'], [5.9, 3.0, 5.1, 1.8, 'Iris-virginica']] 
    2  
  • Orange/testing/regression/results_modules/kmeans-cmp-init.py.txt

    r9689 r9716  
    11           Rnd Div  HC 
    2       iris  11   2   3 
     2      iris  11   2  10 
    33   housing  13   5   3 
    44   vehicle  10   3   2 
  • Orange/testing/regression/results_orange25/ensemble.py.linux2.2.7.crash.txt

    r9689 r9718  
    11Traceback (most recent call last): 
    2   File "/home/miha/work/orange/testing/regressionTests/xtest_one.py", line 97, in <module> 
     2  File "/home/miha/work/orange/Orange/testing/regression/xtest_one.py", line 97, in <module> 
    33    execfile(t__name) 
    44  File "ensemble.py", line 16, in <module> 
    55    results = Orange.evaluation.testing.cross_validation(learners, lymphography, folds=3) 
    6   File "/home/miha/work/orange/orange/Orange/misc/__init__.py", line 454, in wrap_call 
     6  File "/home/miha/work/orange/Orange/misc/__init__.py", line 511, in wrap_call 
    77    return func(*args, **kwargs) 
    8   File "/home/miha/work/orange/orange/Orange/evaluation/testing.py", line 228, in cross_validation 
     8  File "/home/miha/work/orange/Orange/evaluation/testing.py", line 227, in cross_validation 
    99    store_examples=store_examples) 
    10   File "/home/miha/work/orange/orange/Orange/misc/__init__.py", line 454, in wrap_call 
     10  File "/home/miha/work/orange/Orange/misc/__init__.py", line 511, in wrap_call 
    1111    return func(*args, **kwargs) 
    12   File "/home/miha/work/orange/orange/Orange/evaluation/testing.py", line 295, in test_with_indices 
     12  File "/home/miha/work/orange/Orange/evaluation/testing.py", line 294, in test_with_indices 
    1313    results, classifiers = self.one_fold_with_indices(learners, examples, fold, indices, preprocessors, weight) 
    14   File "/home/miha/work/orange/orange/Orange/evaluation/testing.py", line 326, in one_fold_with_indices 
     14  File "/home/miha/work/orange/Orange/evaluation/testing.py", line 325, in one_fold_with_indices 
    1515    results = self._test_on_data(classifiers, test_set, testset_ids) 
    16   File "/home/miha/work/orange/orange/Orange/evaluation/testing.py", line 669, in _test_on_data 
     16  File "/home/miha/work/orange/Orange/evaluation/testing.py", line 668, in _test_on_data 
    1717    result = classifier(ex2, Orange.core.GetBoth) 
    18   File "/home/miha/work/orange/orange/Orange/ensemble/boosting.py", line 136, in __call__ 
     18  File "/home/miha/work/orange/Orange/ensemble/boosting.py", line 136, in __call__ 
    1919    index = Orange.misc.selection.selectBestIndex(votes) 
    20   File "/home/miha/work/orange/orange/Orange/misc/__init__.py", line 526, in wrapped 
     20  File "/home/miha/work/orange/Orange/misc/__init__.py", line 583, in wrapped 
    2121    return func(*args, **kwargs) 
    22   File "/home/miha/work/orange/orange/Orange/misc/__init__.py", line 454, in wrap_call 
     22  File "/home/miha/work/orange/Orange/misc/__init__.py", line 511, in wrap_call 
    2323    return func(*args, **kwargs) 
    24   File "/home/miha/work/orange/orange/Orange/misc/selection.py", line 209, in select_best_index 
     24  File "/home/miha/work/orange/Orange/misc/selection.py", line 209, in select_best_index 
    2525    bs=BestOnTheFly(compare, seed, call_compare_on_1st) 
    26   File "/home/miha/work/orange/orange/Orange/misc/__init__.py", line 454, in wrap_call 
     26  File "/home/miha/work/orange/Orange/misc/__init__.py", line 511, in wrap_call 
    2727    return func(*args, **kwargs) 
    28   File "/home/miha/work/orange/orange/Orange/misc/selection.py", line 105, in __init__ 
     28  File "/home/miha/work/orange/Orange/misc/selection.py", line 105, in __init__ 
    2929    self.randomGenerator = random.Random(seed) 
    3030AttributeError: 'module' object has no attribute 'Random' 
  • Orange/testing/unit/tests/test_distance.py

    r9679 r9724  
    33from Orange.misc.testing import datasets_driven, test_on_data 
    44 
    5 from Orange.distance import instances 
     5from Orange.distance import * 
    66 
    77@datasets_driven 
    88class TestEuclideanDistance(testing.DistanceTestCase): 
    9     DISTANCE_CONSTRUCTOR = instances.EuclideanConstructor() 
     9    DISTANCE_CONSTRUCTOR = Euclidean() 
    1010 
    1111@datasets_driven     
    1212class TestMannhatanDistance(testing.DistanceTestCase): 
    13     DISTANCE_CONSTRUCTOR = instances.ManhattanConstructor() 
     13    DISTANCE_CONSTRUCTOR = Manhattan() 
    1414     
    1515@datasets_driven 
    1616class TestHammingDistance(testing.DistanceTestCase): 
    17     DISTANCE_CONSTRUCTOR = instances.HammingConstructor() 
     17    DISTANCE_CONSTRUCTOR = Hamming() 
    1818     
    1919@datasets_driven 
    2020class TestReliefDistance(testing.DistanceTestCase): 
    21     DISTANCE_CONSTRUCTOR = instances.ReliefConstructor() 
     21    DISTANCE_CONSTRUCTOR = Relief() 
    2222 
    2323@datasets_driven 
    2424class TestPearsonRDistance(testing.DistanceTestCase): 
    25     DISTANCE_CONSTRUCTOR = instances.PearsonRConstructor() 
     25    DISTANCE_CONSTRUCTOR = PearsonR() 
    2626 
    2727@datasets_driven 
    2828class TestSpearmanRDistance(testing.DistanceTestCase): 
    29     DISTANCE_CONSTRUCTOR = instances.SpearmanRConstructor() 
     29    DISTANCE_CONSTRUCTOR = SpearmanR() 
    3030     
    3131@datasets_driven 
    3232class TestPearsonRAbsoluteDistance(testing.DistanceTestCase): 
    33     DISTANCE_CONSTRUCTOR = instances.PearsonRAbsoluteConstructor() 
     33    DISTANCE_CONSTRUCTOR = PearsonRAbsolute() 
    3434     
    3535@datasets_driven 
    3636class TestSpearmanRAbsoluteDistance(testing.DistanceTestCase): 
    37     DISTANCE_CONSTRUCTOR = instances.SpearmanRAbsoluteConstructor() 
     37    DISTANCE_CONSTRUCTOR = SpearmanRAbsolute() 
    3838     
    3939@datasets_driven 
    4040class TestMahalanobisDistance(testing.DistanceTestCase): 
    41     DISTANCE_CONSTRUCTOR = instances.MahalanobisConstructor() 
     41    DISTANCE_CONSTRUCTOR = Mahalanobis() 
    4242     
    4343if __name__ == "__main__": 
  • Orange/testing/unit/tests/test_hclustering.py

    r9679 r9724  
    55                       
    66from Orange.clustering import hierarchical as hier      
    7 from Orange.distance.instances import * 
     7from Orange.distance import * 
    88                            
    99import Orange.misc.testing as testing 
     
    1717    @testing.test_on_data 
    1818    def test_example_clustering_on(self, data): 
    19         constructors = [EuclideanConstructor, ManhattanConstructor] 
     19        constructors = [Euclidean, Manhattan] 
    2020        for distance_constructor in constructors: 
    2121            clust = clustering(data, distance_constructor, HierarchicalClustering.Single) 
     
    3333    @testing.test_on_datasets(datasets=["iris"]) 
    3434    def test_pickling_on(self, data): 
    35         cluster = clustering(data, EuclideanConstructor, HierarchicalClustering.Single) 
     35        cluster = clustering(data, Euclidean, HierarchicalClustering.Single) 
    3636        s = pickle.dumps(cluster) 
    3737        cluster_clone = pickle.loads(s) 
     
    4444            self.assert_(val >= 0 and val <=100) 
    4545            self.assertIsInstance(val, float) 
    46         matrix = instance_distance_matrix(data, EuclideanConstructor(), progress_callback=p) 
     46        matrix = instance_distance_matrix(data, Euclidean(), progress_callback=p) 
    4747        root1 = HierarchicalClustering(matrix, progress_callback=p) 
    4848        root2 = hier.clone(root1) 
  • Orange/testing/unit/tests/test_kmeans.py

    r9679 r9724  
    33from Orange.clustering import kmeans 
    44from Orange.clustering.kmeans import Clustering 
    5 from Orange.distance.instances import * 
     5from Orange.distance import * 
    66 
    77@testing.datasets_driven 
     
    2323    @testing.test_on_data 
    2424    def test_init_functs(self, table): 
    25         distfunc = EuclideanConstructor(table) 
     25        distfunc = Euclidean(table) 
    2626        for k in [1, 5, 10]: 
    2727            self._test_init_func(table, k, distfunc) 
  • Orange/testing/unit/tests/test_knn.py

    r9679 r9724  
    44from Orange.misc.testing import datasets_driven, test_on_data 
    55from Orange.classification import knn 
    6 from Orange.distance.instances import EuclideanConstructor 
     6from Orange.distance import Euclidean 
    77 
    88 
     
    1111class TestKNNLearner(testing.LearnerTestCase): 
    1212    def setUp(self): 
    13         self.learner = knn.kNNLearner(distance_constructor=EuclideanConstructor()) 
     13        self.learner = knn.kNNLearner(distance_constructor=Euclidean()) 
    1414     
    1515    @testing.test_on_data 
    1616    def test_learner_on(self, dataset): 
    1717        testing.LearnerTestCase.test_learner_on(self, dataset) 
    18         instance = dataset.randomexample() 
     18        instance = dataset.random_instance() 
    1919        self.assertEqual(len(self.classifier.find_nearest(3, instance)), 3) 
    2020         
  • Orange/testing/unit/tests/test_mds.py

    r9679 r9724  
    44import unittest 
    55from Orange.projection import mds 
    6 from Orange.distance.instances import distance_matrix, EuclideanConstructor 
     6from Orange.distance import distance_matrix, Euclidean 
    77     
    88@datasets_driven 
  • docs/reference/rst/Orange.data.table.rst

    r9636 r9726  
    99(:obj:`Orange.data.Domain`). 
    1010 
    11 Data tables are usually loaded from a file (see :doc:`/Orange.data.formats`):: 
     11Data tables are usually loaded from a file (see :doc:`Orange.data.formats`):: 
    1212 
    1313    import Orange 
  • docs/reference/rst/Orange.data.variable.rst

    r9372 r9727  
    11.. automodule:: Orange.data.variable 
     2 
     3======================== 
     4Variables (``variable``) 
     5======================== 
     6 
     7Data instances in Orange can contain several types of variables: 
     8:ref:`discrete <discrete>`, :ref:`continuous <continuous>`, 
     9:ref:`strings <string>`, and :ref:`Python <Python>` and types derived from it. 
     10The latter represent arbitrary Python objects. 
     11The names, types, values (where applicable), functions for computing the 
     12variable value from values of other variables, and other properties of the 
     13variables are stored in descriptor classes derived from :obj:`Orange.data 
     14.variable.Variable`. 
     15 
     16Orange considers two variables (e.g. in two different data tables) the 
     17same if they have the same descriptor. It is allowed - but not 
     18recommended - to have different variables with the same name. 
     19 
     20Variable descriptors 
     21-------------------- 
     22 
     23Variable descriptors can be constructed either by calling the 
     24corresponding constructors or by a factory function :func:`Orange.data 
     25.variable.make`, which either retrieves an existing descriptor or 
     26constructs a new one. 
     27 
     28.. class:: Variable 
     29 
     30    An abstract base class for variable descriptors. 
     31 
     32    .. attribute:: name 
     33 
     34        The name of the variable. 
     35 
     36    .. attribute:: var_type 
     37 
     38        Variable type; it can be :obj:`~Orange.data.Type.Discrete`, 
     39        :obj:`~Orange.data.Type.Continuous`, 
     40        :obj:`~Orange.data.Type.String` or :obj:`~Orange.data.Type.Other`. 
     41 
     42    .. attribute:: get_value_from 
     43 
     44        A function (an instance of :obj:`~Orange.classification.Classifier`) 
     45        that computes a value of the variable from values of one or more 
     46        other variables. This is used, for instance, in discretization, 
     47        which computes the value of a discretized variable from the 
     48        original continuous variable. 
     49 
     50    .. attribute:: ordered 
     51 
     52        A flag telling whether the values of a discrete variable are ordered. At 
     53        the moment, no built-in method treats ordinal variables differently than 
     54        nominal ones. 
     55 
     56    .. attribute:: random_generator 
     57 
     58        A local random number generator used by method 
     59        :obj:`~Variable.randomvalue()`. 
     60 
     61    .. attribute:: default_meta_id 
     62 
     63        A proposed (but not guaranteed) meta id to be used for that variable. 
     64        For instance, when a tab-delimited contains meta attributes and 
     65        the existing variables are reused, they will have this id 
     66        (instead of a new one assigned by :obj:`Orange.data.new_meta_id()`). 
     67 
     68    .. attribute:: attributes 
     69 
     70        A dictionary which allows the user to store additional information 
     71        about the variable. All values should be strings. See the section 
     72        about :ref:`storing additional information <attributes>`. 
     73 
     74    .. method:: __call__(obj) 
     75 
     76           Convert a string, number, or other suitable object into a variable 
     77           value. 
     78 
     79           :param obj: An object to be converted into a variable value 
     80           :type o: any suitable 
     81           :rtype: :class:`Orange.data.Value` 
     82 
     83    .. method:: randomvalue() 
     84 
     85           Return a random value for the variable. 
     86 
     87           :rtype: :class:`Orange.data.Value` 
     88 
     89    .. method:: compute_value(inst) 
     90 
     91           Compute the value of the variable given the instance by calling 
     92           obj:`~Variable.get_value_from` through a mechanism that 
     93           prevents infinite recursive calls. 
     94 
     95           :rtype: :class:`Orange.data.Value` 
     96 
     97.. _discrete: 
     98.. class:: Discrete 
     99 
     100    Bases: :class:`Variable` 
     101 
     102    Descriptor for discrete variables. 
     103 
     104    .. attribute:: values 
     105 
     106        A list with symbolic names for variables' values. Values are stored as 
     107        indices referring to this list and modifying it instantly 
     108        changes the (symbolic) names of values as they are printed out or 
     109        referred to by user. 
     110 
     111        .. note:: 
     112 
     113            The size of the list is also used to indicate the number of 
     114            possible values for this variable. Changing the size - especially 
     115            shrinking the list - can crash Python. Also, do not add values 
     116            to the list by calling its append or extend method: use 
     117             :obj:`add_value` method instead. 
     118 
     119            It is also assumed that this attribute is always defined (but can 
     120            be empty), so never set it to ``None``. 
     121 
     122    .. attribute:: base_value 
     123 
     124            Stores the base value for the variable as an index in `values`. 
     125            This can be, for instance, a "normal" value, such as "no 
     126            complications" as opposed to abnormal "low blood pressure". The 
     127            base value is used by certain statistics, continuization etc. 
     128            potentially, learning algorithms. The default is -1 which means that 
     129            there is no base value. 
     130 
     131    .. method:: add_value(s) 
     132 
     133            Add a value with symbolic name ``s`` to values. Always call 
     134            this function instead of appending to ``values``. 
     135 
     136.. _continuous: 
     137.. class:: Continuous 
     138 
     139    Bases: :class:`Variable` 
     140 
     141    Descriptor for continuous variables. 
     142 
     143    .. attribute:: number_of_decimals 
     144 
     145        The number of decimals used when the value is printed out, converted to 
     146        a string or saved to a file. 
     147 
     148    .. attribute:: scientific_format 
     149 
     150        If ``True``, the value is printed in scientific format whenever it 
     151        would have more than 5 digits. In this case, :obj:`number_of_decimals` is 
     152        ignored. 
     153 
     154    .. attribute:: adjust_decimals 
     155 
     156        Tells Orange to monitor the number of decimals when the value is 
     157        converted from a string (when the values are read from a file or 
     158        converted by, e.g. ``inst[0]="3.14"``): 
     159 
     160        * 0: the number of decimals is not adjusted automatically; 
     161        * 1: the number of decimals is (and has already) been adjusted; 
     162        * 2: automatic adjustment is enabled, but no values have been 
     163          converted yet. 
     164 
     165        By default, adjustment of the number of decimals goes as follows: 
     166 
     167        * If the variable was constructed when data was read from a file, 
     168          it will be printed with the same number of decimals as the 
     169          largest number of decimals encountered in the file. If 
     170          scientific notation occurs in the file, 
     171          :obj:`scientific_format` will be set to ``True`` and scientific 
     172          format will be used for values too large or too small. 
     173 
     174        * If the variable is created in a script, it will have, 
     175          by default, three decimal places. This can be changed either by 
     176          setting the value from a string (e.g. ``inst[0]="3.14"``, 
     177          but not ``inst[0]=3.14``) or by manually setting the 
     178          :obj:`number_of_decimals`. 
     179 
     180    .. attribute:: start_value, end_value, step_value 
     181 
     182        The range used for :obj:`randomvalue`. 
     183 
     184.. _String: 
     185.. class:: String 
     186 
     187    Bases: :class:`Variable` 
     188 
     189    Descriptor for variables that contain strings. No method can use them for 
     190    learning; some will raise error or warnings, and others will 
     191    silently ignore them. They can be, however, used as meta-attributes; if 
     192    instances in a dataset have unique IDs, the most efficient way to store them 
     193    is to read them as meta-attributes. In general, never use discrete 
     194    attributes with many (say, more than 50) values. Such attributes are 
     195    probably not of any use for learning and should be stored as string 
     196    attributes. 
     197 
     198    When converting strings into values and back, empty strings are treated 
     199    differently than usual. For other types, an empty string denotes 
     200    undefined values, while :obj:`String` will take empty strings 
     201    as empty strings -- except when loading or saving into file. 
     202    Empty strings in files are interpreted as undefined; to specify an empty 
     203    string, enclose the string in double quotes; these are removed when the 
     204    string is loaded. 
     205 
     206.. _Python: 
     207.. class:: Python 
     208 
     209    Bases: :class:`Variable` 
     210 
     211    Base class for descriptors defined in Python. It is fully functional 
     212    and can be used as a descriptor for attributes that contain arbitrary Python 
     213    values. Since this is an advanced topic, PythonVariables are described on a 
     214    separate page. !!TODO!! 
     215 
     216 
     217.. _attributes: 
     218 
     219Storing additional attributes 
     220----------------------------- 
     221 
     222All variables have a field :obj:`~Variable.attributes`, a dictionary 
     223that can store additional string data. 
     224 
     225.. literalinclude:: code/attributes.py 
     226 
     227These attributes can only be saved to a .tab file. They are listed in the 
     228third line in <name>=<value> format, after other attribute specifications 
     229(such as "meta" or "class"), and are separated by spaces. 
     230 
     231.. _variable_descriptor_reuse: 
     232 
     233Reuse of descriptors 
     234-------------------- 
     235 
     236There are situations when variable descriptors need to be reused. Typically, the 
     237user loads some training examples, trains a classifier, and then loads a separate 
     238test set. For the classifier to recognize the variables in the second data set, 
     239the descriptors, not just the names, need to be the same. 
     240 
     241When constructing new descriptors for data read from a file or during unpickling, 
     242Orange checks whether an appropriate descriptor (with the same name and, in case 
     243of discrete variables, also values) already exists and reuses it. When new 
     244descriptors are constructed by explicitly calling the above constructors, this 
     245always creates new descriptors and thus new variables, although a variable with 
     246the same name may already exist. 
     247 
     248The search for an existing variable is based on four attributes: the variable's name, 
     249type, ordered values, and unordered values. As for the latter two, the values can 
     250be explicitly ordered by the user, e.g. in the second line of the tab-delimited 
     251file. For instance, sizes can be ordered as small, medium, or big. 
     252 
     253The search for existing variables can end with one of the following statuses. 
     254 
     255.. data:: Orange.data.variable.MakeStatus.NotFound (4) 
     256 
     257    The variable with that name and type does not exist. 
     258 
     259.. data:: Orange.data.variable.MakeStatus.Incompatible (3) 
     260 
     261    There are variables with matching name and type, but their 
     262    values are incompatible with the prescribed ordered values. For example, 
     263    if the existing variable already has values ["a", "b"] and the new one 
     264    wants ["b", "a"], the old variable cannot be reused. The existing list can, 
     265    however be appended with the new values, so searching for ["a", "b", "c"] would 
     266    succeed. Likewise a search for ["a"] would be successful, since the extra existing value 
     267    does not matter. The formal rule is thus that the values are compatible iff ``existing_values[:len(ordered_values)] == ordered_values[:len(existing_values)]``. 
     268 
     269.. data:: Orange.data.variable.MakeStatus.NoRecognizedValues (2) 
     270 
     271    There is a matching variable, yet it has none of the values that the new 
     272    variable will have (this is obviously possible only if the new variable has 
     273    no prescribed ordered values). For instance, we search for a variable 
     274    "sex" with values "male" and "female", while there is a variable of the same 
     275    name with values "M" and "F" (or, well, "no" and "yes" :). Reuse of this 
     276    variable is possible, though this should probably be a new variable since it 
     277    obviously comes from a different data set. If we do decide to reuse the variable, the 
     278    old variable will get some unneeded new values and the new one will inherit 
     279    some from the old. 
     280 
     281.. data:: Orange.data.variable.MakeStatus.MissingValues (1) 
     282 
     283    There is a matching variable with some of the values that the new one 
     284    requires, but some values are missing. This situation is neither uncommon 
     285    nor suspicious: in case of separate training and testing data sets there may 
     286    be values which occur in one set but not in the other. 
     287 
     288.. data:: Orange.data.variable.MakeStatus.OK (0) 
     289 
     290    There is a perfect match which contains all the prescribed values in the 
     291    correct order. The existing variable may have some extra values, though. 
     292 
     293Continuous variables can obviously have only two statuses, 
     294:obj:`~Orange.data.variable.MakeStatus.NotFound` or :obj:`~Orange.data.variable.MakeStatus.OK`. 
     295 
     296When loading the data using :obj:`Orange.data.Table`, Orange takes the safest 
     297approach and, by default, reuses everything that is compatible up to 
     298and including :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`. Unintended reuse would be obvious from the 
     299variable having too many values, which the user can notice and fix. More on that 
     300in the page on :doc:`Orange.data.formats`. 
     301 
     302There are two functions for reusing the variables instead of creating new ones. 
     303 
     304.. function:: Orange.data.variable.make(name, type, ordered_values, unordered_values[, create_new_on]) 
     305 
     306    Find and return an existing variable or create a new one if none of the existing 
     307    variables matches the given name, type and values. 
     308 
     309    The optional `create_new_on` specifies the status at which a new variable is 
     310    created. The status must be at most :obj:`~Orange.data.variable.MakeStatus.Incompatible` since incompatible (or 
     311    non-existing) variables cannot be reused. If it is set lower, for instance 
     312    to :obj:`~Orange.data.variable.MakeStatus.MissingValues`, a new variable is created even if there exists 
     313    a variable which is only missing the same values. If set to :obj:`~Orange.data.variable.MakeStatus.OK`, the function 
     314    always creates a new variable. 
     315 
     316    The function returns a tuple containing a variable descriptor and the 
     317    status of the best matching variable. So, if ``create_new_on`` is set to 
     318    :obj:`~Orange.data.variable.MakeStatus.MissingValues`, and there exists a variable whose status is, say, 
     319    :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`, a variable would be created, while the second 
     320    element of the tuple would contain :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`. If, on the other 
     321    hand, there exists a variable which is perfectly OK, its descriptor is 
     322    returned and the returned status is :obj:`~Orange.data.variable.MakeStatus.OK`. The function returns no 
     323    indicator whether the returned variable is reused or not. This can be, 
     324    however, read from the status code: if it is smaller than the specified 
     325    ``create_new_on``, the variable is reused, otherwise a new descriptor has been constructed. 
     326 
     327    The exception to the rule is when ``create_new_on`` is OK. In this case, the 
     328    function does not search through the existing variables and cannot know the 
     329    status, so the returned status in this case is always :obj:`~Orange.data.variable.MakeStatus.OK`. 
     330 
     331    :param name: Variable name 
     332    :param type: Variable type 
     333    :type type: Orange.data.variable.Type 
     334    :param ordered_values: a list of ordered values 
     335    :param unordered_values: a list of values, for which the order does not 
     336        matter 
     337    :param create_new_on: gives the condition for constructing a new variable instead 
     338        of using the new one 
     339 
     340    :return_type: a tuple (:class:`~Orange.data.variable.Variable`, int) 
     341 
     342.. function:: Orange.data.variable.retrieve(name, type, ordered_values, onordered_values[, create_new_on]) 
     343 
     344    Find and return an existing variable, or :obj:`None` if no match is found. 
     345 
     346    :param name: variable name. 
     347    :param type: variable type. 
     348    :type type: Orange.data.variable.Type 
     349    :param ordered_values: a list of ordered values 
     350    :param unordered_values: a list of values, for which the order does not 
     351        matter 
     352    :param create_new_on: gives the condition for constructing a new variable instead 
     353        of using the new one 
     354 
     355    :return_type: :class:`~Orange.data.variable.Variable` 
     356 
     357The following examples give the shown results if 
     358executed only once (in a Python session) and in this order. 
     359 
     360:func:`Orange.data.variable.make` can be used for the construction of new variables. :: 
     361 
     362    >>> v1, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["a", "b"]) 
     363    >>> print s, v1.values 
     364    NotFound <a, b> 
     365 
     366A new variable was created and the status is :obj:`~Orange.data.variable 
     367.MakeStatus.NotFound`. :: 
     368 
     369    >>> v2, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["a"], ["c"]) 
     370    >>> print s, v2 is v1, v1.values 
     371    MissingValues True <a, b, c> 
     372 
     373The status is :obj:`~Orange.data.variable.MakeStatus.MissingValues`, 
     374yet the variable is reused (``v2 is v1``). ``v1`` gets a new value, 
     375``"c"``, which was given as an unordered value. It does 
     376not matter that the new variable does not need the value ``b``. :: 
     377 
     378    >>> v3, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["a", "b", "c", "d"]) 
     379    >>> print s, v3 is v1, v1.values 
     380    MissingValues True <a, b, c, d> 
     381 
     382This is like before, except that the new value, ``d`` is not among the 
     383ordered values. :: 
     384 
     385    >>> v4, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, ["b"]) 
     386    >>> print s, v4 is v1, v1.values, v4.values 
     387    Incompatible, False, <b>, <a, b, c, d> 
     388 
     389The new variable needs to have ``b`` as the first value, so it is incompatible 
     390with the existing variables. The status is 
     391:obj:`~Orange.data.variable.MakeStatus.Incompatible` and 
     392a new variable is created; the two variables are not equal and have 
     393different lists of values. :: 
     394 
     395    >>> v5, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, None, ["c", "a"]) 
     396    >>> print s, v5 is v1, v1.values, v5.values 
     397    OK True <a, b, c, d> <a, b, c, d> 
     398 
     399The new variable has values ``c`` and ``a``, but the order is not important, 
     400so the existing attribute is :obj:`~Orange.data.variable.MakeStatus.OK`. :: 
     401 
     402    >>> v6, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, None, ["e"]) "a"]) 
     403    >>> print s, v6 is v1, v1.values, v6.values 
     404    NoRecognizedValues True <a, b, c, d, e> <a, b, c, d, e> 
     405 
     406The new variable has different values than the existing variable (status 
     407is :obj:`~Orange.data.variable.MakeStatus.NoRecognizedValues`), 
     408but the existing one is nonetheless reused. Note that we 
     409gave ``e`` in the list of unordered values. If it was among the ordered, the 
     410reuse would fail. :: 
     411 
     412    >>> v7, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, None, 
     413            ["f"], Orange.data.variable.MakeStatus.NoRecognizedValues))) 
     414    >>> print s, v7 is v1, v1.values, v7.values 
     415    Incompatible False <a, b, c, d, e> <f> 
     416 
     417This is the same as before, except that we prohibited reuse when there are no 
     418recognized values. Hence a new variable is created, though the returned status is 
     419the same as before:: 
     420 
     421    >>> v8, s = Orange.data.variable.make("a", Orange.data.Type.Discrete, 
     422            ["a", "b", "c", "d", "e"], None, Orange.data.variable.MakeStatus.OK) 
     423    >>> print s, v8 is v1, v1.values, v8.values 
     424    OK False <a, b, c, d, e> <a, b, c, d, e> 
     425 
     426Finally, this is a perfect match, but any reuse is prohibited, so a new 
     427variable is created. 
     428 
     429 
     430 
     431Variables computed from other variables 
     432--------------------------------------- 
     433 
     434Values of variables are often computed from other variables, such as in 
     435discretization. The mechanism described below usually functions behind the scenes, 
     436so understanding it is required only for implementing specific transformations. 
     437 
     438Monk 1 is a well-known dataset with target concept ``y := a==b or e==1``. 
     439It can help the learning algorithm if the four-valued attribute ``e`` is 
     440replaced with a binary attribute having values `"1"` and `"not 1"`. The 
     441new variable will be computed from the old one on the fly. 
     442 
     443.. literalinclude:: code/variable-get_value_from.py 
     444    :lines: 7-17 
     445 
     446The new variable is named ``e2``; we define it with a descriptor of type 
     447:obj:`Discrete`, with appropriate name and values ``"not 1"`` and ``1`` (we 
     448chose this order so that the ``not 1``'s index is ``0``, which can be, if 
     449needed, interpreted as ``False``). Finally, we tell e2 to use 
     450``checkE`` to compute its value when needed, by assigning ``checkE`` to 
     451``e2.get_value_from``. 
     452 
     453``checkE`` is a function that is passed an instance and another argument we 
     454do not care about here. If the instance's ``e`` equals ``1``, the function 
     455returns value ``1``, otherwise it returns ``not 1``. Both are returned as 
     456values, not plain strings. 
     457 
     458In most circumstances the value of ``e2`` can be computed on the fly - we can 
     459pretend that the variable exists in the data, although it does not (but 
     460can be computed from it). For instance, we can compute the information gain of 
     461variable ``e2`` or its distribution without actually constructing data containing 
     462the new variable. 
     463 
     464.. literalinclude:: code/variable-get_value_from.py 
     465    :lines: 19-22 
     466 
     467There are methods which cannot compute values on the fly because it would be 
     468too complex or time consuming. In such cases, the data need to be converted 
     469to a new :obj:`Orange.data.Table`:: 
     470 
     471    new_domain = Orange.data.Domain([data.domain["a"], data.domain["b"], e2, data.domain.class_var]) 
     472    new_data = Orange.data.Table(new_domain, data) 
     473 
     474Automatic computation is useful when the data is split into training and 
     475testing examples. Training instances can be modified by adding, removing 
     476and transforming variables (in a typical setup, continuous variables 
     477are discretized prior to learning, therefore the original variables are 
     478replaced by new ones). Test instances, on the other hand, are left as they 
     479are. When they are classified, the classifier automatically converts the 
     480testing instances into the new domain, which includes recomputation of 
     481transformed variables. 
     482 
     483.. literalinclude:: code/variable-get_value_from.py 
     484    :lines: 24- 
  • docs/reference/rst/Orange.distance.rst

    r9663 r9720  
     1.. py:currentmodule:: Orange.distance 
     2 
    13.. automodule:: Orange.distance 
    24 
     
    57########################################## 
    68 
    7 This page describes a bunch of classes for different metrics for measure 
    8 distances (dissimilarities) between instances. 
     9Distance measures typically have to be adjusted to the data. For instance, 
     10when the data set contains continuous features, the distances between 
     11continuous values should be normalized to ensure that all features have 
     12similar impats, e.g. by dividing the distance with the range. 
    913 
    10 Typical (although not all) measures of distance between instances require 
    11 some "learning" - adjusting the measure to the data. For instance, when 
    12 the dataset contains continuous features, the distances between continuous 
    13 values should be normalized, e.g. by dividing the distance with the range 
    14 of possible values or with some interquartile distance to ensure that all 
    15 features have, in principle, similar impacts. 
    16  
    17 Different measures of distance thus appear in pairs - a class that measures 
    18 the distance and a class that constructs it based on the data. The abstract 
    19 classes representing such a pair are `ExamplesDistance` and 
    20 `ExamplesDistanceConstructor`. 
     14Distance measures thus appear in pairs - a class that measures 
     15the distance (:obj:`Distance`) and a class that constructs it based on the 
     16data (:obj:`DistanceConstructor`). 
    2117 
    2218Since most measures work on normalized distances between corresponding 
    23 features, there is an abstract intermediate class 
    24 `ExamplesDistance_Normalized` that takes care of normalizing. 
    25 The remaining classes correspond to different ways of defining the distances, 
    26 such as Manhattan or Euclidean distance. 
     19features, an abstract class `DistanceNormalized` takes care of 
     20normalizing. 
    2721 
    28 Unknown values are treated correctly only by Euclidean and Relief distance. 
    29 For other measure of distance, a distance between unknown and known or between 
    30 two unknown values is always 0.5. 
     22Unknown values are treated correctly only by Euclidean and Relief 
     23distance.  For other measures, a distance between unknown and known or 
     24between two unknown values is always 0.5. 
    3125 
    32 .. class:: ExamplesDistance 
     26.. class:: Distance 
    3327 
    3428    .. method:: __call__(instance1, instance2) 
    3529 
    36         Returns a distance between the given instances as floating point number. 
     30        Return a distance between the given instances (as a floating point number). 
    3731 
    38 .. class:: ExamplesDistanceConstructor 
     32.. class:: DistanceConstructor 
    3933 
    4034    .. method:: __call__([instances, weightID][, distributions][, basic_var_stat]) 
    4135 
    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. 
     36        Constructs an :obj:`Distance`.  Not all the data needs to be 
     37        given. Most measures can be constructed from basic_var_stat; 
     38        if it is not given, they can help themselves either by instances 
     39        or distributions. Some do not need any arguments. 
    4740 
    48 .. class:: ExamplesDistance_Normalized 
     41.. class:: DistanceNormalized 
    4942 
    5043    This abstract class provides a function which is given two instances 
     
    7265        (continuous features only) 
    7366 
    74     .. attribute:: domainVersion 
     67    .. attribute:: domain_version 
    7568 
    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 
     69        The domain version increases each time a domain description is 
     70        changed (i.e. features are added or removed); this checks  
     71        that the user is not attempting to measure distances between 
    8072        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. 
    8373 
    84     .. method:: attributeDistances(instance1, instance2) 
     74    .. method:: attribute_distances(instance1, instance2) 
    8575 
    86         Returns a list of floats representing distances between pairs of 
     76        Return a list of floats representing distances between pairs of 
    8777        feature values of the two instances. 
    88  
    8978 
    9079.. class:: HammingConstructor 
     
    9584    is not really appropriate for instances that contain continuous features. 
    9685 
    97  
    9886.. class:: MaximalConstructor 
    9987.. class:: Maximal 
     
    10189    The maximal between two instances is defined as the maximal distance 
    10290    between two feature values. If dist is the result of 
    103     ExamplesDistance_Normalized.attributeDistances, 
     91    DistanceNormalized.attribute_distances, 
    10492    then Maximal returns max(dist). 
    105  
    10693 
    10794.. class:: ManhattanConstructor 
  • docs/reference/rst/code/distances-test.py

    r9663 r9724  
    55 
    66# Euclidean distance constructor 
    7 d2Constr = Orange.distance.EuclideanConstructor() 
     7d2Constr = Orange.distance.Euclidean() 
    88d2 = d2Constr(iris) 
    99 
    1010# Constructs  
    11 dPears = Orange.distance.PearsonRConstructor(iris) 
     11dPears = Orange.distance.PearsonR(iris) 
    1212 
    1313#reference instance 
  • docs/reference/rst/code/ensemble-forest.py

    r9638 r9734  
    88 
    99forest = Orange.ensemble.forest.RandomForestLearner(trees=50, name="forest") 
    10 tree = Orange.classification.tree.TreeLearner(minExamples=2, mForPrunning=2, \ 
    11                             sameMajorityPruning=True, name='tree') 
     10tree = Orange.classification.tree.TreeLearner(min_examples=2, m_prunning=2, \ 
     11                            same_majority_pruning=True, name='tree') 
    1212learners = [tree, forest] 
    1313 
  • docs/reference/rst/code/knnExample2.py

    r9638 r9724  
    44knn = Orange.classification.knn.kNNLearner() 
    55knn.k = 10 
    6 knn.distance_constructor = Orange.core.ExamplesDistanceConstructor_Hamming() 
     6knn.distance_constructor = Orange.distance.Hamming() 
    77knn = knn(iris) 
    88for i in range(5): 
  • docs/reference/rst/code/knnInstanceDistance.py

    r9638 r9724  
    44 
    55nnc = Orange.classification.knn.FindNearestConstructor() 
    6 nnc.distanceConstructor = Orange.core.ExamplesDistanceConstructor_Euclidean() 
     6nnc.distanceConstructor = Orange.distance.Euclidean() 
    77 
    88did = Orange.data.new_meta_id() 
  • docs/reference/rst/code/knnlearner.py

    r9638 r9724  
    1515knn = Orange.classification.knn.kNNLearner(train, k=10) 
    1616for i in range(5): 
    17     instance = test.randomexample() 
     17    instance = test.random_instance() 
    1818    print instance.getclass(), knn(instance) 
    1919 
     
    2323knn = Orange.classification.knn.kNNLearner() 
    2424knn.k = 10 
    25 knn.distanceConstructor = Orange.core.ExamplesDistanceConstructor_Hamming() 
     25knn.distance_constructor = Orange.distance.Hamming() 
    2626knn = knn(train) 
    2727for i in range(5): 
    28     instance = test.randomexample() 
     28    instance = test.random_instance() 
    2929    print instance.getclass(), knn(instance) 
  • docs/reference/rst/code/mds-advanced.py

    r9372 r9724  
    1212 
    1313# Construct a distance matrix using Euclidean distance 
    14 dist = Orange.core.ExamplesDistanceConstructor_Euclidean(table) 
     14dist = Orange.distance.Euclidean(table) 
    1515matrix = Orange.core.SymMatrix(len(table)) 
    1616for i in range(len(table)): 
  • docs/reference/rst/code/mds-euclid-torgerson-3d.py

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

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

    r9663 r9724  
    33 
    44from Orange.classification.svm import SVMLearner, kernels 
    5 from Orange.distance import EuclideanConstructor 
    6 from Orange.distance import HammingConstructor 
     5from Orange.distance import Euclidean 
     6from Orange.distance import Hamming 
    77 
    88table = data.Table("iris.tab") 
    99l1 = SVMLearner() 
    10 l1.kernel_func = kernels.RBFKernelWrapper(EuclideanConstructor(table), gamma=0.5) 
     10l1.kernel_func = kernels.RBFKernelWrapper(Euclidean(table), gamma=0.5) 
    1111l1.kernel_type = SVMLearner.Custom 
    1212l1.probability = True 
     
    1515 
    1616l2 = SVMLearner() 
    17 l2.kernel_func = kernels.RBFKernelWrapper(HammingConstructor(table), gamma=0.5) 
     17l2.kernel_func = kernels.RBFKernelWrapper(Hamming(table), gamma=0.5) 
    1818l2.kernel_type = SVMLearner.Custom 
    1919l2.probability = True 
     
    2323l3 = SVMLearner() 
    2424l3.kernel_func = kernels.CompositeKernelWrapper( 
    25     kernels.RBFKernelWrapper(EuclideanConstructor(table), gamma=0.5), 
    26     kernels.RBFKernelWrapper(HammingConstructor(table), gamma=0.5), l=0.5) 
     25    kernels.RBFKernelWrapper(Euclidean(table), gamma=0.5), 
     26    kernels.RBFKernelWrapper(Hamming(table), gamma=0.5), l=0.5) 
    2727l3.kernel_type = SVMLearner.Custom 
    2828l3.probability = True 
  • docs/reference/rst/index.rst

    r9534 r9729  
    66   :maxdepth: 3 
    77 
     8   Orange.data 
     9 
    810   Orange.associate 
    911 
     
    1113 
    1214   Orange.clustering 
    13  
    14    Orange.data 
    1515 
    1616   Orange.distance 
  • install-scripts/createCommonAddOns__.btm

    r8055 r9730  
    1818  echo ************************************* 
    1919  echo *** Compiling Orange Bioinformatics for Python %pyver 
    20   cdd %TMPDIR\add-ons\Bioinformatics 
     20  cdd %TMPDIR\Bioinformatics 
    2121  del /syeq build 
    2222  del /syeq dist 
     
    2828  %PYTHON\python setup.py build -c mingw32 bdist_wininst > %COMPILELOG 
    2929  break_on_error 
    30 rem when compiled:  move /z %TMPDIR\add-ons\Bioinformatics\dist\*.win32-py%npver.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe 
    31   move /z %TMPDIR\add-ons\Bioinformatics\dist\*.win32.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe 
     30rem when compiled:  move /z %TMPDIR\Bioinformatics\dist\*.win32-py%npver.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe 
     31  move /z %TMPDIR\Bioinformatics\dist\*.win32.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe 
    3232 
    3333  REM # publish, add record to stamps_pyd.txt, needed for update from web (accessed by updateFromSVN.bat)   
     
    3535  if not direxist %TMPBINDIR mkdir /s %TMPBINDIR 
    3636   
    37   cdd %TMPDIR\add-ons\Bioinformatics\build\lib.win32-%npver 
     37  cdd %TMPDIR\Bioinformatics\build\lib.win32-%npver 
    3838  for %pydf in (*.pyd) do ( 
    3939    copy %pydf %TMPBINDIR 
     
    4949  echo ************************************* 
    5050  echo *** Compiling TEXT MINING for Python %pyver  
    51   cdd %TMPDIR\add-ons\Text 
     51  cdd %TMPDIR\Text 
    5252  del /syeq build 
    5353  del /syeq dist 
     
    5959  %PYTHON\python setup.py build -c mingw32 bdist_wininst > %COMPILELOG 
    6060  rem break_on_error 
    61   move /z %TMPDIR\add-ons\Text\dist\*.win32-py%npver.exe %TMPDIR\%PKG_TEXT-py%npver.exe 
     61  move /z %TMPDIR\Text\dist\*.win32-py%npver.exe %TMPDIR\%PKG_TEXT-py%npver.exe 
    6262 
    6363  REM # publish, add record to stamps_pyd.txt, needed for update from web (accessed by updateFromSVN.bat)   
     
    6565  if not direxist %TMPBINDIR mkdir /s %TMPBINDIR 
    6666 
    67   cdd %TMPDIR\add-ons\Text\build\lib.win32-%npver 
     67  cdd %TMPDIR\Text\build\lib.win32-%npver 
    6868  for %pydf in (*.pyd) do ( 
    6969    copy %pydf %TMPBINDIR 
  • install-scripts/createSnapshot.btm

    r8976 r9730  
    44 
    55call updateSetVariables__.btm snapshot 
    6 set WIN_SNAPSHOT=orange-win-snapshot-%daystr 
    7 set WIN_PYTHON_SNAPSHOT=orange-win-w-python-snapshot-%daystr 
     6set WIN_SNAPSHOT=orange-win-snapshot-hg-%daystr 
     7set WIN_PYTHON_SNAPSHOT=orange-win-w-python-snapshot-hg-%daystr 
    88set ADDON_BIOINFORMATICS_SNAPSHOT=orangeAddOn-bioinformatics-snapshot-%daystr 
    99set ADDON_TEXT_SNAPSHOT=orangeAddOn-text-snapshot-%daystr 
     
    1212rem # update source(s) to revision HEAD 
    1313cdd %TMPDIR 
    14 svn cleanup 
    15 svn update --ignore-externals 
     14 
     15hg pull --update 
    1616 
    1717rem # build core 
     
    2727rem # if no errors then publish on web (everything at the same time) 
    2828rem # remove any old files 
    29 except (%DOWNLOADDIR\orange*-snapshot-%daystr-*.exe) del %DOWNLOADDIR\orange*-snapshot-????-??-??-*.exe 
     29REM except (%DOWNLOADDIR\orange*-snapshot-%daystr-*.exe) del %DOWNLOADDIR\orange*-snapshot-????-??-??-*.exe 
    3030 
    3131rem # pack sources 
    3232cdd %TMPDIR 
    3333del /syeqtx sourcestopack 
    34 mkdir sourcestopack 
     34 
     35hg archive sourcestopack 
     36 
    3537cd sourcestopack 
    36 svn export --native-eol LF -q http://orange.biolab.si/svn/orange/trunk/orange 
    37 cd orange 
    38 del *.pyd *.dll *.bat 
    39 svn export --native-eol LF -q http://orange.biolab.si/svn/orange/trunk/source  
    40 copy doc\LICENSES . 
    41 copy doc\COPYING . 
    42 copy doc\LICENSES source 
    43 copy doc\COPYING source 
     38 
    4439rem # build source distribution 
    45 e:\Python26\python.exe setup.py sdist  
    46 del %DOWNLOADDIR\orange-source-snapshot-????-??-??.zip 
     40e:\Python27\python.exe setup.py sdist 
     41rem # build msi file 
     42e:\Python27\python.exe setup.py bdist_msi 
     43rem del %DOWNLOADDIR\orange-source-snapshot-????-??-??.zip 
    4744move /z dist\Orange-?.*.zip %DOWNLOADDIR\%SOURCE_SNAPSHOT 
     45move /z dist\Orange-?.*.msi %DOWNLOADDIR\%WIN_SNAPSHOT.msi 
    4846 
    4947rem # publish 
     
    5553rem # remember new filenames 
    5654cdd %SCRIPTDIR 
    57 call updateVersionsPy__.btm 
     55rem # Don't update the visible versions for now 
     56rem call updateVersionsPy__.btm 
  • install-scripts/mac/bundle-daily-build.sh

    r8908 r9731  
    1919    exit 2 
    2020fi 
     21 
     22# Clone hg repo if not yet local. 
     23if [ ! -e orange ]; then 
     24    hg clone https://bitbucket.org/biolab/orange 
     25fi 
     26 
     27cd orange 
     28hg pull --update 
     29 
     30if [ -e ../orange_archive ]; then 
     31    rm -rf ../orange_archive 
     32fi 
     33 
     34hg archive ../orange_archive 
     35cd .. 
     36 
     37ORANGE_REPO=`pwd`/orange 
     38ORANGE_ARCHIVE=`pwd`/orange_archive 
    2139 
    2240# Defaults are current latest revisions in stable branch and trunk 
     
    3250    STABLE_REVISION=$STABLE_REVISION_2 
    3351fi 
    34 DAILY_REVISION_1=${2:-`svn info --non-interactive http://orange.biolab.si/svn/orange/trunk/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`} 
    35 # svn info does not return proper exit status on an error so we check it this way 
    36 [ "$DAILY_REVISION_1" ] || exit 4 
    37 DAILY_REVISION_2=${2:-`svn info --non-interactive http://orange.biolab.si/svn/orange/externals/trunk/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`} 
    38 # svn info does not return proper exit status on an error so we check it this way 
    39 [ "$DAILY_REVISION_2" ] || exit 4 
    40 if [[ $DAILY_REVISION_1 -gt $DAILY_REVISION_2 ]]; then 
    41     DAILY_REVISION=$DAILY_REVISION_1 
    42 else 
    43     DAILY_REVISION=$DAILY_REVISION_2 
    44 fi 
     52 
     53DAILY_REVISION_1 = `hg log -l1 daily | grep 'changeset:' | cut -d ' ' -f 4 | cut -d ':' -f 1` 
     54 
     55#TODO: versions of hg and svn repos are no longer in sync 
     56 
     57#DAILY_REVISION_2=${2:-`svn info --non-interactive http://orange.biolab.si/svn/orange/externals/trunk/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`} 
     58## svn info does not return proper exit status on an error so we check it this way 
     59#[ "$DAILY_REVISION_2" ] || exit 4 
     60#if [[ $DAILY_REVISION_1 -gt $DAILY_REVISION_2 ]]; then 
     61#    DAILY_REVISION=$DAILY_REVISION_1 
     62#else 
     63#    DAILY_REVISION=$DAILY_REVISION_2 
     64#fi 
    4565 
    4666echo "Preparing temporary directory." 
     
    5474export CXXFLAGS="-arch ppc -arch i386" 
    5575export LDFLAGS="-arch ppc -arch i386" 
     76 
     77 
     78########################### 
     79# Stable orange-1.0  bundle 
     80########################### 
    5681 
    5782if [ ! -e /Volumes/download/orange-bundle-1.0b.$STABLE_REVISION.dmg ]; then 
     
    174199/Users/ailabc/mount-dirs.sh 
    175200 
    176 if [ ! -e /Volumes/download/orange-bundle-svn-0.0.$DAILY_REVISION.dmg ]; then 
     201######################### 
     202# Daily orange 2.* bundle 
     203######################### 
     204 
     205if [ ! -e /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ]; then 
    177206    echo "Downloading bundle template." 
    178207    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/externals/trunk/install-scripts/mac/bundle/ /private/tmp/bundle/ 
    179208     
    180     echo "Downloading Orange daily source code revision $DAILY_REVISION." 
    181     svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/orange/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/ 
    182     svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/source/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/source/ 
    183     svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/add-ons/orngCRS/src/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/source/crs/ 
    184      
    185     [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/doc/COPYING ] || svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/COPYING /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/doc/COPYING 
    186     [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/doc/LICENSES ] || svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/LICENSES /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/doc/LICENSES 
    187      
    188     ln -s ../Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/ /private/tmp/bundle/Orange.app/Contents/Resources/orange 
    189     ln -s ../Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/doc/ /private/tmp/bundle/Orange.app/Contents/Resources/doc 
    190      
    191     echo "Compiling." 
    192     cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/source/ 
    193     make EXCLUDE_ORANGEQT=1 
    194     cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/source/crs/ 
    195     make 
    196     mv _orngCRS.so ../../ 
    197     cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/ 
    198      
    199     echo "Correcting install names for modules." 
    200     for module in *.so ; do 
    201         [ -L $module ] && continue 
    202          
    203         install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/$module $module 
    204          
    205         perl -MFile::Spec::Functions=abs2rel -e ' 
    206         for (`/usr/bin/otool -L -X $ARGV[0]`) { 
    207             next unless m|^\s+(/private/tmp/bundle/Orange.app/.*) \(.*\)$|; 
    208             system("/usr/bin/install_name_tool", "-change", $1, "\@loader_path/" . abs2rel($1), $ARGV[0]);  
    209         } 
    210         ' $module 
    211     done 
    212      
    213     echo "Cleaning up." 
    214     rm -rf source/ c45.dll liborange_include.a updateOrange.py 
     209    echo "Building and installing orange into the bundle." 
     210    cd $ORANGE_ARCHIVE 
     211    /private/tmp/bundle/Orange.app/Contents/MacOS/python setup.py install 
     212         
     213#   echo "Correcting install names for modules." 
     214#   for module in *.so ; do 
     215#       [ -L $module ] && continue 
     216#        
     217#       install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/$module $module 
     218#        
     219#       perl -MFile::Spec::Functions=abs2rel -e ' 
     220#       for (`/usr/bin/otool -L -X $ARGV[0]`) { 
     221#           next unless m|^\s+(/private/tmp/bundle/Orange.app/.*) \(.*\)$|; 
     222#           system("/usr/bin/install_name_tool", "-change", $1, "\@loader_path/" . abs2rel($1), $ARGV[0]);  
     223#       } 
     224#       ' $module 
     225#   done 
     226     
     227#   echo "Cleaning up." 
     228#   rm -rf source/ c45.dll liborange_include.a updateOrange.py 
    215229     
    216230    # Installation registration 
    217     echo "orange" > /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange.pth 
    218      
     231#   echo "orange" > /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange.pth 
     232     
     233    # TODO: hg repos for addons 
    219234    for addon in $DAILY_ADDONS ; do 
    220235        echo "Downloading Orange add-on $addon daily source code revision $DAILY_REVISION." 
     
    245260        fi 
    246261         
    247         echo "Cleaning up." 
    248         rm -rf source/ setup.py 
     262#       echo "Cleaning up." 
     263#       rm -rf source/ setup.py 
    249264         
    250265        # Installation registration 
     
    282297     
    283298    echo "Converting temporary image to a compressed image." 
    284     rm -f /private/tmp/orange-bundle-svn-0.0.$DAILY_REVISION.dmg 
    285     hdiutil convert /private/tmp/bundle.dmg -format UDZO -imagekey zlib-level=9 -o /private/tmp/orange-bundle-svn-0.0.$DAILY_REVISION.dmg 
     299    rm -f /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg 
     300    hdiutil convert /private/tmp/bundle.dmg -format UDZO -imagekey zlib-level=9 -o /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg 
    286301     
    287302    echo "Cleaning up." 
     
    295310echo "Removing old versions of bundles." 
    296311# (Keeps last 5 versions.) 
    297 perl -e 'unlink ((reverse sort </Volumes/download/orange-bundle-svn-0*.dmg>)[5..10000])' 
     312perl -e 'unlink ((reverse sort </Volumes/download/orange-bundle-hg-0*.dmg>)[5..10000])' 
    298313perl -e 'unlink ((reverse sort </Volumes/download/orange-bundle-1*.dmg>)[5..10000])' 
    299314 
    300 if [ -e /private/tmp/orange-bundle-svn-0.0.$DAILY_REVISION.dmg ] || [ -e /private/tmp/orange-bundle-svn-0.0.$DAILY_REVISION.dmg ]; then 
     315if [ -e /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ] || [ -e /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ]; then 
    301316    echo "Moving bundles to the download directory." 
    302317    [ -e /private/tmp/orange-bundle-1.0b.$STABLE_REVISION.dmg ] && mv /private/tmp/orange-bundle-1.0b.$STABLE_REVISION.dmg /Volumes/download/ 
    303     [ -e /private/tmp/orange-bundle-svn-0.0.$DAILY_REVISION.dmg ] && mv /private/tmp/orange-bundle-svn-0.0.$DAILY_REVISION.dmg /Volumes/download/ 
     318    [ -e /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ] && mv /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg /Volumes/download/ 
    304319     
    305320    echo "Setting permissions." 
    306321    chmod +r /Volumes/download/orange-bundle-1.0b.$STABLE_REVISION.dmg 
    307     chmod +r /Volumes/download/orange-bundle-svn-0.0.$DAILY_REVISION.dmg 
    308      
    309     echo "Registering new bundles." 
    310     egrep -v '^(MAC_STABLE|MAC_DAILY)=' /Volumes/download/filenames_mac.set > /Volumes/download/filenames_mac.set.new 
    311     echo "MAC_STABLE=orange-bundle-1.0b.$STABLE_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new 
    312     echo "MAC_DAILY=orange-bundle-svn-0.0.$DAILY_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new 
    313     mv /Volumes/download/filenames_mac.set.new /Volumes/download/filenames_mac.set 
    314 fi 
     322    chmod +r /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg 
     323 
     324# Don't register the bundles until hg version stabilizes 
     325     
     326#   echo "Registering new bundles." 
     327#   egrep -v '^(MAC_STABLE|MAC_DAILY)=' /Volumes/download/filenames_mac.set > /Volumes/download/filenames_mac.set.new 
     328#   echo "MAC_STABLE=orange-bundle-1.0b.$STABLE_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new 
     329#   echo "MAC_DAILY=orange-bundle-svn-0.0.$DAILY_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new 
     330#   mv /Volumes/download/filenames_mac.set.new /Volumes/download/filenames_mac.set 
     331fi 
  • install-scripts/mac/update-all-scripts.sh

    r7694 r9731  
    44# 
    55 
    6 curl --silent --output update-all-scripts.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/update-all-scripts.sh 
    7 curl --silent --output bundle-64bit-daily-build.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/bundle-64bit-daily-build.sh 
    8 curl --silent --output bundle-daily-build.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/bundle-daily-build.sh 
    9 curl --silent --output dailyrun.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/dailyrun.sh 
    10 curl --silent --output dailyrun-finkonly-withsource.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/dailyrun-finkonly-withsource.sh 
    11 curl --silent --output dailyrun-finkonly.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/dailyrun-finkonly.sh 
    12 curl --silent --output dailyrun-bundleonly.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/dailyrun-bundleonly.sh 
    13 curl --silent --output fink-daily-build.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/fink-daily-build.sh 
    14 curl --silent --output fink-restore-selections.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/fink-restore-selections.sh 
    15 curl --silent --output fink-selfupdate-orange.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/fink-selfupdate-orange.sh 
    16 curl --silent --output force-fink-daily-build.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/force-fink-daily-build.sh 
    17 curl --silent --output mount-dirs.sh http://orange.biolab.si/svn/orange/trunk/install-scripts/mac/mount-dirs.sh 
     6# Clone the orange repo if not already present 
     7if [ ! -e orange ]; then 
     8    hg clone https://bitbucket.org/biolab/orange 
     9fi 
     10 
     11# Pull all changesets and update to latest 
     12cd orange 
     13hg pull --update 
     14cd .. 
     15 
     16cp orange/install-scripts/mac/update-all-scripts.sh ./ 
     17cp orange/install-scripts/mac/bundle-64bit-daily-build.sh ./ 
     18cp orange/install-scripts/mac/bundle-daily-build.sh ./ 
     19cp orange/install-scripts/mac/dailyrun.sh ./ 
     20cp orange/install-scripts/mac/dailyrun-finkonly-withsource.sh ./ 
     21cp orange/install-scripts/mac/dailyrun-finkonly.sh ./ 
     22cp orange/install-scripts/mac/dailyrun-bundleonly.sh ./ 
     23cp orange/install-scripts/mac/fink-daily-build.sh ./ 
     24cp orange/install-scripts/mac/fink-restore-selections.sh ./ 
     25cp orange/install-scripts/mac/fink-selfupdate-orange.sh ./ 
     26cp orange/install-scripts/mac/force-fink-daily-build.sh ./ 
     27cp orange/install-scripts/mac/mount-dirs.sh ./ 
    1828 
    1929chmod +x *.sh 
  • install-scripts/updateAndCall.btm

    r7692 r9730  
    1 net use o: \\ailab.si\download 
     1 
    22cdd e:\orange\scripts 
    3 svn update -N 
    4 svn export http://orange.biolab.si/svn/orange/trunk/orange/doc/LICENSES license.txt 
    5 svn  
     3 
     4 
     5REM # Until orange-install-scripts repo is up this does not yet run 
     6REM hg clone https://bitbucket.org/biolab/orange-install-scripts . 
     7REM hg pull --update  
     8 
     9REM hg clone https://bitbucket.org/biolab/orange snapshot 
     10cdd snapshot 
     11hg pull --update 
     12 
     13REM hg clone https://bitbucket.org/biolab/orange-addon-bioinformatics Bioinformatics 
     14cdd Bioinformatics 
     15hg pull --update 
     16 
     17cdd  e:\orange\scripts\snapshot 
     18 
     19REM hg clone https://bitbucket.org/biolab/orange-addon-text Text 
     20cdd Text 
     21hg pull --update 
     22 
     23cdd e:\orange\scripts 
     24 
     25copy /r snapshot\install-scripts\* . 
     26 
     27#svn update -N 
     28#svn export http://orange.biolab.si/svn/orange/trunk/orange/doc/LICENSES license.txt 
     29#svn 
     30  
    631call callCreateSnapshot.btm 
    732shutdown -s 
  • install-scripts/updateSetVariables__.btm

    r8739 r9730  
    77set SCRIPTDIR=%_CWD 
    88set TMPDIR=%SCRIPTDIR\%1 
     9set SOURCEDIR=%TMPDIR\source 
    910set DOWNLOADDIR=Z:\Volumes\download\ 
    1011 
Note: See TracChangeset for help on using the changeset viewer.