public interface Matrix2D extends Serializable, Iterable<DMUtil.FieldValues>
Query
in the DatamartContext
Query
in the TableContext
Modifier and Type | Interface and Description |
---|---|
static class |
Matrix2D.BucketNaming |
Modifier and Type | Method and Description |
---|---|
Matrix2D |
addColumn(String colLabel)
Add a column to this Matrix2D, without any values
|
Matrix2D |
addColumn(String colLabel,
Object[] colValues)
Add a column to this Matrix2D, with the value on each row retreived from the given values array.
|
Matrix2D |
addMappedColumn(String colLabel,
List<String> fromColLabels,
Map<MultiKey<String>,Object> mapping)
Add a column to this Matrix2D, with the value on each row looked up from the given map, using a set of existing columns' values as a composite lookup key.
|
Matrix2D |
addMappedColumn(String colLabel,
String mappedColLabel,
Map<String,Object> mapping)
Add a column to this Matrix2D, with the value on each row looked up from the given map, using the mapped column's value as the lookup key.
|
static Matrix2DImpl |
fromListOfMaps(Collection<Map<String,Object>> rows) |
static Matrix2DImpl |
fromResultMatrix(ResultMatrix resultMatrix) |
long |
getColumn(String label) |
long |
getColumnCount() |
DataType |
getColumnDataType(String colLabel) |
String |
getColumnLabel(long col) |
List<String> |
getColumnLabels() |
long[] |
getColumns(Collection<String> labels) |
List<Object> |
getColumnValues(long col) |
Long |
getCumulativeDistributionValue(long col,
BigDecimal value)
Determines the total number of values (samples) smaller or equal to the given value, in the given numeric column.
|
BigDecimal[] |
getExcelPercentileValues(long c)
Computes percentiles compatible with Excel
|
double |
getExcelPercentRank(long c,
double value)
Computes the rank of a value, as a percentage, in the distribution of values in the given column.
|
Map<MultiKey<String>,Object> |
getMap(List<String> colLabels,
String valColLabel)
Extracts a map from the values in the nominated key columns (resulting in keys of type MultiKey) and value columns.
|
Map<String,Object> |
getMap(String keyColLabel,
String valColLabel)
Extracts a map from the values in the nominated key and value columns.
|
BigDecimal |
getPercentileValue(long col,
int percentile)
Calculates the value at the given percentile in the given numeric column.
|
long |
getRowCount() |
DMUtil.FieldValues |
getRowValues(long row) |
Object |
getValue()
Convenience getter of values in the matrix.
|
Object |
getValue(long row,
long col) |
Matrix2D |
indexOfMax() |
Matrix2D |
indexOfMin() |
boolean |
isEmpty()
A matrix is empty if it has no rows.
|
double |
kurtosis(String label) |
Matrix2D |
max() |
Matrix2D |
mean() |
Matrix2D |
min() |
Matrix2D |
normalize(long... cols)
Normalizes numeric column values, by dividing each value in the column by the total for the column.
|
Matrix2D |
normalizeRowValues(Collection<String> colLabels,
int precision)
Normalizes the values on a row-by-row basis.
|
List<String> |
quantize(int numberOfBuckets,
String newColLabelPostfix,
String bucketNaming)
Convenience method to quantize all numeric columns in one go.
|
void |
quantize(String colLabel,
int numberOfBuckets,
String newColLabel,
String bucketNaming)
Performs equal width quantization of a scalar distribution in a given column, and maps each value to its nearest lower quantile.
|
Matrix2D |
renameColumns(Map<String,String> old2NewColLabels)
Renames the columns in this matrix so that the old column label = key, and the new column label = value in the given map.
|
Matrix2D |
replaceMissingValues(String colLabel,
Object val)
Replaces nulls in the given column with the given value.
|
long |
search(BigDecimal value,
long col)
Finds the index of row containing a given value in a given column, assuming this column is sorted high --> low.
|
long[] |
search(Collection<?> values,
long col)
Find all rows for which the value in the given column is contained in the passed in collection.
|
Matrix2D |
select(long startRow,
long endRow,
long startColumn,
long endColumn)
Selects a subset of rows and columns in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectColumn(long col)
Selects a column in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectColumn(String label)
Selects a column in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectColumns(long startCol,
long endCol)
Selects a subset of columns in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectRow(long row)
Selects one row in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectRows(Collection<? extends Number> rows)
Selects a subset of rows in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectRows(long[] rows)
Selects a subset of rows in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
Matrix2D |
selectRows(long startRow,
long endRow)
Selects a subset of rows in the matrix, and returns the result as new Matrix2D object, but which crucially does not duplicate any of the original rows.
|
void |
setRowValues(Map<String,Object> val,
long row)
Modifies the value at the row coordinate, setting those values that match column names in the matrix.
|
void |
setValue(Object val,
long row,
long col)
Modifies the value at the given coordinates (row,col)
|
Matrix2D |
sortRows(long col) |
Matrix2D |
sortRowsReverse(long col) |
Matrix2D |
std() |
Matrix2D |
sum() |
ResultMatrix |
toResultMatrix() |
ResultMatrix |
toResultMatrix(Map<String,String> columnMapping)
Create a ResultMatrix from a Matrix2D, selecting only the columns included in the mapping if such a mapping is provided.
|
forEach, iterator, spliterator
long getRowCount()
long getColumnCount()
String getColumnLabel(long col)
col
- Index of the column to get the label for. The label is the corresponding projection's alias.boolean isEmpty()
long getColumn(String label)
label
- Label of a column in the matrixlong[] getColumns(Collection<String> labels)
labels
- Labels of a set of columns in the matrixDataType getColumnDataType(String colLabel)
colLabel
- Label of the column to get the DataType forMatrix2D selectRow(long row)
row
- Index of row to selectMatrix2D selectRows(long startRow, long endRow)
startRow
- Index of first row to select, inclusiveendRow
- Index of last row to select, inclusiveMatrix2D selectColumn(String label)
label
- Label of the column to selectMatrix2D selectColumn(long col)
label
- Index of the column to selectMatrix2D selectColumns(long startCol, long endCol)
startCol
- Index of first column to select, inclusiveendCol
- Index of last column to select, inclusiveMatrix2D select(long startRow, long endRow, long startColumn, long endColumn)
startRow
- Index of first row to select, inclusiveendRow
- Index of last row to select, inclusivestartCol
- Index of first column to select, inclusiveendCol
- Index of last column to select, inclusiveMatrix2D selectRows(long[] rows)
rows
- Array of row indices to select.Matrix2D selectRows(Collection<? extends Number> rows)
rows
- Collection of row indices to select.long search(BigDecimal value, long col)
value
- Threshold valuecol
- Index of the column to searchlong[] search(Collection<?> values, long col)
values
- Collection of values to match tocol
- Index of the column to searchMatrix2D max()
Matrix2D min()
Matrix2D sum()
Matrix2D mean()
Matrix2D std()
Matrix2D indexOfMin()
Matrix2D indexOfMax()
Matrix2D normalize(long... cols)
cols
- The indices of the columns to normalize. These columns should contain numerical data, for th enormalization to be useful.Object getValue()
Object getValue(long row, long col)
row
- Row indexcol
- Column indexDMUtil.FieldValues getRowValues(long row)
row
- Row indexList<Object> getColumnValues(long col)
col
- Column indexvoid setValue(Object val, long row, long col)
val
- Value to setrow
- Row indexcol
- Column indexvoid setRowValues(Map<String,Object> val, long row)
val
- Map of (column name, value) pairs.row
- Row indexBigDecimal getPercentileValue(long col, int percentile)
col
- Column indexpercentile
- Integer number from 0 to 100Long getCumulativeDistributionValue(long col, BigDecimal value)
col
- Column indexvalue
- Input to the CDF ('cumulative distribution function')BigDecimal[] getExcelPercentileValues(long c)
c
- Column indexdouble getExcelPercentRank(long c, double value)
col
- Column indexvalue
- The value for which to return the rankMatrix2D normalizeRowValues(Collection<String> colLabels, int precision)
colLabels
- Labels of the columns to include in the normalizationprecision
- Maximum number of decimals in the normalized valuedouble kurtosis(String label)
label
- Label of a numeric columnMatrix2D sortRows(long col)
col
- Column indexMatrix2D sortRowsReverse(long col)
col
- Column indexMap<String,Object> getMap(String keyColLabel, String valColLabel)
keyColLabel
- Label of the column for which the values are to be used as keys in the mapvalColLabel
- Label of the column for which the values are to be used as values in the mapMap<MultiKey<String>,Object> getMap(List<String> colLabels, String valColLabel)
colLabels
- valColLabel
- Matrix2D addMappedColumn(String colLabel, String mappedColLabel, Map<String,Object> mapping)
colLabel
- Label of the new columnmappedColLabel
- Label of the column holding the lookup keysmapping
- Map holding the values to map those lookup keys toMatrix2D addMappedColumn(String colLabel, List<String> fromColLabels, Map<MultiKey<String>,Object> mapping)
net.pricefx.formulaengine.scripting.SandboxAPI.multiKey
.colLabel
- Label of the new columnfromColLabels
- Labels of the columns holding the composite lookup key valuesmapping
- Map holding the values to map those lookup keys toMatrix2D addColumn(String colLabel, Object[] colValues)
colLabel
- Label of the new columncolValues
- Array of values to populate the new column withMatrix2D addColumn(String colLabel)
colLabel
- Label of the new columnMatrix2D renameColumns(Map<String,String> old2NewColLabels)
old2NewColLabels
- Old --> new column label mappingMatrix2D replaceMissingValues(String colLabel, Object val)
colLabel
- Label of column to processval
- Value to setList<String> quantize(int numberOfBuckets, String newColLabelPostfix, String bucketNaming)
numberOfBuckets
- newColLabelPostfix
- Example: the bins for column 'margin' go into a new column named 'margin_q' if the prefix is set to '_q'.bucketNaming
- void quantize(String colLabel, int numberOfBuckets, String newColLabel, String bucketNaming)
colLabel
- Label of the column holding the scalar valuesnumberOfBuckets
- Number of quantiles/buckets to calculate (max 100). Typically 10 deciles or 4 quartiles.colLabel
- Label of the new column to add, holding the mapped quantilebucketNaming
- One of the following values:
ResultMatrix toResultMatrix()
ResultMatrix toResultMatrix(Map<String,String> columnMapping)
columnMapping
- Mapping ResultMatrix column name --> Matrix2D column labelstatic Matrix2DImpl fromResultMatrix(ResultMatrix resultMatrix)
static Matrix2DImpl fromListOfMaps(Collection<Map<String,Object>> rows)
Copyright © 2019. All rights reserved.