|
JMSLTM Numerical Library 5.0.1 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.imsl.datamining.neural.UnsupervisedOrdinalFilter
public class UnsupervisedOrdinalFilter
Encodes ordinal data into percentages for input to a neural network. It also allows decoding, accepting a percentage and converting it into an ordinal value.
Class UnsupervisedOrdinalFilter
is designed to either encode or decode
ordinal variables. Encoding consists of transforming the ordinal classes
into percentages, with each percentage being equal to the percentage of the
data at or below this class.
In this case, x
is input to the
method encode
and is filtered by
converting each ordinal class value into a cumulative percentage.
For example, if x[]={2, 1, 3, 4, 2, 4, 1, 1, 3, 3}
then
nClasses=4
, and encode
returns
the ordinal class designation with the cumulative
percentages displayed in the following table. Cumulative percentages are
equal to the percent of the data in this class or a lower class.
Ordinal Class | Frequency | Cumulative Percentage |
1 | 3 | 30% |
2 | 2 | 50% |
3 | 3 | 80% |
4 | 2 | 100% |
Classes in x
must be numbered from 1 to nClasses
.
The values returned from encoding or decoding depend upon the setting of
transform
. In this example, if the filter was constructed
with transform = TRANSFORM_NONE
, then
the method encode
will return
If the filter was constructed with transform = TRANSFORM_SQRT
,
then the square root of these values is returned, i.e.,
If the filter was constructed with transform = TRANSFORM_ASIN_SQRT
,
then the arcsin square root of these
values is returned using the following calculation:
Ordinal decoding takes a transformed cumulative proportion and converts it into an ordinal class value.
Field Summary | |
---|---|
static int |
TRANSFORM_ASIN_SQRT
Flag to indicate the arcsine square root transform will be applied to the percentages. |
static int |
TRANSFORM_NONE
Flag to indicate no transformation of percentages. |
static int |
TRANSFORM_SQRT
Flag to indicate the square root transform will be applied to the percentages. |
Constructor Summary | |
---|---|
UnsupervisedOrdinalFilter(int nClasses,
int transform)
Constructor for UnsupervisedOrdinalFilter . |
Method Summary | |
---|---|
int |
decode(double z)
Decodes an encoded ordinal variable. |
int[] |
decode(double[] z)
Decodes an array of encoded ordinal values. |
double |
encode(int x)
Encodes an ordinal category. |
double[] |
encode(int[] x)
Encodes an array of ordinal categories into an array of transformed percentages. |
int |
getNumberOfClasses()
Retrieves the number of categories associated with this ordinal variable. |
double[] |
getPercentages()
Retrieves the cumulative percentages used for encoding and decoding. |
int |
getTransform()
Retrieves the transform flag used for encoding and decoding. |
void |
setPercentages(double[] percentages)
Set the untransformed cumulative percentages used during encoding and decoding. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRANSFORM_ASIN_SQRT
public static final int TRANSFORM_NONE
public static final int TRANSFORM_SQRT
Constructor Detail |
---|
public UnsupervisedOrdinalFilter(int nClasses, int transform)
UnsupervisedOrdinalFilter
.
nClasses
- An int
specifying the number of classes in the data to be filtered.transform
- An int
specifying the transform to be applied to the percentages.
Values for transform
are:
TRANSFORM_NONE
,
TRANSFORM_SQRT
,
TRANSFORM_ASIN_SQRT
Method Detail |
---|
public int decode(double z)
z
- A double
containing the encoded value to be decoded.
int
containing the ordinal category associated with y
.public int[] decode(double[] z)
z
- A double
array containing the encoded ordinal data to be decoded.
int
array containing the decoded ordinal classifications.public double encode(int x)
x
- An int
containing the ordinal category. Must be
an integer between 1 and nClasses
.
double
containing the encoded value, a transformed cumulative percentage.public double[] encode(int[] x)
x
- An int
array containing the categories for the ordinal
variable. Categories must be numbered from
1 to nClasses
.
double
array of the transformed percentages.public int getNumberOfClasses()
int
containing the number of categories
associated with this ordinal variable.public double[] getPercentages()
double
array of length nClasses
containing the cumulative transformed percentages
associated with the ordinal categories.public int getTransform()
int
containing the transform flag used for
encoding and decoding.public void setPercentages(double[] percentages)
percentages
- A double
array of length nClasses
containing the cumulative percentages to use during encoding
and decoding.
|
JMSLTM Numerical Library 5.0.1 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |