FAQs: Difference between revisions
No edit summary |
No edit summary |
||
Line 35: | Line 35: | ||
<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 | '''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]. | ||
</p> | </p> | ||
<hr /> | <hr /> |
Revision as of 11:10, 7 September 2008
Handling 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
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.
Q: How can store and load my model, classifier, ...?
A: All classes that implement Storable should have a method toXML() that returns a StringBuffer containing the instance as XML. Furthermore, such classes should 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 StringBuffer to the hard drive.
Q: Why does Jstacs use XML to save instances?
A: Because it is human readable.
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.