public class SparseFloatFV extends Object implements FeatureVector, Concatenatable<SparseFloatFV,SparseFloatFV>
Modifier and Type | Field and Description |
---|---|
SparseFloatArray |
values
The underlying data backing the feature vector
|
Modifier | Constructor and Description |
---|---|
protected |
SparseFloatFV()
Construct an empty FV with zero length
|
|
SparseFloatFV(float[] values)
Construct from native array
|
|
SparseFloatFV(int nbins)
Construct empty FV with given number of bins
|
|
SparseFloatFV(SparseFloatArray 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.
|
SparseFloatFV |
concatenate(List<SparseFloatFV> ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
SparseFloatFV |
concatenate(SparseFloatFV... 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
|
SparseFloatArray |
getVector()
Get the underlying data array.
|
int |
length()
Get the length of this vector
|
SparseFloatFV |
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 SparseFloatArray values
protected SparseFloatFV()
public SparseFloatFV(int nbins)
nbins
- the number of bins in each dimensionpublic SparseFloatFV(SparseFloatArray values)
values
- the array of valuespublic SparseFloatFV(float[] values)
values
- the array of valuespublic void readASCII(Scanner in) throws IOException
ReadableASCII
readASCII
in interface ReadableASCII
in
- source to read from.IOException
- an error reading inputpublic String asciiHeader()
ReadableASCII
asciiHeader
in interface ReadableASCII
asciiHeader
in interface WriteableASCII
public void readBinary(DataInput in) throws IOException
ReadableBinary
readBinary
in interface ReadableBinary
in
- source to read from.IOException
- an error reading inputpublic byte[] binaryHeader()
ReadableBinary
binaryHeader
in interface ReadableBinary
binaryHeader
in interface WriteableBinary
public void writeASCII(PrintWriter out) throws IOException
WriteableASCII
writeASCII
in interface WriteableASCII
out
- sink to write toIOException
- an error writing to outpublic void writeBinary(DataOutput out) throws IOException
WriteableBinary
writeBinary
in interface WriteableBinary
out
- sink to write toIOException
- an error writing to outpublic SparseFloatArray 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 SparseFloatFV concatenate(SparseFloatFV... ins)
Concatenatable
concatenate
in interface Concatenatable<SparseFloatFV,SparseFloatFV>
ins
- the inputspublic SparseFloatFV concatenate(List<SparseFloatFV> ins)
Concatenatable
concatenate
in interface Concatenatable<SparseFloatFV,SparseFloatFV>
ins
- the inputspublic 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 SparseFloatFV newInstance()
FeatureVector
newInstance
in interface FeatureVector