COMMAND(1)

NAME
attr - describes the attribute file format for the IND family of programs

SYNOPSIS
A "stem.attr" file informs the IND programs about the data set.

DESCRIPTION

Overview

The attribute file (usually a file ending in ".attr") contains a series of attribute descriptions that guide IND's processing of examples. The examples themselves are not stored in the ".attr" file. The corpus of all examples available for the domain is usually stored in a file ending with ".dta", or in encoded form in a file ending with ".enc". Other file endings are used by IND to signify the type of data file, the type of classifier or intermediate file, etc.

As an example, consider the hypothyroid database in directory /IND/Data/thyroid. The file "hypo.attr" describes each attribute (including the class attribute) for the thyroid database. Each line in the "hypo.attr" describes one or more attributes. Attribute descriptions include the attribute name, attribute type, and allowable attribute values. The file "hypo.dta.Z" is a compressed version of all of the thyroid examples. Each line in the uncompressed version of this file is a single example containing a classification and a sequence of attribute values (in the order they are described in "hypo.attr"). enc is used to encode this data file into an encoded file, "hypo.enc" which can them be sampled online by encsmpl, tgen, tclass and mktree, etc. Alternatively, you can use your own sampling routine to create a training set "hypo.bld" and possibly a test set "hypo.tst" in the same format as "hypo.dta", and with the -e option these routines will use your samples. Other IND routines then build trees using the attribute descriptions in "hypo.attr" and either the examples in "hypo.bld" or a sampled selection from "hypo.enc" and place these in "hypo.treec" (a counts tree) or "hypo.tree" (a class propability tree).

Attributes and Examples in More Detail

The attribute file contains a series of attribute descriptions separated by white space (space, tab, newline). Each attribute description contains a white space separated list of attribute names, followed by a colon, followed by a description of the type, followed by some qualifiers in brackets, and terminated with a full-stop (i.e., ".<CR>"). Any identifiers such as attribute names or attribute value names must be composed of letters, digits or the symbols "_-/.". The symbols "./\" cannot appear in the first or last positions. For discrete attributes, the type description is a comma-separated list of attribute value names. If the value name '?' is given then it implies that further values should be determined from the data file itself. For continuous attributes, the type description is a continuous type, cont, step, norm, followed by a range specifying the minimum and maximum value the attribute can take, represented as min .. max, or as "?" if you want the bounds determined from the data, or nothing if you don't care about bounding the value.

The decision attribute must have the name "class", or have "(class)" added to the end of its description. The qualifiers "?" indicates the attribute has missing values.

  attribute-line   ::==     name-list ':' type
            [ '(' qual-list ')' ] '.'
  name-list ::== < space separated list of names >
  type   ::==    value-list  | cont | cont min '..' max |
            cont '?' | 'asfor' name
  value-list ::== < comma separated list of values >
  qual-list ::== qualifier | qualifer ',' qual-list
  qualifer ::== '?' | 'class' | 'subset=full' |
            'subset=one'

The attribute file may have an optional contexts specification following attribute descriptions. Contexts are used to constrain the shape of the tree that can be generated by tgen. Contexts can also be used to prevent an attribute from ever appearing in a tree (using the form "never").

A context specification consists of the word "contexts" followed by a colon then a sequence of context descriptions for attributes. A context description is constructed from the following grammar:

  context ::==    attribute-name "never" "."  |
        attribute-name "onlyif" test "."
  test ::==    atom  |
        atom "and" ... atom
  atom  ::==    attribute-name  |
        attribute-name "=" attribute-value

These indicate that an attribute should be tested "never" or only if a certain condition holds. The test consisting of an attribute name alone holds if the attribute has itself been tested further up in the decision tree. The equality test only applies to discrete attributes. An attribute is "in context" if the context condition holds, and it can only be tested at a given node in the tree if it is in context.

The attribute file may have an optional utilities specification. This specifies the utility "u(c,d)" of predicting class "c" when the true class is "d". A higher utility is better, and utility can sometimes be measured in units like dollars. The utility is specified by a matrix of comma delimited real values with each block delimited by semi-colons. An example specification for the three class case is:
   utilities : 100, 10, 10; 20, 50, 20; 10, 10, 100.
This means u(1,1) = 100, u(1,2)=10, u(2,1)=20, u(2,2)=50, etc. Utilities are taken into account by the tclass programs when calculating the best decision, and by tgen and tprune when pruning a tree. The default utility is "minimum errors", or a matrix with 1's on the diagonal and 0's elsewhere. This makes all errors of equal importance.

Finally, the attribute file may have an optional prior specification. This takes the form like:
   prior : "-d 6 -Anonsym,1" .
The string in quotes is processed like command line options by tgen during tree generation, but is ignored by other routines which by default use the prior details from the tree header they read in. Only options -d, -A, -P and -N will be processed. Notice these options override any passed through the command line interface so use this feature with caution.

The attribute file is parsed with a yacc-generated parser, so does limited error reporting. Anything following a "|" on a line is treated as comment and is ignored.

An example attribute file is shown below.

class : compensated_hypothyroid,negative,
        primary_hypothyroid,secondary_hypothyroid.
age: cont 0..100.
sex: M,F,?.
on_thyroxine query_on_thyroxine on_antithyroid_medication
            query_hypothyroid query_hyperthyroid: f,t.
lithium goitre tumor hypopituitary psych: f,t.
TSH_measured: f,t.
TSH: cont 0..600 (?). | missing values
T3_measured: asfor TSH_measured. | same as TSH_measured
T3: cont 0..100 (?).
TT4_measured: asfor TSH_measured.
TT4: cont. | dont care about ranges
TBG_measured: asfor TSH_measured.
TBG: cont 0..100 (?).
referral_source: SVI,STMW,WEST,SVHC,
                  SVHD,other (subset=full).
prior : "-d8 -Anonsym,1" .
contexts : TBG onlyif TBG_measured = t .
            on_thyroxine never.

The contexts here mean that the attribute "on_thyroxine" should never be tested, the attribute "TBG" should only be tested if "TBG_measured" has been tested previously to be "t".

The example file contains input data matching the attribute description given in the attribute file. Fields are separated by tabs or spaces. No line can be longer than 2000 characters. Below is an example of an input line matching the "hypo.attr" attribute descriptions. Note that every entry in the file must contain a single example. In particular, this means that there cannot be any blank lines at the end of the file

   negative 73 F f f f f f f f f f f t 2.4 t 2 t 119 f ? SVI

Other sample attribute files and examples databases can be found in "/IND/Data".

LIMITS

Currently, the class cannot have more the 127 values. If there are more than 30 values then you probably need to decompose the problem into a hierarchical one. The attributes cannot have more than 254 values, and sets cannot have more than 31 elements.

The maximum number of attributes is 254. Again, if the problem has more than this, and they're all considered "possibly useful", then the problem probably needs a different non-tree system. However, by changing the constant MAXATTRS and recompilation, this limit can be modified.

Lines in the data file should be no longer than 2000 characters.

SEE ALSO
mktree(1), tgen(1). tclass(1).