public class SparseIntFV extends Object implements FeatureVector, Concatenatable<SparseIntFV,SparseIntFV>
Modifier and Type | Field and Description |
---|---|
SparseIntArray |
values
The underlying data backing the feature vector
|
Modifier | Constructor and Description |
---|---|
protected |
SparseIntFV()
Construct an empty FV with zero length
|
|
SparseIntFV(int nbins)
Construct empty FV with given number of bins
|
|
SparseIntFV(int[] values)
Construct from native array
|
|
SparseIntFV(SparseIntArray 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.
|
SparseIntFV |
concatenate(List<SparseIntFV> ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
SparseIntFV |
concatenate(SparseIntFV... 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
|
SparseIntArray |
getVector()
Get the underlying data array.
|
int |
length()
Get the length of this vector
|
SparseIntFV |
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 SparseIntArray values
protected SparseIntFV()
public SparseIntFV(int nbins)
nbins
- the number of bins in each dimensionpublic SparseIntFV(SparseIntArray values)
values
- the array of valuespublic SparseIntFV(int[] 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 SparseIntArray 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 SparseIntFV concatenate(SparseIntFV... ins)
Concatenatable
concatenate
in interface Concatenatable<SparseIntFV,SparseIntFV>
ins
- the inputspublic SparseIntFV concatenate(List<SparseIntFV> ins)
Concatenatable
concatenate
in interface Concatenatable<SparseIntFV,SparseIntFV>
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 SparseIntFV newInstance()
FeatureVector
newInstance
in interface FeatureVector