|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.sequenceScores.statisticalModels.trainable.AbstractTrainableStatisticalModel
de.jstacs.sequenceScores.statisticalModels.trainable.VariableLengthWrapperTrainSM
public class VariableLengthWrapperTrainSM
This class allows to train any TrainableStatisticalModel
on DataSet
s of Sequence
s with
variable length if each individual length is at least SequenceScore.getLength()
. All other methods
are piped to the internally used TrainableStatisticalModel
.
This class might be useful in any ClassifierAssessment
.
DataSet.WeightedDataSetFactory.DataSet.WeightedDataSetFactory(DataSet.WeightedDataSetFactory.SortOperation, DataSet, double[], int)
,
ClassifierAssessment
Field Summary |
---|
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.AbstractTrainableStatisticalModel |
---|
alphabets, length |
Constructor Summary | |
---|---|
VariableLengthWrapperTrainSM(StringBuffer stringBuff)
The standard constructor for the interface Storable . |
|
VariableLengthWrapperTrainSM(TrainableStatisticalModel m)
This is the main constructor that creates an instance from any TrainableStatisticalModel . |
Method Summary | |
---|---|
VariableLengthWrapperTrainSM |
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 . |
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 SequenceScore.getCharacteristics() . |
boolean |
isInitialized()
This method can be used to determine whether the instance is initialized. |
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
void |
train(DataSet data,
double[] weights)
Trains the TrainableStatisticalModel object given the data as DataSet using
the specified weights. |
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.AbstractTrainableStatisticalModel |
---|
check, emitDataSet, getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getMaximalMarkovOrder, train |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.trainable.TrainableStatisticalModel |
---|
toString |
Constructor Detail |
---|
public VariableLengthWrapperTrainSM(TrainableStatisticalModel m) throws CloneNotSupportedException
TrainableStatisticalModel
.
m
- the model
CloneNotSupportedException
- if the mode m
could not be clonedpublic VariableLengthWrapperTrainSM(StringBuffer stringBuff) throws NonParsableException
Storable
.
Creates a new VariableLengthWrapperTrainSM
out of a StringBuffer
.
stringBuff
- the StringBuffer
to be parsed
NonParsableException
- is thrown if the StringBuffer
could not be parsedMethod Detail |
---|
public VariableLengthWrapperTrainSM clone() throws CloneNotSupportedException
AbstractTrainableStatisticalModel
Object
's clone()
-method.
clone
in interface SequenceScore
clone
in interface TrainableStatisticalModel
clone
in class AbstractTrainableStatisticalModel
AbstractTrainableStatisticalModel
(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
AbstractTrainableStatisticalModel
. 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 cloningprotected void fromXML(StringBuffer xml) throws NonParsableException
AbstractTrainableStatisticalModel
StringBuffer
. It is the counter part of Storable.toXML()
.
fromXML
in class AbstractTrainableStatisticalModel
xml
- the XML representation of the model
NonParsableException
- if the StringBuffer
is not parsable or the
representation is conflictingAbstractTrainableStatisticalModel.AbstractTrainableStatisticalModel(StringBuffer)
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
public String getInstanceName()
SequenceScore
public double getLogPriorTerm() throws Exception
StatisticalModel
Exception
- if something went wrongpublic NumericalResultSet getNumericalCharacteristics() throws Exception
SequenceScore
SequenceScore.getCharacteristics()
.
Exception
- if some of the characteristics could not be definedpublic double getLogProbFor(Sequence sequence, int startpos, int endpos) throws NotTrainedException, Exception
StatisticalModel
StatisticalModel.getLogProbFor(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
> sequence.length
, ...) by the modelpublic boolean isInitialized()
SequenceScore
SequenceScore.getLogScoreFor(Sequence)
.
true
if the instance is initialized, false
otherwisepublic void train(DataSet data, double[] weights) throws Exception
TrainableStatisticalModel
TrainableStatisticalModel
object given the data as DataSet
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 DataSet
weights
- 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)DataSet.getElementAt(int)
,
DataSet.ElementEnumerator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |