Package table
Class TableMapper
java.lang.Object
table.TableMapper
- All Implemented Interfaces:
Serializable
Class for mapping data table rows to real-valued vectors.
- Since:
- 2007.05.16
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
use two columns for binary attributes (default: one column)static final int
map both input and target attributesstatic final int
map only the input attributesstatic final int
map only marked columns (non-negative)static final int
map only the target attribute -
Constructor Summary
ConstructorsConstructorDescriptionTableMapper
(Table tab) Create a data table mapper.TableMapper
(Table tab, int mode) Create a data table mapper. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
exec
(int row) Execute the table map for a given row.double[]
exec
(int row, double[] vec) Execute the table map for a given row.double[]
exec
(int row, int mode) Execute the table map for a given row.double[]
exec
(int row, int mode, double[] vec) Execute the table map for a given row.getColumn
(int id) Get a mapped column.int
Get the number of mapped columns.int
getCount
(int id) Get the number of elements a column is mapped to.int
Get the total number of elements.int
Get the number of input elements.int
getOffset
(int id) Get the offset to the first element a column is mapped to.int
Get the number of output elements.getTable()
Get the underlying table.Get the target column.int
Get the target column id.getVarName
(int id) Get the name of a mapped variable.static void
Main function for testing basic functionality.void
setTarget
(int trgid) Set the target column.
-
Field Details
-
MARKED
public static final int MARKEDmap only marked columns (non-negative)- See Also:
-
BIN2COL
public static final int BIN2COLuse two columns for binary attributes (default: one column)- See Also:
-
INPUTS
public static final int INPUTSmap only the input attributes- See Also:
-
TARGET
public static final int TARGETmap only the target attribute- See Also:
-
BOTH
public static final int BOTHmap both input and target attributes- See Also:
-
-
Constructor Details
-
TableMapper
Create a data table mapper.- Parameters:
tab
- the table to map- Since:
- 2007.05.16 (Christian Borgelt)
-
TableMapper
Create a data table mapper.- Parameters:
tab
- the table to mapmode
- the mapping mode- Since:
- 2007.05.16 (Christian Borgelt)
-
-
Method Details
-
getTable
Get the underlying table.- Returns:
- the underlying table
- Since:
- 2007.05.16 (Christian Borgelt)
-
getColumnCount
public int getColumnCount()Get the number of mapped columns.- Returns:
- the number of mapped columns
- Since:
- 2007.05.16 (Christian Borgelt)
-
getColumn
Get a mapped column.Note that the column id in the table mapper may differ from the column id in the underlying table if not all columns were mapped or the target column is not the last column of the table. The target column (if it has been set) can be accessed with a negative column index or with
getColumnCount()-1
.- Parameters:
id
- the id of the mapped column- Returns:
- the
id
-th mapped column - Since:
- 2007.05.16 (Christian Borgelt)
-
getTarget
Get the target column.- Returns:
- the target column
- Since:
- 2007.05.21 (Christian Borgelt)
-
getTargetId
public int getTargetId()Get the target column id.- Returns:
- the target column id
- Since:
- 2007.05.21 (Christian Borgelt)
-
getInputCount
public int getInputCount()Get the number of input elements.- Returns:
- the number of input elements
- Since:
- 2007.05.16 (Christian Borgelt)
-
getOutputCount
public int getOutputCount()Get the number of output elements.- Returns:
- the number of output elements
- Since:
- 2007.05.16 (Christian Borgelt)
-
getInOutCount
public int getInOutCount()Get the total number of elements.- Returns:
- the total number of elements
- Since:
- 2007.05.16 (Christian Borgelt)
-
getOffset
public int getOffset(int id) Get the offset to the first element a column is mapped to.- Parameters:
id
- the id of the column- Returns:
- the offset to the first element a column is mapped to
- Since:
- 2007.05.16 (Christian Borgelt)
-
getCount
public int getCount(int id) Get the number of elements a column is mapped to.- Parameters:
id
- the id of the column- Returns:
- the number of elements a column is mapped to
- Since:
- 2007.05.16 (Christian Borgelt)
-
getVarName
Get the name of a mapped variable.- Parameters:
id
- the id of the variable (vector index)- Returns:
- the name of the mapped variable
- Since:
- 2007.05.16 (Christian Borgelt)
-
setTarget
public void setTarget(int trgid) Set the target column.- Parameters:
trgid
- the column id of the target attribute- Since:
- 2007.05.16 (Christian Borgelt)
-
exec
public double[] exec(int row) Execute the table map for a given row.- Parameters:
row
- the index of the row to map- Returns:
- the numeric vector the row is mapped to
- Since:
- 2007.05.16 (Christian Borgelt)
-
exec
public double[] exec(int row, int mode) Execute the table map for a given row.- Parameters:
row
- the index of the row to mapmode
- the mapping mode (e.g.INPUTS
)- Returns:
- the numeric vector the row is mapped to
- Since:
- 2007.05.16 (Christian Borgelt)
-
exec
public double[] exec(int row, double[] vec) Execute the table map for a given row.- Parameters:
row
- the index of the row to mapvec
- the vector in which to store the mapped row- Returns:
- the numeric vector the row is mapped to
- Since:
- 2007.05.16 (Christian Borgelt)
-
exec
public double[] exec(int row, int mode, double[] vec) Execute the table map for a given row.- Parameters:
row
- the index of the row to mapmode
- the mapping mode (e.g.INPUTS
)vec
- the vector in which to store the mapped row- Returns:
- the numeric vector the row is mapped to
- Since:
- 2007.05.16 (Christian Borgelt)
-
main
Main function for testing basic functionality.- Parameters:
args
- the command line arguments- Since:
- 2007.05.16 (Christian Borgelt)
-