Public Member Functions

HAPI::DataSet Class Reference

List of all members.

Public Member Functions

std::vector< double > computeIEMIntervals (size_t value_column, size_t class_column) const
 Create a discretization of the numeric data in the specified column.
 DataSet ()
 Construct a new (empty) DataSet object.
 DataSet (const std::string &csvStringOrFileName, int separator, ParseListener *pl)
 Construct a DataSet from a CSV specification provided in a file or as a string.
void deleteColumn (size_t column)
 Delete the specified column from this DataSet.
void deleteRow (size_t row)
 Delete the specified row from this DataSet.
std::string getColumnName (size_t column) const
 Return the name of the specified column of this DataSet.
const char * getDataItem (size_t row, size_t column) const
 Return the data item at the specified location of this DataSet.
size_t getNumberOfColumns () const
 Return the number of columns in this DataSet.
size_t getNumberOfRows () const
 Return the number of rows in this DataSet.
void moveColumn (size_t column, size_t new_column)
 Moves the specified column to a new position.
void moveRow (size_t row, size_t new_row)
 Move the specified row to a new position.
size_t newColumn (const char *name)
 Create a new column in this DataSet.
size_t newColumn (const std::string &name)
 Create a new column in this DataSet.
size_t newRow ()
 Create a new row in this DataSet.
void saveAsCSV (const std::string &file_name, int delimiter)
 Save this DataSet in the format of a comma-separated-values (CSV) file.
void setColumnName (size_t column, const std::string &name)
 Set the name of the specified column of this DataSet.
void setColumnName (size_t column, const char *name)
 Set the name of the specified column of this DataSet.
void setDataItem (size_t row, size_t column, const std::string &data)
 Set the data item at the specified location of this DataSet.
void setDataItem (size_t row, size_t column, const char *data)
 Set (or delete) the data item at the specified location of this DataSet.
std::string toCSVString (int delimiter) const
 Create a CSV representation (as a string) of this DataSet.
 ~DataSet () throw ()
 Destruct a DataSet object.

Constructor & Destructor Documentation

HAPI::DataSet::DataSet ( const std::string &  csvStringOrFileName,
int  separator,
ParseListener pl 
)

Construct a DataSet from a CSV specification provided in a file or as a string.

Instead of a comma, a different separator character may be used.

Parameters:
csvStringOrFileNamea string containing a CSV specification or the name of a CSV file
separatorthe separator character (must not be a double-quote character)
plthe ParseListener used for handling parse errors.

Member Function Documentation

std::vector<double> HAPI::DataSet::computeIEMIntervals ( size_t  value_column,
size_t  class_column 
) const

Create a discretization of the numeric data in the specified column.

The supervised discretization algorithm by Fayyad and Irani is used to create intervals for the numeric data in the column with index value_column. The class data used to guide the discretization is contained in the column with index class_column.

Parameters:
value_columnthe index of the column to discretize
class_columnthe index of the column containing the class (or target) data.
Returns:
a list of real numbers (suitable for use as state values for an interval node).
void HAPI::DataSet::deleteColumn ( size_t  column )

Delete the specified column from this DataSet.

Columns to the right of the deleted column will be shifted one position to the left.

Parameters:
columnthe index of the column to be deleted
void HAPI::DataSet::deleteRow ( size_t  row )

Delete the specified row from this DataSet.

Rows below the deleted row will be shifted one position up.

Parameters:
rowthe index of the row to be deleted
std::string HAPI::DataSet::getColumnName ( size_t  column ) const

Return the name of the specified column of this DataSet.

Parameters:
columnthe index of the column
const char* HAPI::DataSet::getDataItem ( size_t  row,
size_t  column 
) const

Return the data item at the specified location of this DataSet.

Parameters:
rowthe index of the row
columnthe index of the column
Returns:
The data item at the specified location.
void HAPI::DataSet::moveColumn ( size_t  column,
size_t  new_column 
)

Moves the specified column to a new position.

The columns between the old and the new column positions will be shifted one position to the left or to the right depending on the direction of the move.

Parameters:
columnthe index of the column to be moved
newColumnthe index of the destination column
void HAPI::DataSet::moveRow ( size_t  row,
size_t  new_row 
)

Move the specified row to a new position.

The rows between the old and the new row positions will be shifted one position up or down depending on the direction of the move.

Parameters:
rowthe index of the row to be moved
newRowthe index of the destination row
size_t HAPI::DataSet::newColumn ( const std::string &  name )

Create a new column in this DataSet.

Parameters:
namethe name of the new column
Returns:
the index of the new column
size_t HAPI::DataSet::newColumn ( const char *  name )

Create a new column in this DataSet.

Parameters:
namethe name of the new column
Returns:
the index of the new column
size_t HAPI::DataSet::newRow (  )

Create a new row in this DataSet.

Returns:
the index of the new row
void HAPI::DataSet::saveAsCSV ( const std::string &  file_name,
int  delimiter 
)

Save this DataSet in the format of a comma-separated-values (CSV) file.

However, another delimiter than a comma may be used.

Parameters:
file_namethe name of the file in which to store the data
delimiterthe delimiter character (must not be a double-quote character).
void HAPI::DataSet::setColumnName ( size_t  column,
const char *  name 
)

Set the name of the specified column of this DataSet.

Parameters:
columnthe index of the column
namethe new name of the column
void HAPI::DataSet::setColumnName ( size_t  column,
const std::string &  name 
)

Set the name of the specified column of this DataSet.

Parameters:
columnthe index of the column
namethe new name of the column
void HAPI::DataSet::setDataItem ( size_t  row,
size_t  column,
const char *  data 
)

Set (or delete) the data item at the specified location of this DataSet.

Parameters:
rowthe index of the row
columnthe index of the column
datathe new data item (a NULL value causes the item to be deleted).
void HAPI::DataSet::setDataItem ( size_t  row,
size_t  column,
const std::string &  data 
)

Set the data item at the specified location of this DataSet.

Parameters:
rowthe index of the row
columnthe index of the column
datathe new data item.
std::string HAPI::DataSet::toCSVString ( int  delimiter ) const

Create a CSV representation (as a string) of this DataSet.

Parameters:
delimiterthe delimiter character (must not be a double-quote character).
Returns:
A string containing the CSV representation.

Copyright Hugin Expert A/S 1993-2024