|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectLBJ2.learn.SparseWeightVector
public class SparseWeightVector
This class is used as a weight vector in sparse learning algorithms.
Features are associated with Doubles and/or with
double[]s representing the weights of the features they
produce. Features not appearing in the vector are assumed to have the
defaultWeight.
| Nested Class Summary | |
|---|---|
protected class |
SparseWeightVector.WeightIterator
This class simultaneously iterates over the features in the given vector and their corresponding weights from a SparseWeightVector. |
| Field Summary | |
|---|---|
protected static double |
defaultWeight
When a feature appears in an example but not in this vector, it is assumed to have this weight. |
protected java.util.HashMap |
weights
The weights in the vector indexed by Feature. |
| Constructor Summary | |
|---|---|
SparseWeightVector()
Simply instantiates weights. |
|
SparseWeightVector(java.util.HashMap w)
Simply initializes weights. |
|
| Method Summary | |
|---|---|
void |
clear()
Empties the weight map. |
java.lang.Object |
clone()
Returns a copy of this SparseWeightVector in which the
weights variable has been cloned deeply. |
double |
dot(FeatureVector example)
Takes the dot product of this SparseWeightVector with the
argument vector, using the hard coded default weight. |
double |
dot(FeatureVector example,
double defaultW)
Takes the dot product of this SparseWeightVector with the
argument vector, using the specified default weight when one is not yet
present in this vector. |
void |
scaledAdd(FeatureVector example)
Self-modifying vector addition. |
void |
scaledAdd(FeatureVector example,
double factor)
Self-modifying vector addition where the argument vector is first scaled by the given factor. |
void |
scaledAdd(FeatureVector example,
double factor,
double defaultW)
Self-modifying vector addition where the argument vector is first scaled by the given factor. |
java.lang.String |
toString()
Converts this SparseWeightVector into a
String. |
SparseWeightVector.WeightIterator |
weightIterator(FeatureVector example)
Produces an iterator that accesses the data in this vector associated with the features in the argument vector. |
void |
write(java.io.PrintStream out)
Outputs the contents of this SparseWeightVector into the
specified PrintStream. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final double defaultWeight
protected java.util.HashMap weights
Feature.
| Constructor Detail |
|---|
public SparseWeightVector()
weights.
public SparseWeightVector(java.util.HashMap w)
weights.
w - A map of weights.| Method Detail |
|---|
public SparseWeightVector.WeightIterator weightIterator(FeatureVector example)
example - A vector of features extracted from an example object.
public double dot(FeatureVector example)
SparseWeightVector with the
argument vector, using the hard coded default weight.
example - A vector of features extracted from an example object.
public double dot(FeatureVector example,
double defaultW)
SparseWeightVector with the
argument vector, using the specified default weight when one is not yet
present in this vector.
example - A vector of features extracted from an example object.defaultW - The default weight.
public void scaledAdd(FeatureVector example)
example - A vector of features extracted from an example object.
public void scaledAdd(FeatureVector example,
double factor)
example - A vector of features extracted from an example object.factor - The scaling factor.
public void scaledAdd(FeatureVector example,
double factor,
double defaultW)
example - A vector of features extracted from an example object.factor - The scaling factor.defaultW - An initial weight for previously unseen features.public void clear()
public java.lang.String toString()
SparseWeightVector into a
String.
toString in class java.lang.ObjectString holding a textual representation of this
vector.public void write(java.io.PrintStream out)
SparseWeightVector into the
specified PrintStream. This method merely writes the value
returned by toString().
out - The stream to output into.public java.lang.Object clone()
SparseWeightVector in which the
weights variable has been cloned deeply.
clone in class java.lang.ObjectSparseWeightVector.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||