public class Feature extends Object
Modifier and Type | Field and Description |
---|---|
int[] |
indexedValues
This will contain the (x,y) pairs for which the feature is non-zero in
case it is sparse.
|
protected Index<IntPair> |
instanceIndex |
protected double |
sum |
Constructor and Description |
---|
Feature() |
Feature(Experiments e,
double[][] vals,
Index<IntPair> instanceIndex) |
Feature(Experiments e,
double[] vals,
Index<IntPair> instanceIndex)
This is if we are given an array of double with a value for each training sample in the order of their occurrence.
|
Feature(Experiments e,
int[] indexes,
double[] vals,
Index<IntPair> instanceIndex) |
Feature(Experiments e,
int numElems,
Index<IntPair> instanceIndex) |
Modifier and Type | Method and Description |
---|---|
double |
ftilde() |
double |
getVal(int index)
Get the value at the index-ed non zero value pair (x,y)
|
double |
getVal(int x,
int y)
This is rarely used because it is slower and requires initHashVals() to be called beforehand
to initialize the hashValues.
|
int |
getX(int index) |
int |
getY(int index) |
void |
initHashVals()
Creates a HashMap with keys indices from pairs (x,y) and values the value of the function at the pair;
required for use of getVal(x,y)
|
int |
len() |
void |
print()
Prints out the points where the feature is non-zero and the values
at these points.
|
void |
print(PrintStream pf) |
void |
setSum() |
void |
setValue(int index,
int key,
double value)
Used to sequentially set the values of a feature -- index is the pace in the arrays ; key goes into
indexedValues, and value goes into valuesI.
|
public int[] indexedValues
protected double sum
public Feature()
public Feature(Experiments e, double[] vals, Index<IntPair> instanceIndex)
public Feature(Experiments e, double[][] vals, Index<IntPair> instanceIndex)
vals
- a value for each (x,y) pairpublic Feature(Experiments e, int numElems, Index<IntPair> instanceIndex)
public Feature(Experiments e, int[] indexes, double[] vals, Index<IntPair> instanceIndex)
indexes
- The pairs (x,y) for which the feature is non-zero. They are coded as x*ySize+yvals
- The values at these points.public void print()
public void setValue(int index, int key, double value)
public void print(PrintStream pf)
public double getVal(int index)
public void setSum()
public int len()
public int getX(int index)
public int getY(int index)
public double getVal(int x, int y)
public void initHashVals()
public double ftilde()