|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcalhoun.analysis.crf.solver.semimarkov.CleanMaximumLikelihoodSemiMarkovGradient
calhoun.analysis.crf.solver.semimarkov.CleanLocalScoreSemiMarkovGradient
public class CleanLocalScoreSemiMarkovGradient
computes an objective function which is the expected value of a local path similarity score on a
semi-Markov model. Requires a CacheProcessor and a LocalPathSimilarityScore to be configured.
maxIters = 1 and requireConvergence = false in your optimizer
to do only a single training iteration, possibly setting the starts to some predetermined value. Each of these
properties can be configured with a filename and each time apply(double[], double[]) is called, the file will be overwritten with
data from the current call. The logging options are:
alphaFile - computation of alpha values for Markov states, includes all nodes and edges.
alphaLengthFile - computation of alpha values for semi-Markov states , includes all segments
betaLengthFile - computation of beta values for semi-Markov states , includes all segments
expectFile - computation of expected values for each Markov feature
expectLengthFile - computation of expected values for each semi-Markov feature
nodeMarginalFile - computation of marginal probability of each state at each position
Instead of always normalizing to 1 we discretize the normalization. We choose an arbitrary normalization factor w, such as 50. The normalization factor at any position is then an integer v, and all entries at that position are alpha[y]*e^(v*w).
The normalization can be computed at any position from 1) Elements of the alpha array are summed s 2) v = log(s)/w. By integer division v will always be an appropriate normalizer. It may be positive or negative. 3) All elements of the array are divided by e^(v*w)
| Field Summary |
|---|
| Fields inherited from class calhoun.analysis.crf.solver.semimarkov.CleanMaximumLikelihoodSemiMarkovGradient |
|---|
ASSERTION_TOLERANCE, debug, NORM_FACTOR, NORM_MAX, NORM_MIN |
| Constructor Summary | |
|---|---|
CleanLocalScoreSemiMarkovGradient()
|
|
| Method Summary | |
|---|---|
double |
apply(double[] param,
double[] grad)
computes the objective function value and the gradient. |
java.lang.String |
getExpectedProductFile()
|
java.lang.String |
getMarginalsFile()
|
LocalPathSimilarityScore |
getScore()
gets the local similarity score function used to score each position in every path. |
java.lang.String |
getScoreAlphaFile()
|
void |
setExpectedProductFile(java.lang.String expectedProductFile)
|
void |
setMarginalsFile(java.lang.String marginalsFile)
|
void |
setScore(LocalPathSimilarityScore score)
sets the local similarity score function used to score each position in every path. |
void |
setScoreAlphaFile(java.lang.String scoreAlphaFile)
|
void |
setTrainingData(ModelManager fm,
java.util.List<? extends TrainingSequence<?>> data)
sets the training data that will be used for evaluation of the objective function. |
| Methods inherited from class calhoun.analysis.crf.solver.semimarkov.CleanMaximumLikelihoodSemiMarkovGradient |
|---|
clean, getAlphaFile, getAlphaLengthFile, getBetaLengthFile, getCacheProcessor, getExpectFile, getExpectLengthFile, getNodeMarginalFile, printNorm, setAlphaFile, setAlphaLengthFile, setBetaLengthFile, setCacheProcessor, setExpectFile, setExpectLengthFile, setNodeMarginalFile |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CleanLocalScoreSemiMarkovGradient()
| Method Detail |
|---|
public void setTrainingData(ModelManager fm,
java.util.List<? extends TrainingSequence<?>> data)
CRFObjectiveFunctionGradientapply
is called to set up the training data. Since it is expected that apply will be called many times, this funtion is
the place to do one time setup and caching.
setTrainingData in interface CRFObjectiveFunctionGradientsetTrainingData in class CleanMaximumLikelihoodSemiMarkovGradientfm - the model to use. Defines the hidden states, transitions, and features.data - the training sequences on which to calculate the objective function.
public double apply(double[] param,
double[] grad)
CRFObjectiveFunctionGradient
apply in interface CRFObjectiveFunctionGradientapply in class CleanMaximumLikelihoodSemiMarkovGradientparam - an array of feature weights to use. The length will equal the number of features in the model, and the values will change
for each call to apply.grad - an array which must be filled with the gradient vector when the function returns. For each feature index, the array should contain an
entry with the partial derivative with respect to that feature.
public LocalPathSimilarityScore getScore()
public void setScore(LocalPathSimilarityScore score)
score - the score function to usepublic java.lang.String getScoreAlphaFile()
public void setScoreAlphaFile(java.lang.String scoreAlphaFile)
public java.lang.String getExpectedProductFile()
public void setExpectedProductFile(java.lang.String expectedProductFile)
public java.lang.String getMarginalsFile()
public void setMarginalsFile(java.lang.String marginalsFile)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||