public class SparseShortFV extends Object implements FeatureVector, Concatenatable<SparseShortFV,SparseShortFV>
| Modifier and Type | Field and Description |
|---|---|
SparseShortArray |
values
The underlying data backing the feature vector
|
| Modifier | Constructor and Description |
|---|---|
protected |
SparseShortFV()
Construct an empty FV with zero length
|
|
SparseShortFV(int nbins)
Construct empty FV with given number of bins
|
|
SparseShortFV(short[] values)
Construct from native array
|
|
SparseShortFV(SparseShortArray values)
Construct from sparse array
|
| 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.
|
SparseShortFV |
concatenate(List<SparseShortFV> ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
SparseShortFV |
concatenate(SparseShortFV... ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
double |
getAsDouble(int i)
Get an element of the feature as a double value
|
SparseShortArray |
getVector()
Get the underlying data array.
|
int |
length()
Get the length of this vector
|
SparseShortFV |
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 SparseShortArray values
protected SparseShortFV()
public SparseShortFV(int nbins)
nbins - the number of bins in each dimensionpublic SparseShortFV(SparseShortArray values)
values - the array of valuespublic SparseShortFV(short[] values)
values - the array of valuespublic void readASCII(Scanner in) throws IOException
ReadableASCIIreadASCII in interface ReadableASCIIin - source to read from.IOException - an error reading inputpublic String asciiHeader()
ReadableASCIIasciiHeader in interface ReadableASCIIasciiHeader in interface WriteableASCIIpublic void readBinary(DataInput in) throws IOException
ReadableBinaryreadBinary in interface ReadableBinaryin - source to read from.IOException - an error reading inputpublic byte[] binaryHeader()
ReadableBinarybinaryHeader in interface ReadableBinarybinaryHeader in interface WriteableBinarypublic void writeASCII(PrintWriter out) throws IOException
WriteableASCIIwriteASCII in interface WriteableASCIIout - sink to write toIOException - an error writing to outpublic void writeBinary(DataOutput out) throws IOException
WriteableBinarywriteBinary in interface WriteableBinaryout - sink to write toIOException - an error writing to outpublic SparseShortArray getVector()
FeatureVectorgetVector in interface FeatureVectorpublic int length()
FeatureVectorlength in interface FeatureVectorpublic DoubleFV normaliseFV(double[] min, double[] max)
FeatureVectornormaliseFV in interface FeatureVectormin - an array containing the minimum expected valuesmax - an array containing the maximum expected valuespublic DoubleFV normaliseFV(double min, double max)
FeatureVectornormaliseFV in interface FeatureVectormin - the minimum expected valuemax - the maximum expected valuepublic DoubleFV normaliseFV()
FeatureVectornormaliseFV in interface FeatureVectorpublic DoubleFV normaliseFV(double p)
FeatureVectornormaliseFV in interface FeatureVectorp - the norm to computepublic DoubleFV asDoubleFV()
FeatureVectorasDoubleFV in interface FeatureVectorpublic double[] asDoubleVector()
FeatureVectorasDoubleVector in interface FeatureVectorpublic SparseShortFV concatenate(SparseShortFV... ins)
Concatenatableconcatenate in interface Concatenatable<SparseShortFV,SparseShortFV>ins - the inputspublic SparseShortFV concatenate(List<SparseShortFV> ins)
Concatenatableconcatenate in interface Concatenatable<SparseShortFV,SparseShortFV>ins - the inputspublic double getAsDouble(int i)
FeatureVectorgetAsDouble in interface FeatureVectori - the element indexpublic void setFromDouble(int i, double v)
FeatureVectorsetFromDouble in interface FeatureVectori - the element indexv - the valuepublic SparseShortFV newInstance()
FeatureVectornewInstance in interface FeatureVector