Package com.rapidminer.belt.column
Class CategoricalColumn
- java.lang.Object
-
- com.rapidminer.belt.column.Column
-
- com.rapidminer.belt.column.CategoricalColumn
-
public abstract class CategoricalColumn extends Column
Column with data associated to integer categories. Data can be accessed via aCategoricalReader
or aNumericReader
together with access to the mapping byColumn.getDictionary()
or via aObjectReader
.- Author:
- Gisa Meier, Michael Knopf
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.rapidminer.belt.column.Column
Column.Capability, Column.Category, Column.TypeId
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
fill(double[] array, int rowIndex)
Fills the given array with column data starting with the given row index.void
fill(double[] array, int startIndex, int arrayOffset, int arrayStepSize)
Fills the given array with column data starting with the given row index and using the given array offset and step size.void
fill(int[] array, int rowIndex)
Fills the given array with column data starting with the given row index.void
fill(int[] array, int startIndex, int arrayOffset, int arrayStepSize)
Fills the given array with column data starting with the given row index and using the given array offset and step size.void
fill(java.lang.Object[] array, int rowIndex)
Fills the given array with column data starting with the given row index.void
fill(java.lang.Object[] array, int startIndex, int arrayOffset, int arrayStepSize)
Fills the given array with column data starting with the given row index and using the given array offset and step size.protected abstract IntegerFormats.PackedIntegers
getByteData()
Returns the underlyingbyte
category indices of this column.abstract IntegerFormats.Format
getFormat()
Returns the format of the underlying category indices.protected abstract int[]
getIntData()
Returns the underlyingint
category indices of this column.protected abstract short[]
getShortData()
Returns the underlying unsignedshort
category indices of this column.Column
stripData()
Strips the data from the column so that it has length 0 and no mapping or remapping.protected abstract CategoricalColumn
swapDictionary(Dictionary newDictionary)
Creates a new categorical column with the same data and the given dictionary.java.lang.String
toString()
ColumnType<java.lang.String>
type()
Returns theColumnType
of this column.-
Methods inherited from class com.rapidminer.belt.column.Column
getDictionary, rows, size, sort
-
-
-
-
Method Detail
-
fill
public void fill(double[] array, int rowIndex)
Description copied from class:Column
Fills the given array with column data starting with the given row index. Throws anUnsupportedOperationException
if this column has not the capabilityColumn.Capability.NUMERIC_READABLE
.Please note that accessing rows outside of the columns bounds will lead to undefined results.
-
fill
public void fill(double[] array, int startIndex, int arrayOffset, int arrayStepSize)
Description copied from class:Column
Fills the given array with column data starting with the given row index and using the given array offset and step size. For instance, given the row index256
, the array offset4
and a step size of8
, the method writes the values at index256, 257, 258, ...
to array positionsarray[4], array[12], array[20], ...
respectively. Throws anUnsupportedOperationException
if this column has not the capabilityColumn.Capability.NUMERIC_READABLE
.Please note that accessing rows outside of the columns bounds will lead to undefined results.
-
fill
public void fill(int[] array, int rowIndex)
Description copied from class:Column
Fills the given array with column data starting with the given row index. Throws anUnsupportedOperationException
if the category of this column is notColumn.Category.CATEGORICAL
.Please note that accessing rows outside of the columns bounds will lead to undefined results.
-
fill
public void fill(int[] array, int startIndex, int arrayOffset, int arrayStepSize)
Description copied from class:Column
Fills the given array with column data starting with the given row index and using the given array offset and step size. For instance, given the row index256
, the array offset4
and a step size of8
, the method writes the values at index256, 257, 268, ...
to array positionsarray[4], array[12], array[20], ...
respectively. Throws anUnsupportedOperationException
if the category of this column is notColumn.Category.CATEGORICAL
.Please note that accessing rows outside of the columns bounds will lead to undefined results.
-
fill
public void fill(java.lang.Object[] array, int rowIndex)
Description copied from class:Column
Fills the given array with column data starting with the given row index. Throws anUnsupportedOperationException
if this column has not the capabilityColumn.Capability.OBJECT_READABLE
.
-
fill
public void fill(java.lang.Object[] array, int startIndex, int arrayOffset, int arrayStepSize)
Description copied from class:Column
Fills the given array with column data starting with the given row index and using the given array offset and step size. For instance, given the row index256
, the array offset4
and a step size of8
, the method writes the values at index256, 257, 268, ...
to array positionsarray[4], array[12], array[20], ...
respectively. Throws anUnsupportedOperationException
if this column has not the capabilityColumn.Capability.OBJECT_READABLE
.
-
getFormat
public abstract IntegerFormats.Format getFormat()
Returns the format of the underlying category indices.- Returns:
- the index format
-
getByteData
protected abstract IntegerFormats.PackedIntegers getByteData()
Returns the underlyingbyte
category indices of this column. Returnsnull
if the column is not of a format inIntegerFormats.BYTE_BACKED_FORMATS
.- Returns:
- the index array or
null
-
getShortData
protected abstract short[] getShortData()
Returns the underlying unsignedshort
category indices of this column. Returnsnull
if the column is not of formatIntegerFormats.Format.UNSIGNED_INT16
.- Returns:
- the index array or
null
-
getIntData
protected abstract int[] getIntData()
Returns the underlyingint
category indices of this column. Returnsnull
if the column is not of formatIntegerFormats.Format.SIGNED_INT32
.- Returns:
- the index array or
null
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
type
public final ColumnType<java.lang.String> type()
Description copied from class:Column
Returns theColumnType
of this column.
-
swapDictionary
protected abstract CategoricalColumn swapDictionary(Dictionary newDictionary)
Creates a new categorical column with the same data and the given dictionary. The new dictionary must be compatible with the data of the column in the sense that every category index in the data is mapped to a different non-null object value except for 0 which is mapped tonull
. The compatibility is not checked by this method.- Parameters:
newDictionary
- the new dictionary- Returns:
- a new categorical column
-
-