T
- type of underlying enumerationpublic class EnumFV<T extends Enum<T>> extends Object implements FeatureVector
Constructor and Description |
---|
EnumFV(T value)
Construct the feature with the given value
|
Modifier and Type | Method and Description |
---|---|
String |
asciiHeader()
Header for ascii input.
|
DoubleFV |
asDoubleFV()
Convert the FV to a DoubleFV representation
|
double[] |
asDoubleVector()
Convert the FV to a 1-dimensional double array representation
|
byte[] |
binaryHeader()
Header for binary input.
|
double |
getAsDouble(int i)
Get an element of the feature as a double value
|
Enum<T> |
getVector()
Get the underlying data array.
|
int |
length()
Get the length of this vector
|
EnumFV<T> |
newInstance()
Construct a new instance of this featurevector.
|
DoubleFV |
normaliseFV()
Normalise the FV to unit length
|
DoubleFV |
normaliseFV(double p)
Lp Norm of the FV.
|
DoubleFV |
normaliseFV(double[] min,
double[] max)
Element-wise normalisation to 0..1 using separated expected minimum and
maximum values for each element of the underlying feature vector.
|
DoubleFV |
normaliseFV(double min,
double max)
Min-Max normalisation of the FV.
|
void |
readASCII(Scanner in)
Read internal state from in.
|
void |
readBinary(DataInput in)
Read internal state from in.
|
void |
setFromDouble(int i,
double v)
Set an element of the feature from a double value
|
void |
writeASCII(PrintWriter out)
Write the content of this as ascii to out.
|
void |
writeBinary(DataOutput out)
Write the content of this as binary to out.
|
public void readBinary(DataInput in) throws IOException
ReadableBinary
readBinary
in interface ReadableBinary
in
- source to read from.IOException
- an error reading inputpublic void readASCII(Scanner in) throws IOException
ReadableASCII
readASCII
in interface ReadableASCII
in
- source to read from.IOException
- an error reading inputpublic byte[] binaryHeader()
ReadableBinary
binaryHeader
in interface ReadableBinary
binaryHeader
in interface WriteableBinary
public String asciiHeader()
ReadableASCII
asciiHeader
in interface ReadableASCII
asciiHeader
in interface WriteableASCII
public void writeBinary(DataOutput out) throws IOException
WriteableBinary
writeBinary
in interface WriteableBinary
out
- sink to write toIOException
- an error writing to outpublic void writeASCII(PrintWriter out) throws IOException
WriteableASCII
writeASCII
in interface WriteableASCII
out
- sink to write toIOException
- an error writing to outpublic Enum<T> getVector()
FeatureVector
getVector
in interface FeatureVector
public int length()
FeatureVector
length
in interface FeatureVector
public DoubleFV normaliseFV(double[] min, double[] max)
FeatureVector
normaliseFV
in interface FeatureVector
min
- an array containing the minimum expected valuesmax
- an array containing the maximum expected valuespublic DoubleFV normaliseFV(double min, double max)
FeatureVector
normaliseFV
in interface FeatureVector
min
- the minimum expected valuemax
- the maximum expected valuepublic DoubleFV normaliseFV()
FeatureVector
normaliseFV
in interface FeatureVector
public DoubleFV normaliseFV(double p)
FeatureVector
normaliseFV
in interface FeatureVector
p
- the norm to computepublic DoubleFV asDoubleFV()
FeatureVector
asDoubleFV
in interface FeatureVector
public double[] asDoubleVector()
FeatureVector
asDoubleVector
in interface FeatureVector
public double getAsDouble(int i)
FeatureVector
getAsDouble
in interface FeatureVector
i
- the element indexpublic void setFromDouble(int i, double v)
FeatureVector
setFromDouble
in interface FeatureVector
i
- the element indexv
- the valuepublic EnumFV<T> newInstance()
FeatureVector
newInstance
in interface FeatureVector