|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.models.AbstractModel
de.jstacs.models.NormalizableScoringFunctionModel
public class NormalizableScoringFunctionModel
This model can be used to use a NormalizableScoringFunction as model. It enables the user to train the NormalizableScoringFunction in a generative way.
NormalizableScoringFunction,
LogGenDisMixFunction| Field Summary | |
|---|---|
protected NormalizableScoringFunction |
nsf
The internally used NormalizableScoringFunction. |
| Fields inherited from class de.jstacs.models.AbstractModel |
|---|
alphabets, length |
| Constructor Summary | |
|---|---|
NormalizableScoringFunctionModel(NormalizableScoringFunction nsf,
int threads,
byte algo,
AbstractTerminationCondition tc,
double lineps,
double startD)
The main constructor that creates an instance with the user given parameters. |
|
NormalizableScoringFunctionModel(StringBuffer stringBuff)
The standard constructor for the interface Storable. |
|
| Method Summary | |
|---|---|
NormalizableScoringFunctionModel |
clone()
Follows the conventions of Object's clone()-method. |
protected void |
fromXML(StringBuffer xml)
This method should only be used by the constructor that works on a StringBuffer. |
NormalizableScoringFunction |
getFunction()
Returns a copy of the internally used NormalizableScoringFunction. |
String |
getInstanceName()
Should return a short instance name such as iMM(0), BN(2), ... |
double |
getLogPriorTerm()
Returns a value that is proportional to the log of the prior. |
double |
getLogProbFor(Sequence sequence,
int startpos,
int endpos)
Returns the logarithm of the probability of (a part of) the given sequence given the model. |
NumericalResultSet |
getNumericalCharacteristics()
Returns the subset of numerical values that are also returned by Model.getCharacteristics(). |
double |
getProbFor(Sequence sequence,
int startpos,
int endpos)
Returns the probability of (a part of) the given sequence given the model. |
boolean |
isTrained()
Returns true if the model has been trained successfully,
false otherwise. |
void |
setOutputStream(OutputStream o)
Sets the OutputStream that is used e.g. for writing information while training. |
String |
toString()
Should give a simple representation (text) of the model as String
. |
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
void |
train(Sample data,
double[] weights)
Trains the Model object given the data as Sample using
the specified weights. |
| Methods inherited from class de.jstacs.models.AbstractModel |
|---|
emitSample, getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder, getPriorTerm, getProbFor, getProbFor, set, setNewAlphabetContainerInstance, train |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected NormalizableScoringFunction nsf
NormalizableScoringFunction.
| Constructor Detail |
|---|
public NormalizableScoringFunctionModel(NormalizableScoringFunction nsf,
int threads,
byte algo,
AbstractTerminationCondition tc,
double lineps,
double startD)
throws CloneNotSupportedException
nsf - the NormalizableScoringFunction that should be usedthreads - the number of threads that should be used for optimizationalgo - the algorithm that should be used for the optimizationtc - the AbstractTerminationCondition for stopping the optimizationlineps - the line epsilon for stopping the line search in the optimizationstartD - the start distance that should be used initially
CloneNotSupportedException - if nsf can not be cloned
public NormalizableScoringFunctionModel(StringBuffer stringBuff)
throws NonParsableException
Storable.
Creates a new NormalizableScoringFunctionModel out of a StringBuffer.
stringBuff - the StringBuffer to be parsed
NonParsableException - is thrown if the StringBuffer could not be parsed| Method Detail |
|---|
public NormalizableScoringFunctionModel clone()
throws CloneNotSupportedException
AbstractModelObject's clone()-method.
clone in interface Modelclone in class AbstractModelAbstractModel
(the member-AlphabetContainer isn't deeply cloned since
it is assumed to be immutable). The type of the returned object
is defined by the class X directly inherited from
AbstractModel. Hence X's
clone()-method should work as:Object o = (X)super.clone(); o defined by
X that are not of simple data-types like
int, double, ... have to be deeply
copied return o
CloneNotSupportedException - if something went wrong while cloning
public void train(Sample data,
double[] weights)
throws Exception
ModelModel object given the data as Sample using
the specified weights. The weight at position i belongs to the element at
position i. So the array weight should have the number of
sequences in the sample as dimension. (Optionally it is possible to use
weight == null if all weights have the value one.)train(data1); train(data2)
should be a fully trained model over data2 and not over
data1+data2. All parameters of the model were given by the
call of the constructor.
data - the given sequences as Sampleweights - the weights of the elements, each weight should be
non-negative
Exception - if the training did not succeed (e.g. the dimension of
weights and the number of sequences in the
sample do not match)Sample.getElementAt(int),
Sample.ElementEnumerator
public double getProbFor(Sequence sequence,
int startpos,
int endpos)
throws NotTrainedException,
Exception
ModelModel.getProbFor(Sequence, int) by the fact, that the model could be
e.g. homogeneous and therefore the length of the sequences, whose
probability should be returned, is not fixed. Additionally the end
position of the part of the given sequence is given and the probability
of the part from position startpos to endpos
(inclusive) should be returned.
length and the alphabets define the type of
data that can be modeled and therefore both has to be checked.
sequence - the given sequencestartpos - the start position within the given sequenceendpos - the last position to be taken into account
NotTrainedException - if the model is not trained yet
Exception - if the sequence could not be handled (e.g.
startpos > endpos, endpos
> sequence.length, ...) by the model
public double getLogProbFor(Sequence sequence,
int startpos,
int endpos)
throws NotTrainedException,
Exception
ModelModel.getProbFor(Sequence, int, int)
getLogProbFor in interface ModelgetLogProbFor in class AbstractModelsequence - the given sequencestartpos - the start position within the given sequenceendpos - the last position to be taken into account
NotTrainedException - if the model is not trained yet
Exception - if the sequence could not be handled (e.g.
startpos > , endpos
> sequence.length, ...) by the modelModel.getProbFor(Sequence, int, int)
public double getLogPriorTerm()
throws Exception
Model
Exception - if something went wrongModel.getPriorTerm()public String getInstanceName()
Model
public boolean isTrained()
Modeltrue if the model has been trained successfully,
false otherwise.
true if the model has been trained successfully,
false otherwise
public NumericalResultSet getNumericalCharacteristics()
throws Exception
ModelModel.getCharacteristics().
Exception - if some of the characteristics could not be definedpublic String toString()
ModelString
.
toString in interface ModeltoString in class ObjectString
protected void fromXML(StringBuffer xml)
throws NonParsableException
AbstractModelStringBuffer. It is the counter part of Storable.toXML().
fromXML in class AbstractModelxml - the XML representation of the model
NonParsableException - if the StringBuffer is not parsable or the
representation is conflictingAbstractModel.AbstractModel(StringBuffer)public StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.
public final void setOutputStream(OutputStream o)
o=null, than nothing will be written.
o - the OutputStream
public NormalizableScoringFunction getFunction()
throws CloneNotSupportedException
NormalizableScoringFunction.
NormalizableScoringFunction
CloneNotSupportedException - if the internal instance could not be cloned
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||