|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjnisvmlight.FeatureVector
public class FeatureVector
A feature vector. Features are dimension-value pairs. This class implements a simple dictionary data structure to map dimensions onto their values. Note that for convenience, features do not have be sorted according to their dimensions at this point. The SVMLightTrainer class has an option for sorting input vectors prior to training.
| Field Summary | |
|---|---|
protected int[] |
m_dims
|
protected double[] |
m_vals
|
| Constructor Summary | |
|---|---|
FeatureVector(int size)
|
|
FeatureVector(int[] dims,
double[] vals)
|
|
| Method Summary | |
|---|---|
double |
getCosine(FeatureVector v)
Returns the cosine similarity between two feature vectors. |
int |
getDimAt(int index)
|
double |
getL1Norm()
Returns the linear norm factor of this vector's values (i.e., the sum of it's values). |
double |
getL2Norm()
Returns the L2 norm factor of this vector's values. |
double |
getValueAt(int index)
|
void |
normalizeL1()
Performs a linear normalization to the value 1. |
void |
normalizeL1(double norm)
Performs a linear normalization to the given norm value. |
void |
normalizeL2()
Performs an L2 normalization to the value 1. |
void |
setFeatures(int[] dims,
double[] vals)
|
int |
size()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int[] m_dims
protected double[] m_vals
| Constructor Detail |
|---|
public FeatureVector(int size)
public FeatureVector(int[] dims,
double[] vals)
| Method Detail |
|---|
public double getCosine(FeatureVector v)
public int getDimAt(int index)
public double getL1Norm()
public double getL2Norm()
public double getValueAt(int index)
public void normalizeL1()
public void normalizeL1(double norm)
public void normalizeL2()
public void setFeatures(int[] dims,
double[] vals)
public int size()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||