|
|
| Data_File_ARFF (std::string fileName) |
| | constructs an (unloaded) reader for fileName; call prepareFile() to actually read it
|
| bool | prepareFile () |
| | Reads and parses the whole .arff file: the header (@RELATION/@ATTRIBUTE lines) then every @DATA row. Columns of an unsupported type (STRING, DATE, or any other non-numeric/non-nominal type) are skipped gracefully with a loud per-column message; a malformed @ATTRIBUTE definition is still a hard failure. Loading only hard-fails on unsupported columns if NONE of them turn out loadable (every column skipped).
|
| void | sortRecordsByClass () |
| | Reorders data in place, grouping records by class id (bucket sort over classCount buckets, then concatenated in class order).
|
| unsigned int | getNoOfClasses () |
| | Number of classes, i.e. the CLASS attribute's value count.
|
|
unsigned int | getNoOfFeatures () |
| | number of non-class loadable features (features, i.e. attributes minus the CLASS attribute)
|
| unsigned int | getNoOfAttributes () |
| unsigned int | getTotalSize () |
| | Number of loaded records (data's size).
|
| unsigned int | getClassSize (int clsId) |
| | Number of records belonging to class clsId.
|
| std::string | getClassName (int clsId) |
| | Name (nominal value text) of class clsId.
|
|
Data_File_ARFF_Record * | getRecordAt (long i) |
| | the loaded record at index i, or nullptr if i is out of range
|
| float | getFeatureValue (long record, int feature) |
| | The value of features[feature] in record record, read out of that record's raw data buffer.
|
|
void | printInfo () |
| | prints a full debug dump (every record's feature values, the attribute list with nominal value tables, and per-class sizes) to stdout; just a "File not loaded" message if loaded is false
|
|
| Data_File_ARFF_Feature * | createAttribute (char *info) |
| bool | readNextRow (char *row) |
| | Reads and stores one data row (dense or sparse, dispatched on a leading '{'); increments the row's class's classSize entry if the row has a class id.
|
|
void | prepareAttributes () |
| | Post-@DATA setup: assigns each loaded attribute's Data_File_ARFF_Feature::offset within a record buffer, splits off the CLASS attribute into classAttribute/classCount (allocating classSize), and sets recordSize.
|
| Data_File_ARFF_Record * | readNormalRow (char *row) |
| | Parses one dense (comma-separated) data row into a new record, walking file columns through columnMap (skipped columns are consumed and discarded).
|
| Data_File_ARFF_Record * | readSparseRow (char *row) |
| | Parses one sparse ({idx value, idx value, ...}) data row into a new record (unset attributes default to 0; an omitted class attribute defaults to class 0), remapping each file column index through columnMap.
|
| bool | readAttrValue (Data_File_ARFF_Feature *feature, Data_File_ARFF_Record *rec, char *value) |
| | Parses value into feature's slot of rec's data buffer (float for TYPE_NUMERIC, a Data_File_ARFF_Feature::values index for TYPE_NOMINAL); also sets rec's class id if feature isClass.
|
| bool | readLine (FILE *f, std::vector< char > &buff) |
|
char * | trim (char *szSource) |
| | trims a string (removes spaces, tabs, and cr / lf
|
|
char * | mystrupr (char *szSource) |
| | replaces nonstandard strupr
|
|
|
std::string | _fileName |
| | input .arff file name, as passed to the constructor
|
|
std::vector< Data_File_ARFF_Record * > | data |
| | loaded records, owned (deleted in the destructor); reordered in place by sortRecordsByClass()
|
|
std::vector< Data_File_ARFF_Feature * > | attributes |
| | LOADED attribute columns only (unsupported types are skipped), INCLUDING the CLASS attribute if present; owned (deleted in the destructor).
|
|
std::vector< Data_File_ARFF_Feature * > | features |
| | the subset of attributes that are actual features (i.e. excluding the CLASS attribute); populated by prepareAttributes()
|
|
std::vector< SkippedColumn > | skippedColumns |
| | every column skipped due to an unsupported type, in file order; see columnMap
|
|
std::vector< int > | columnMap |
| | one entry per @ATTRIBUTE line in file order: the index into attributes for a loaded column, or -1 for a skipped one (see skippedColumns)
|
|
int * | classSize |
| | per-class record counts, indexed by class id (size classCount); owned, allocated in prepareAttributes(), freed in the destructor
|
|
std::string | relationName |
| | the @RELATION name
|
|
int | attributesCount |
| | number of loaded (non-skipped) attribute columns, i.e. attributes.size()
|
|
int | classAttribute |
| | index into attributes of the nominal attribute named CLASS/'CLASS', or -1 if none was found
|
|
int | classCount |
| | number of classes (the CLASS attribute's value count), or -1 if classAttribute is -1
|
|
int | recordSize |
| | size in bytes of one record's raw data buffer (sum of all loaded attributes' Data_File_ARFF_Feature::size); set by prepareAttributes()
|
|
bool | loaded |
| | whether prepareFile() completed without error; getters that need loaded data throw fst_error while false
|
ARFF data format filter.
Reads the subset of Weka's ARFF format that FST4 can use.
Supported. @RELATION, @ATTRIBUTE and @DATA sections in the usual order; lines starting with '' are comments and blank lines are ignored; keywords are matched case-insensitively; data rows may be dense (comma-separated, values optionally single- or double-quoted) or sparse ({index value, index value, ...}, where an omitted attribute means 0 and an omitted class means class 0). Lines may be of any length.
Attribute types. NUMERIC, REAL and INTEGER load as floating-point features. A nominal type ({v1,v2,...}) loads as its 0-based index into the declared value list; a row's value must match one of the declared names exactly (after trimming), or the row fails.
Attribute types that are skipped. STRING, DATE, RELATIONAL and any unrecognized type cannot be represented as a feature. Such a column is reported on standard output and then skipped: its tokens are parsed and discarded, and the file continues loading.
- Warning
- A skipped column does NOT keep an index. Feature indices are assigned to the REMAINING columns in file order, so every column after a skipped one shifts down by one, and the mapping between FST4 feature numbers and columns in the file is no longer the identity. The load summary states how many columns were skipped. If every column is skipped, loading fails.
The class attribute. The class is the nominal attribute named CLASS (case-insensitive, with or without surrounding single quotes). It is excluded from the features, and its value list defines the classes, in declaration order. A file without such an attribute loads, but reports zero classes and cannot be split by class – so the FST4 accessors require one.
Errors. A malformed @ATTRIBUTE definition, an unparseable data value, and a sparse row with an out-of-range column index all abort the load; the reader reports the reason on standard output and prepareFile() returns false. An unopenable file throws fst_error.