Additive logratio transform
alr_transform(df, column=None, keep_denominator_column=False)
Perform an additive logratio transformation on the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe of compositional data. |
required |
column |
Optional[str]
|
The name of the column to be used as the denominator column. |
None
|
keep_denominator_column |
bool
|
Whether to include the denominator column in the result. If True, the returned dataframe retains its original shape. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
A new dataframe containing the ALR transformed data. |
Raises:
Type | Description |
---|---|
InvalidColumnException
|
The input column isn't found in the dataframe. |
InvalidCompositionException
|
Data is not normalized to the expected value. |
NumericValueSignException
|
Data contains zeros or negative values. |
Source code in eis_toolkit/transformations/coda/alr.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
inverse_alr(df, denominator_column, scale=1.0)
Perform the inverse transformation for a set of ALR transformed data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe of ALR transformed compositional data. |
required |
denominator_column |
str
|
The name of the denominator column. |
required |
scale |
Number
|
The value to which each composition should be normalized. Eg., if the composition is expressed as percentages, scale=100. |
1.0
|
Returns:
Type | Description |
---|---|
DataFrame
|
A dataframe containing the inverse transformed data. |
Raises:
Type | Description |
---|---|
NumericValueSignException
|
The input scale value is zero or less. |
Source code in eis_toolkit/transformations/coda/alr.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|