public class ByteFV extends ArrayFeatureVector<byte[]> implements Concatenatable<ByteFV,ByteFV>, Cloneable
values
Constructor and Description |
---|
ByteFV()
Construct an empty feature vector
|
ByteFV(byte[] values)
Construct from flattened values array and dimensions
|
ByteFV(int nbins)
Construct empty FV with given number of bins
|
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.
|
ByteFV |
clone() |
double |
compare(ByteFV h,
ByteFVComparison method)
Compare this FV to another with the given method.
|
ByteFV |
concatenate(ByteFV... ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
ByteFV |
concatenate(List<ByteFV> ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
boolean |
equals(Object obj) |
byte |
get(int x)
Get the element at the given flat index
|
double |
getAsDouble(int i)
Get an element of the feature as a double value
|
int |
hashCode() |
int |
length()
Get the length of this vector
|
ByteFV |
newInstance()
Construct a new instance of this featurevector.
|
DoubleFV |
normaliseFV()
Normalise the FV to unit area.
|
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
|
ByteFV |
subvector(int beginIndex)
Returns a new featurevector that is a subsequence of this vector.
|
ByteFV |
subvector(int beginIndex,
int endIndex)
Returns a new string that is a subvector of this vector.
|
String |
toString() |
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.
|
getVector
public ByteFV()
public ByteFV(int nbins)
nbins
- the number of bins in each dimensionpublic ByteFV(byte[] values)
values
- the flat array of valuespublic byte get(int x)
x
- the flattened element indexpublic DoubleFV normaliseFV(double[] min, double[] max)
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)
normaliseFV
in interface FeatureVector
min
- the minimum expected valuemax
- the maximum expected valuepublic DoubleFV normaliseFV()
normaliseFV
in interface FeatureVector
public DoubleFV normaliseFV(double p)
normaliseFV
in interface FeatureVector
p
- the norm to computepublic DoubleFV asDoubleFV()
asDoubleFV
in interface FeatureVector
public double[] asDoubleVector()
asDoubleVector
in interface FeatureVector
public double compare(ByteFV h, ByteFVComparison method)
h
- the feature to compare against.method
- the method to compare with.public int length()
FeatureVector
length
in interface FeatureVector
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 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 ByteFV concatenate(ByteFV... ins)
Concatenatable
concatenate
in interface Concatenatable<ByteFV,ByteFV>
ins
- the inputspublic ByteFV concatenate(List<ByteFV> ins)
Concatenatable
concatenate
in interface Concatenatable<ByteFV,ByteFV>
ins
- the inputspublic ByteFV subvector(int beginIndex)
ArrayFeatureVector
subvector
in class ArrayFeatureVector<byte[]>
beginIndex
- the beginning index, inclusive.public ByteFV subvector(int beginIndex, int endIndex)
ArrayFeatureVector
beginIndex
and extends to the
element at index endIndex - 1
. Thus the length of the
subvector is endIndex-beginIndex
.subvector
in class ArrayFeatureVector<byte[]>
beginIndex
- the beginning index, inclusive.endIndex
- the ending index, exclusive.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 ByteFV newInstance()
FeatureVector
newInstance
in interface FeatureVector