Changeset 9704:4eaf240118e8 in orange


Ignore:
Timestamp:
02/06/12 13:17:53 (2 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Children:
9705:47fb0f1ff655, 9726:aec7c15289d3
rebase_source:
8ff3f1297fc151f8f466be0e18a9ec556d003fdb
Message:

Finished polishing documentation about Domain

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/Orange.data.domain.rst

    r9678 r9704  
    228228 
    229229         List of domain attributes 
    230          (:obj:`Orange.data.variable.Variables`) without the class 
     230         (of type :obj:`Orange.data.variable.Variables`) without the class 
    231231         variable. Read only. 
    232232 
    233233     .. attribute:: variables 
    234234 
    235      List of domain attributes 
    236      (:obj:`~Orange.data.variable.Variables`) including the class 
    237      variable. Read only. 
     235         List of domain attributes including the class variable. Read only. 
    238236 
    239237     .. attribute:: class_var 
    240238 
    241      The class variable (:obj:`~Orange.data.variable.Variable`), or 
    242      :obj:`None` if there is none. Read only. 
     239         The class variable (:obj:`~Orange.data.variable.Variable`) or 
     240         ``None``. Read only. 
    243241 
    244242     .. attribute:: class_vars 
    245243 
    246      A list of additional class attributes. Read only. 
     244         A list of additional class attributes. Read only. 
    247245 
    248246     .. attribute:: version 
    249247 
    250      An integer value that is changed when the domain is 
    251      modified. The value can be also used as unique domain identifier; two 
    252      different domains have different value of ``version``. 
     248         An integer value that is changed when the domain is 
     249         modified. The value can be also used as unique domain identifier; two 
     250         different domains have different value of ``version``. 
    253251 
    254252     .. method:: __init__(variables[, class_vars=]) 
    255253 
    256      Construct a domain with the given variables; the 
    257      last one is used as the class variable. :: 
    258  
    259          >>> a, b, c = [Orange.data.variable.Discrete(x) for x in "abc"] 
    260          >>> domain = Orange.data.Domain([a, b, c]) 
    261          >>> domain.features 
    262          <EnumVariable 'a', EnumVariable 'b'> 
    263          >>> domain.class_var 
    264          EnumVariable 'c' 
    265  
    266      :param variables: List of variables (instances of :obj:`~Orange.data.variable.Variable`) 
    267      :type variables: list 
    268      :param class_vars: A list of multiple classes; must be a keword argument 
    269      :type class_vars: list 
     254         Construct a domain with the given variables; the 
     255         last one is used as the class variable. :: 
     256 
     257             >>> a, b, c = [Orange.data.variable.Discrete(x) for x in "abc"] 
     258             >>> domain = Orange.data.Domain([a, b, c]) 
     259             >>> domain.features 
     260             <EnumVariable 'a', EnumVariable 'b'> 
     261             >>> domain.class_var 
     262             EnumVariable 'c' 
     263 
     264         :param variables: List of variables (instances of :obj:`~Orange.data.variable.Variable`) 
     265         :type variables: list 
     266         :param class_vars: A list of multiple classes; must be a keword argument 
     267         :type class_vars: list 
    270268 
    271269     .. method:: __init__(features, class_variable[, class_vars=]) 
    272270 
    273      Construct a domain with the given list of features and the 
    274      class variable. :: 
    275  
    276          >>> domain = Orange.data.Domain([a, b], c) 
    277          >>> domain.features 
    278          <EnumVariable 'a', EnumVariable 'b'> 
    279          >>> domain.class_var 
    280          EnumVariable 'c' 
    281  
    282      :param features: List of features (instances of :obj:`~Orange.data.variable.Variable`) 
    283      :type features: list 
    284      :param class_variable: Class variable 
    285      :type class_variable: Orange.data.variable.Variable 
    286      :param class_vars: A list of multiple classes; must be a keyword argument 
    287      :type class_vars: list 
     271         Construct a domain with the given list of features and the 
     272         class variable. :: 
     273 
     274             >>> domain = Orange.data.Domain([a, b], c) 
     275             >>> domain.features 
     276             <EnumVariable 'a', EnumVariable 'b'> 
     277             >>> domain.class_var 
     278             EnumVariable 'c' 
     279 
     280         :param features: List of features (instances of :obj:`~Orange.data.variable.Variable`) 
     281         :type features: list 
     282         :param class_variable: Class variable 
     283         :type class_variable: Orange.data.variable.Variable 
     284         :param class_vars: A list of multiple classes; must be a keyword argument 
     285         :type class_vars: list 
    288286 
    289287     .. method:: __init__(variables, has_class[, class_vars=]) 
    290288 
    291      Construct a domain with the given variables. If `has_class` is 
    292      :obj:`True`, the last one is used as the class variable. :: 
    293  
    294          >>> domain = Orange.data.Domain([a, b, c], False) 
    295          >>> domain.features 
    296          <EnumVariable 'a', EnumVariable 'b'> 
    297          >>> domain.class_var 
    298          EnumVariable 'c' 
    299  
    300      :param variables: List of variables (instances of :obj:`~Orange.data.variable.Variable`) 
    301      :type features: list 
    302      :param has_class: A flag telling whether the domain has a class 
    303      :type has_class: bool 
    304      :param class_vars: A list of multiple classes; must be a keyword argument 
    305      :type class_vars: list 
     289         Construct a domain with the given variables. If ``has_class`` 
     290         is ``True``, the last variable is the class. :: 
     291 
     292             >>> domain = Orange.data.Domain([a, b, c], False) 
     293             >>> domain.features 
     294             <EnumVariable 'a', EnumVariable 'b'> 
     295             >>> domain.class_var 
     296             EnumVariable 'c' 
     297 
     298         :param variables: List of variables (instances of :obj:`~Orange.data.variable.Variable`) 
     299         :type features: list 
     300         :param has_class: A flag telling whether the domain has a class 
     301         :type has_class: bool 
     302         :param class_vars: A list of multiple classes; must be a keyword argument 
     303         :type class_vars: list 
    306304 
    307305     .. method:: __init__(variables, source[, class_vars=]) 
    308306 
    309      Construct a domain with the given variables that can also be 
    310      specified by names if the variables with that names exist in the 
    311      source list. The last variable from the list is used as the class 
    312      variable. :: 
    313  
    314          >>> domain1 = orange.Domain([a, b]) 
    315          >>> domain2 = orange.Domain(["a", b, c], domain) 
    316  
    317      :param variables: List of variables (strings or instances of :obj:`~Orange.data.variable.Variable`) 
    318      :type variables: list 
    319      :param source: An existing domain or a list of variables 
    320      :type source: Orange.data.Domain or list of :obj:`~Orange.data.variable.Variable` 
    321      :param class_vars: A list of multiple classes; must be a keyword argument 
    322      :type class_vars: list 
     307         Construct a domain with the given variables. Variables specified 
     308         by names are sought for in the ``source`` argument. The last 
     309         variable from the list is used as the class variable. :: 
     310 
     311             >>> domain1 = orange.Domain([a, b]) 
     312             >>> domain2 = orange.Domain(["a", b, c], domain) 
     313 
     314         :param variables: List of variables (strings or instances of :obj:`~Orange.data.variable.Variable`) 
     315         :type variables: list 
     316         :param source: An existing domain or a list of variables 
     317         :type source: Orange.data.Domain or list of :obj:`~Orange.data.variable.Variable` 
     318         :param class_vars: A list of multiple classes; must be a keyword argument 
     319         :type class_vars: list 
    323320 
    324321     .. method:: __init__(variables, has_class, source[, class_vars=]) 
    325322 
    326      Similar to above except for the flag which tells whether the 
    327      last variable should be used as the class variable. :: 
    328  
    329          >>> domain1 = orange.Domain([a, b], False) 
    330          >>> domain2 = orange.Domain(["a", b, c], False, domain) 
    331  
    332      :param variables: List of variables (strings or instances of :obj:`~Orange.data.variable.Variable`) 
    333      :type variables: list 
    334      :param has_class: A flag telling whether the domain has a class 
    335      :type has_class: bool 
    336      :param source: An existing domain or a list of variables 
    337      :type source: Orange.data.Domain or list of :obj:`~Orange.data.variable.Variable` 
    338      :param class_vars: A list of multiple classes; must be a keyword argument 
    339      :type class_vars: list 
     323         Similar to above except for the flag which tells whether the 
     324         last variable should be used as the class variable. :: 
     325 
     326             >>> domain1 = orange.Domain([a, b], False) 
     327             >>> domain2 = orange.Domain(["a", b, c], False, domain) 
     328 
     329         :param variables: List of variables (strings or instances of :obj:`~Orange.data.variable.Variable`) 
     330         :type variables: list 
     331         :param has_class: A flag telling whether the domain has a class 
     332         :type has_class: bool 
     333         :param source: An existing domain or a list of variables 
     334         :type source: Orange.data.Domain or list of :obj:`~Orange.data.variable.Variable` 
     335         :param class_vars: A list of multiple classes; must be a keyword argument 
     336         :type class_vars: list 
    340337 
    341338     .. method:: __init__(domain, class_var[, class_vars=]) 
    342339 
    343      Construct a copy of an existing domain 
    344      except that the class variable is replaced with the given one 
    345      and the class variable of the existing domain becomes an 
    346      ordinary feature. If the new class is one of the original 
    347      domain's features, it can also be specified by a name. 
    348  
    349      :param domain: An existing domain 
    350      :type domain: :obj:`~Orange.variable.Domain` 
    351      :param class_var: Class variable for the new domain 
    352      :type class_var: string or :obj:`~Orange.data.variable.Variable` 
    353      :param class_vars: A list of multiple classes; must be a keyword argument 
    354      :type class_vars: list 
     340         Construct a copy of an existing domain except that the class 
     341         variable is replaced with the one specified in the argument 
     342         and the class variable of the existing domain becomes an 
     343         ordinary feature. If the new class is one of the original 
     344         domain's features, ``class_var`` can also be specified by name. 
     345 
     346         :param domain: An existing domain 
     347         :type domain: :obj:`~Orange.variable.Domain` 
     348         :param class_var: Class variable for the new domain 
     349         :type class_var: :obj:`~Orange.data.variable.Variable` or string 
     350         :param class_vars: A list of multiple classes; must be a keyword argument 
     351         :type class_vars: list 
    355352 
    356353     .. method:: __init__(domain, has_class=False[, class_vars=]) 
    357354 
    358      Construct a copy of the domain. If the ``has_class`` 
    359      flag is given and is :obj:`False`, it moves the class 
    360      attribute to ordinary features. 
    361  
    362      :param domain: An existing domain 
    363      :type domain: :obj:`~Orange.variable.Domain` 
    364      :param has_class: A flag telling whether the domain has a class 
    365      :type has_class: bool 
    366      :param class_vars: A list of multiple classes; must be a keword argument 
    367      :type class_vars: list 
     355         Construct a copy of the domain. If the ``has_class`` 
     356         flag is given and is :obj:`False`, the class attribute becomes 
     357         an ordinary feature. 
     358 
     359         :param domain: An existing domain 
     360         :type domain: :obj:`~Orange.variable.Domain` 
     361         :param has_class: A flag indicating whether the domain will have a class 
     362         :type has_class: bool 
     363         :param class_vars: A list of multiple classes; must be a keword argument 
     364         :type class_vars: list 
    368365 
    369366     .. method:: has_discrete_attributes(include_class=True) 
    370367 
    371      Return :obj:`True` if the domain has any discrete variables; 
    372      class is included unless ``include_class`` is ``False``. 
    373  
    374      :param has_class: Tells whether to consider the class variable 
    375      :type has_class: bool 
    376      :rtype: bool 
     368         Return ``True`` if the domain has any discrete variables; 
     369         class is included unless ``include_class`` is ``False``. 
     370 
     371         :param has_class: tells whether to consider the class variable 
     372         :type has_class: bool 
     373         :rtype: bool 
    377374 
    378375     .. method:: has_continuous_attributes(include_class=True) 
    379376 
    380      Return :obj:`True` if the domain has any continuous variables; 
    381      class is included unless ``include_class`` is ``False``. 
    382  
    383      :param has_class: Tells whether to consider the class variable 
    384      :type has_class: bool 
    385      :rtype: bool 
     377         Return ``True`` if the domain has any continuous variables; 
     378         class is included unless ``include_class`` is ``False``. 
     379 
     380         :param has_class: tells whether to consider the class variable 
     381         :type has_class: bool 
     382         :rtype: bool 
    386383 
    387384     .. method:: has_other_attributes(include_class=True) 
    388385 
    389      Return :obj:`True` if the domain has any variables which are 
    390      neither discrete nor continuous, such as, for instance string variables. 
    391      class is included unless ``include_class`` is ``False``. 
    392  
    393      :param has_class: Tells whether to consider the class variable 
    394      :type has_class: bool 
    395      :rtype: bool 
     386         Return ``True`` if the domain has any variables that are 
     387         neither discrete nor continuous, such as, for instance string 
     388         variables. The class is included unless ``include_class`` is 
     389         ``False``. 
     390 
     391         :param has_class: tells whether to consider the class variable 
     392         :type has_class: bool 
     393         :rtype: bool 
    396394 
    397395 
    398396     .. method:: add_meta(id, variable, optional=0) 
    399397 
    400      Register a meta attribute with the given id (obtained by 
    401      :obj:`Orange.data.new_meta_id`). The same meta attribute should 
    402      have the same id in all domain in which it is registered. :: 
    403  
    404          >>> newid = Orange.data.new_meta_id() 
    405          >>> domain.add_meta(newid, Orange.data.variable.String("origin")) 
    406          >>> data[55]["origin"] = "Nepal" 
    407          >>> data[55] 
    408          ['1', '0', '0', '1', '0', '0', '0', '1', '1', '1', '0', '0', 
    409          '4', '1', '0', '1', 'mammal'], {"name":'oryx', "origin":'Nepal'} 
    410  
    411      The third argument tells whether the meta attribute is optional or 
    412      not. The parameter is an integer, with any non-zero value meaning that 
    413      the attribute is optional. Different values can be used to distinguish 
    414      between various types optional attributes; the meaning of the value 
    415      is not defined in advance and can be used arbitrarily by the 
    416      application. 
    417  
    418      :param id: id of the new meta attribute 
    419      :type id: int 
    420      :param variable: variable descriptor 
    421      :type variable: Orange.data.variable.Variable 
    422      :param optional: tells whether the meta attribute is optional 
    423      :type optional: int 
     398         Register a meta attribute with the given id (see 
     399         :obj:`Orange.data.new_meta_id`). The same meta attribute should 
     400         have the same id in all domains in which it is registered. :: 
     401 
     402             >>> newid = Orange.data.new_meta_id() 
     403             >>> domain.add_meta(newid, Orange.data.variable.String("origin")) 
     404             >>> data[55]["origin"] = "Nepal" 
     405             >>> data[55] 
     406             ['1', '0', '0', '1', '0', '0', '0', '1', '1', '1', '0', '0', 
     407             '4', '1', '0', '1', 'mammal'], {"name":'oryx', "origin":'Nepal'} 
     408 
     409         The third argument tells whether the meta attribute is optional or 
     410         not; non-zero values indicate optional attributes. Different 
     411         values can be used to distinguish between various types 
     412         optional attributes; the meaning of the value is not defined in 
     413         advance and can be used arbitrarily by the application. 
     414 
     415         :param id: id of the new meta attribute 
     416         :type id: int 
     417         :param variable: variable descriptor 
     418         :type variable: Orange.data.variable.Variable 
     419         :param optional: indicates whether the meta attribute is optional 
     420         :type optional: int 
    424421 
    425422     .. method:: add_metas(attributes, optional=0) 
    426423 
    427      Add multiple meta attributes at once. The dictionary contains id's as 
    428      keys and variables (:obj:~Orange.data.variable as the corresponding 
    429      values. The following example shows how to add all meta attributes 
    430      from one domain to another:: 
    431  
    432           newdomain.add_metas(domain.get_metas()) 
    433  
    434      The optional second argument has the same meaning as in :obj:`add_meta`. 
    435  
    436      :param attributes: dictionary of id's and variables 
    437      :type attributes: dict 
    438      :param optional: tells whether the meta attribute is optional 
    439      :type optional: int 
     424         Add multiple meta attributes at once. The dictionary contains id's as 
     425         keys and variables (:obj:`~Orange.data.variable.Variable`) as the 
     426         corresponding values. The following example shows how to add all 
     427          meta attributes from another domain:: 
     428 
     429              >>> newdomain.add_metas(domain.get_metas()) 
     430 
     431         The optional second argument has the same meaning as in :obj:`add_meta`. 
     432 
     433         :param attributes: dictionary of id's and variables 
     434         :type attributes: dict 
     435         :param optional: tells whether the meta attribute is optional 
     436         :type optional: int 
    440437 
    441438     .. method:: remove_meta(attribute) 
    442439 
    443      Removes one or multiple meta attributes. Removing a meta attribute has 
    444      no effect on data instances. 
    445  
    446      :param attribute: attribute(s) to be removed, given as name, id, variable descriptor or a list of them 
    447      :type attribute: string, int, Orange.data.variable.Variable; or a list 
     440         Removes one or multiple meta attributes. Removing a meta attribute has 
     441         no effect on data instances. 
     442 
     443         :param attribute: attribute(s) to be removed, given as name, id, variable descriptor or a list of them 
     444         :type attribute: string, int, Orange.data.variable.Variable; or a list 
    448445 
    449446     .. method:: has_attribute(attribute) 
    450447 
    451      Return True if the domain contains the specified meta attribute. 
    452  
    453      :param attribute: attribute to be checked 
    454      :type attribute: string, int, Orange.data.variable.Variable 
    455      :rtype: bool 
     448         Return ``True`` if the domain contains the specified meta 
     449         attribute. 
     450 
     451         :param attribute: attribute to be checked 
     452         :type attribute: string, int, Orange.data.variable.Variable 
     453         :rtype: bool 
    456454 
    457455     .. method:: meta_id(attribute) 
    458456 
    459      Return an id of a meta attribute. 
    460  
    461      :param attribute: name or variable descriptor of the attribute 
    462      :type attribute: string or Orange.data.variable.Variable 
    463      :rtype: int 
     457         Return an id of a meta attribute. 
     458 
     459         :param attribute: name or variable descriptor of the attribute 
     460         :type attribute: string or Orange.data.variable.Variable 
     461         :rtype: int 
    464462 
    465463     .. method:: get_meta(attribute) 
    466464 
    467      Return a variable descriptor corresponding to the meta attribute. 
    468  
    469      :param attribute: name or id of the attribute 
    470      :type attribute: string or int 
    471      :rtype: Orange.data.variable.Variable 
     465         Return a variable descriptor corresponding to the meta attribute. 
     466 
     467         :param attribute: name or id of the attribute 
     468         :type attribute: string or int 
     469         :rtype: Orange.data.variable.Variable 
    472470 
    473471     .. method:: get_metas() 
    474472 
    475       Return a dictionary with meta attribute id's as keys and corresponding 
    476       variable descriptors as values. 
     473          Return a dictionary with meta attribute id's as keys and 
     474          corresponding variable descriptors as values. 
    477475 
    478476     .. method:: get_metas(optional) 
    479477 
    480       Return a dictionary with meta attribute id's as keys and corresponding 
    481       variable descriptors as values. The dictionary contains only meta 
    482       attributes for which the argument ``optional`` matches the flag given 
    483       when the attributes were added using :obj:`add_meta` or :obj:`add_metas`. 
    484  
    485       :param optional: flag that specifies the attributes to be returned 
    486       :type optional: int 
    487       :rtype: dict 
     478          Return a dictionary with meta attribute id's as keys and 
     479          corresponding variable descriptors as values. The dictionary 
     480          contains only meta attributes for which the argument ``optional`` 
     481          matches the flag given when the attributes were added using 
     482          :obj:`add_meta` or :obj:`add_metas`. 
     483 
     484          :param optional: flag that specifies the attributes to be returned 
     485          :type optional: int 
     486          :rtype: dict 
    488487 
    489488     .. method:: is_optional_meta(attribute) 
    490489 
    491      Return True if the given meta attribute is optional, and False if it is 
    492      not. 
    493  
    494      :param attribute: attribute to be checked 
    495      :type attribute: string, int, Orange.data.variable.Variable 
    496      :rtype: bool 
     490         Return ``True`` if the given meta attribute is optional, 
     491         and ``False`` if it is not. 
     492 
     493         :param attribute: attribute to be checked 
     494         :type attribute: string, int, Orange.data.variable.Variable 
     495         :rtype: bool 
Note: See TracChangeset for help on using the changeset viewer.