FAQs: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== Handling data == | == Handling data == | ||
Also have a look at the code example [[Loading data]]. | |||
<p> | <p> | ||
'''Q: How do I create an [http://www.jstacs.de/api/de/jstacs/data/AlphabetContainer.html AlphabetContainer] instance for DNA sequences?'''<br /> | '''Q: How do I create an [http://www.jstacs.de/api/de/jstacs/data/AlphabetContainer.html AlphabetContainer] instance for DNA sequences?'''<br /> | ||
Line 27: | Line 28: | ||
== Using existing models == | == Using existing models == | ||
Also have a look at code examples [[Training a classifier and classifying new sequences]], [[Performing a 10-fold cross validation]] and [[Saving and loading a model]]. | |||
<p> | <p> | ||
'''Q: Where do I find a list of the models currently implemented in Jstacs?'''<br /> | '''Q: Where do I find a list of the models currently implemented in Jstacs?'''<br /> | ||
Line 35: | Line 37: | ||
<p> | <p> | ||
'''Q: I decided for two [http://www.jstacs.de/api/de/jstacs/models/Model.html Models]. How do I learn them and classify new data?'''<br /> | '''Q: I decided for two [http://www.jstacs.de/api/de/jstacs/models/Model.html Models]. How do I learn them and classify new data?'''<br /> | ||
'''A:''' You can create a new [http://www.jstacs.de/api/de/jstacs/classifier/modelBased/ModelBasedClassifier.html ModelBasedClassifier] from your models and use its [http://www.jstacs.de/api/de/jstacs/classifier/modelBased/ModelBasedClassifier.html#train(de.jstacs.data.Sample%5B%5D,%20double%5B%5D%5B%5D) train] and [http://www.jstacs.de/api/de/jstacs/classifier/modelBased/ModelBasedClassifier.html#classify(de.jstacs.data.Sample) classify] methods. If you only want to learn a model from data, e.g. to sample new sequences, you can also directly use the [http://www.jstacs.de/api/de/jstacs/models/Model.html#train(de.jstacs.data.Sample) train] method of the [http://www.jstacs.de/api/de/jstacs/models/Model.html Model]. | '''A:''' You can create a new [http://www.jstacs.de/api/de/jstacs/classifier/modelBased/ModelBasedClassifier.html ModelBasedClassifier] from your models and use its [http://www.jstacs.de/api/de/jstacs/classifier/modelBased/ModelBasedClassifier.html#train(de.jstacs.data.Sample%5B%5D,%20double%5B%5D%5B%5D) train] and [http://www.jstacs.de/api/de/jstacs/classifier/modelBased/ModelBasedClassifier.html#classify(de.jstacs.data.Sample) classify] methods. If you only want to learn a model from data, e.g. to sample new sequences, you can also directly use the [http://www.jstacs.de/api/de/jstacs/models/Model.html#train(de.jstacs.data.Sample) train] method of the [http://www.jstacs.de/api/de/jstacs/models/Model.html Model].<br /> | ||
Also see the [[Training a classifier and classifying new sequences | code example]]. | |||
</p> | </p> | ||
<hr /> | <hr /> | ||
Line 41: | Line 44: | ||
'''Q: I decided for two [http://www.jstacs.de/api/de/jstacs/scoringFunctions/ScoringFunction.html ScoringFunctions]. How do I learn them and classify new data?'''<br /> | '''Q: I decided for two [http://www.jstacs.de/api/de/jstacs/scoringFunctions/ScoringFunction.html ScoringFunctions]. How do I learn them and classify new data?'''<br /> | ||
'''A:''' You can create a new [http://www.jstacs.de/api/de/jstacs/classifier/scoringFunctionBased/ScoreClassifier.html ScoreClassifier] from your scoring functions and use its [http://www.jstacs.de/api/de/jstacs/classifier/scoringFunctionBased/ScoreClassifier.html#train(de.jstacs.data.Sample%5B%5D,%20double%5B%5D%5B%5D) train] and [http://www.jstacs.de/api/de/jstacs/classifier/AbstractScoreBasedClassifier.html#classify(de.jstacs.data.Sequence)) classify] methods. | '''A:''' You can create a new [http://www.jstacs.de/api/de/jstacs/classifier/scoringFunctionBased/ScoreClassifier.html ScoreClassifier] from your scoring functions and use its [http://www.jstacs.de/api/de/jstacs/classifier/scoringFunctionBased/ScoreClassifier.html#train(de.jstacs.data.Sample%5B%5D,%20double%5B%5D%5B%5D) train] and [http://www.jstacs.de/api/de/jstacs/classifier/AbstractScoreBasedClassifier.html#classify(de.jstacs.data.Sequence)) classify] methods. | ||
</p> | |||
<hr /> | |||
<p> | |||
'''Q: I have to decide, which model is best for my classification task. How do I assess different model combinations or classifiers?'''<br /> | |||
'''A:''' You can use the subclasses of [http://www.jstacs.de/api/de/jstacs/classifier/assessment/ClassifierAssessment.html ClassifierAssessment], e.g. [http://www.jstacs.de/api/de/jstacs/classifier/assessment/KFoldCrossValidation.html KFoldCrossValidation]. All [http://www.jstacs.de/api/de/jstacs/classifier/assessment/ClassifierAssessment.html ClassifierAssessments] have a constructor that accepts an array of classifiers (or [http://www.jstacs.de/api/de/jstacs/models/Model.html Models]). You can then use the [http://www.jstacs.de/api/de/jstacs/classifier/assessment/ClassifierAssessment.html#assess(de.jstacs.classifier.MeasureParameters,%20de.jstacs.classifier.assessment.ClassifierAssessmentAssessParameterSet,%20de.jstacs.data.Sample...) assess] method to assess these classifiers on the same data using a number of pre-defined [http://www.jstacs.de/api/de/jstacs/classifier/MeasureParameters.Measure.html performance measures].<br /> | |||
Also see the [[Performing a 10-fold cross validation | code example]] | |||
</p> | </p> | ||
<hr /> | <hr /> | ||
<p> | <p> | ||
'''Q: How can store and load my model, classifier, ...?'''<br /> | '''Q: How can store and load my model, classifier, ...?'''<br /> | ||
'''A:''' All classes that implement [http://www.jstacs.de/api/de/jstacs/Storable.html Storable] have a method [http://www.jstacs.de/api/de/jstacs/Storable.html#toXML() toXML()] that returns a StringBuffer containing the instance as [http://en.wikipedia.org/wiki/XML XML]. Such classes should also have a proper constructor with a single argument StringBuffer. This can be used to create a new instance form a StringBuffer that contains an instance as XML. In addition, The class [http://www.jstacs.de/api/de/jstacs/io/FileManager.html FileManger] allows to read and write StringBuffers to the hard drive. | '''A:''' All classes that implement [http://www.jstacs.de/api/de/jstacs/Storable.html Storable] have a method [http://www.jstacs.de/api/de/jstacs/Storable.html#toXML() toXML()] that returns a StringBuffer containing the instance as [http://en.wikipedia.org/wiki/XML XML]. Such classes should also have a proper constructor with a single argument StringBuffer. This can be used to create a new instance form a StringBuffer that contains an instance as XML. In addition, The class [http://www.jstacs.de/api/de/jstacs/io/FileManager.html FileManger] allows to read and write StringBuffers to the hard drive.<br /> | ||
Also see the [[Saving and loading a model | code example]]. | |||
</p> | </p> | ||
'''Q: Why does Jstacs use XML to save instances?'''<br /> | '''Q: Why does Jstacs use XML to save instances?'''<br /> | ||
Line 53: | Line 63: | ||
<p> | <p> | ||
'''Q: How do I implement a new generative [http://www.jstacs.de/api/de/jstacs/models/Model.html Model]?'''<br /> | '''Q: How do I implement a new generative [http://www.jstacs.de/api/de/jstacs/models/Model.html Model]?'''<br /> | ||
'''A:''' Write an implementation of the [http://www.jstacs.de/api/de/jstacs/models/Model.html Model] interface. For convenience, you can use the abstract [http://www.jstacs.de/api/de/jstacs/models/AbstractModel.html AbstractModel] class with default implementations for many methods. | '''A:''' Write an implementation of the [http://www.jstacs.de/api/de/jstacs/models/Model.html Model] interface. For convenience, you can use the abstract [http://www.jstacs.de/api/de/jstacs/models/AbstractModel.html AbstractModel] class with default implementations for many methods.<br /> | ||
Also see the [[Implementation of a homogeneous Markov model of order 0 based on AbstractModel | code example]]. | |||
</p> | </p> | ||
<hr /> | <hr /> |
Revision as of 12:48, 7 September 2008
Handling data
Also have a look at the code example Loading data.
Q: How do I create an AlphabetContainer instance for DNA sequences?
A: AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
Q: Why shall I use the AlphabetContainer and not just a simple Alphabet instance?
A: Because for some data you will not have the same alphabet at each position of the sequence, e.g. when using phenotypic data. Hence, we also strongly recommend to always use getAlphabetLengthAt(int) when setting e.g. the size of an array.
Q: How can I create a simple sequence?
A: Try to use the create method of Sequence, e.q. Sequence.create( new AlphabetContainer( new DNAAlphabet() ), "ACGTACGT" );
Q: How can I load my own data?
A: If your sequences are stored either in plain text or in FastA format, you can directly create a new Sample from the file.
Q: I wrote some sophisticated method using BioJava to load my data from a Genbank file/a database/somewhere else. How can I do something similar in Jstacs?
A: You can still use your existing method. Jstacs has an adapter for BioJava SequenceIterators.
Using existing models
Also have a look at code examples Training a classifier and classifying new sequences, Performing a 10-fold cross validation and Saving and loading a model.
Q: Where do I find a list of the models currently implemented in Jstacs?
A: All generative models in Jstacs implement the Model interface.
All discriminative models in Jstacs implement the ScoringFunction interface. You find all the existing implementations in the list of implementing classes of these two interfaces.
Q: I decided for two Models. How do I learn them and classify new data?
A: You can create a new ModelBasedClassifier from your models and use its train and classify methods. If you only want to learn a model from data, e.g. to sample new sequences, you can also directly use the train method of the Model.
Also see the code example.
Q: I decided for two ScoringFunctions. How do I learn them and classify new data?
A: You can create a new ScoreClassifier from your scoring functions and use its train and classify methods.
Q: I have to decide, which model is best for my classification task. How do I assess different model combinations or classifiers?
A: You can use the subclasses of ClassifierAssessment, e.g. KFoldCrossValidation. All ClassifierAssessments have a constructor that accepts an array of classifiers (or Models). You can then use the assess method to assess these classifiers on the same data using a number of pre-defined performance measures.
Also see the code example
Q: How can store and load my model, classifier, ...?
A: All classes that implement Storable have a method toXML() that returns a StringBuffer containing the instance as XML. Such classes should also have a proper constructor with a single argument StringBuffer. This can be used to create a new instance form a StringBuffer that contains an instance as XML. In addition, The class FileManger allows to read and write StringBuffers to the hard drive.
Also see the code example.
Q: Why does Jstacs use XML to save instances?
A: Because it is human-readable.
Implementing new models
Q: How do I implement a new generative Model?
A: Write an implementation of the Model interface. For convenience, you can use the abstract AbstractModel class with default implementations for many methods.
Also see the code example.
Q: How do I implement a new discriminative model?
A: Write an implementation of the ScoringFunction interface. For convenience, you can use the abstract AbstractNormalizableScoringFunction class with default implementations for many methods.
Q: How do I implement a model that can be trained generatively and discriminatively?
A: You can either extend AbstractModel and additionally implement the ScoringFunction interface, or you extend the AbstractNormalizableScoringFunction and additionally implement the Model interface.
Reporting bugs and requesting new features
Q: How do I report bugs I found in Jstacs?
A: Before reporting bugs in Jstacs, you should be sure it's not a feature ;-) You can discuss potential issues in the Jstacs forum. You can also have a look at the Bugs that have already been reported. If you are sure that you found a bug, submit a | new ticket to the Jstacs bug tracking system.
Q: How can request new features?
A: You may use the Jstacs forum to discuss your request with other users. Most likely, we will join the discussion, too (We are somewhere out there!).
If you are convinced that the feature you request will be useful for all users of Jstacs, you are invited to submit a new ticket with your request.
Other
Q: The class UserTime does not work! Why?
A: The class UserTime uses native code. Therefore there are at least two possibilities:
- A1: You have forgotten to set the Java library path: -Djava.library.path=...
- A2: You have to compile the native code on your system.