|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.labs.minion.classification.WeightedFeatureVector
public class WeightedFeatureVector
A class for holding a weighted feature vector. Such a vector may hold features drawn from a single index partition or features drawn from a number of index partitions. It is up to the user of the class to keep track of how each vector is used!
| Field Summary | |
|---|---|
protected static java.lang.String |
logTag
|
protected int |
nFeat
The number of features in our vector. |
protected boolean |
normalized
Whether we've been normalized. |
protected FeatureCluster[] |
v
An array to hold the features clusters that make up our vector. |
| Constructor Summary | |
|---|---|
WeightedFeatureVector(java.util.Collection<FeatureCluster> c)
Creates a feature vector from a collection of feature clusters. |
|
WeightedFeatureVector(FeatureClusterSet fcs,
float[] weights)
Creates a feature vector from a collection of feature clusters and some associated weights |
|
WeightedFeatureVector(int nFeat)
Creates a feature vector that can hold a certain number of features. |
|
WeightedFeatureVector(WeightedFeatureVector fv)
Creates a feature vector that's a copy of the given vector. |
|
| Method Summary | |
|---|---|
void |
add(FeatureCluster f)
Adds a feature to this vector. |
WeightedFeatureVector |
add(WeightedFeatureVector fv)
Adds a feature vector to this vector, returning a new vector. |
WeightedFeatureVector |
add(WeightedFeatureVector fv,
float fac1,
float fac2,
boolean dropNegative)
Adds a feature vector to this vector, returning a new vector. |
float |
dot(WeightedFeatureVector fv)
Calculate the dot product of this feature vector and another feature vector. |
FeatureCluster |
getCluster(java.lang.String name)
|
static WeightedFeatureVector |
getCrossPartition(java.util.List vecs,
FeatureClusterSet clusters)
Given a number of partition-specific feature vectors, generate a new, cross-partition feature vector. |
FeatureClusterSet |
getSet()
Gets a sorted set of features. |
WeightedFeature[] |
getWeightedFeatures()
Gets an array of weighted feature from this WeightedFeatureVector. |
float |
length()
Gets the euclidean length of this vector. |
WeightedFeatureVector |
mult(float s)
Multiplies a feature vector by a scalar, producing a new vector. |
void |
normalize()
Normalizes the length of this vector to 1. |
int |
size()
Gets the size of this vector, which is the number of features it contains. |
WeightedFeatureVector |
sub(WeightedFeatureVector fv)
Subtracts a feature vector from this vector, returning a new vector. |
WeightedFeatureVector |
sub(WeightedFeatureVector fv,
boolean dropNegative)
Subtracts a feature vector from this vector, returning a new vector. |
WeightedFeatureVector |
sub(WeightedFeatureVector fv,
float fac1,
float fac2,
boolean dropNegative)
Subtracts a feature vector from this vector, returning a new vector. |
java.lang.String |
toString()
|
java.lang.String |
toString(int t)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected FeatureCluster[] v
protected int nFeat
protected boolean normalized
protected static java.lang.String logTag
| Constructor Detail |
|---|
public WeightedFeatureVector(java.util.Collection<FeatureCluster> c)
c - a collection of feature clusters from which we should make
a feature vector.
public WeightedFeatureVector(FeatureClusterSet fcs,
float[] weights)
fcs - a collection of feature clustersweights - weights associated with the clusterspublic WeightedFeatureVector(int nFeat)
nFeat - the initial number of featurespublic WeightedFeatureVector(WeightedFeatureVector fv)
fv - the vector that we want to copy| Method Detail |
|---|
public int size()
public void add(FeatureCluster f)
f - the feature clusterpublic FeatureCluster getCluster(java.lang.String name)
public WeightedFeatureVector add(WeightedFeatureVector fv,
float fac1,
float fac2,
boolean dropNegative)
fv - the vector to add to this one.fac1 - a factor to apply to the weights in this vectorfac2 - a factor to apply to the weights in the other vectordropNegative - if true features with a negative
weight are left out of the resulting vector
public WeightedFeatureVector add(WeightedFeatureVector fv)
fv - the vector to add to this one.
public WeightedFeatureVector sub(WeightedFeatureVector fv,
float fac1,
float fac2,
boolean dropNegative)
fv - the vector to subtract from this one.fac1 - a factor to apply to the weights in this vectorfac2 - a factor to apply to the weights in the other vectordropNegative - if true features with a negative
weight are left out of the resulting vector
public WeightedFeatureVector sub(WeightedFeatureVector fv)
fv - the vector to subtract from this one.
public WeightedFeatureVector sub(WeightedFeatureVector fv,
boolean dropNegative)
fv - the vector to subtract from this one.dropNegative - if true features with a negative
weight are left out of the resulting vector
public WeightedFeatureVector mult(float s)
s - a scalar that we want to multiply the weights by
public float dot(WeightedFeatureVector fv)
fv - another weighted feature vector
public WeightedFeature[] getWeightedFeatures()
public void normalize()
public float length()
public FeatureClusterSet getSet()
public static WeightedFeatureVector getCrossPartition(java.util.List vecs,
FeatureClusterSet clusters)
Note that this could be done using straightforward addition, but this will be more efficient in space and time.
vecs - a list of weighted feature vectors from a number of
partitionsclusters - the clusters that we want to make cross partition
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(int t)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||