<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.jstacs.de/index.php?action=history&amp;feed=atom&amp;title=Quick_start%3A_Jstacs_in_a_nutshell</id>
	<title>Quick start: Jstacs in a nutshell - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.jstacs.de/index.php?action=history&amp;feed=atom&amp;title=Quick_start%3A_Jstacs_in_a_nutshell"/>
	<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Quick_start:_Jstacs_in_a_nutshell&amp;action=history"/>
	<updated>2026-04-04T14:01:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://www.jstacs.de/index.php?title=Quick_start:_Jstacs_in_a_nutshell&amp;diff=562&amp;oldid=prev</id>
		<title>Keilwagen: Created page with &quot;This section is for the unpatient who like to directly start using Jstacs without reading the complete cookbook. If you do not belong to this group, you can skip this section.  H...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Quick_start:_Jstacs_in_a_nutshell&amp;diff=562&amp;oldid=prev"/>
		<updated>2012-05-14T07:49:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This section is for the unpatient who like to directly start using Jstacs without reading the complete cookbook. If you do not belong to this group, you can skip this section.  H...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This section is for the unpatient who like to directly start using Jstacs without reading the complete cookbook. If you do not belong to this group, you can skip this section.&lt;br /&gt;
&lt;br /&gt;
Here, we provide code snippets for simple task including reading a data set, creating models and classifiers which might be frequently used. In addition, some of the basic code examples in section \nameref{recipes} may also serve as a basis for a quick start into Jstacs.&lt;br /&gt;
&lt;br /&gt;
For reading a FastA file, we call the constructor of the [http://www.jstacs.de/api-2.0//de/jstacs/data/DNADataSet.html DNADataSet] with the (absolute or relative) path to the FastA file. Subsequently, we can determine the alphabets used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
DNADataSet ds = new DNADataSet( args[0] );&lt;br /&gt;
AlphabetContainer con = ds.getAlphabetContainer();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more detailed information about data sets, sequences, and alphabets, we refer to section [[Starter: Data handling]].&lt;br /&gt;
&lt;br /&gt;
== Statistical models and classifiers using generative learning principles ==&lt;br /&gt;
&lt;br /&gt;
In Jstacs, statistical models that use generative learning principles to infer their parameters implement the interface [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModel.html TrainableStatisticalModel]. For convenience, Jstacs provides the [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModelFactory.html TrainableStatisticalModelFactory], which allows for creating various simple models in an easy manner. Creating for instance a PWM model is just one line of code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
TrainableStatisticalModel pwm = TrainableStatisticalModelFactory.createPWM( con, ds.getElementLength(), 4 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarily other models including inhomogeneous Markov models, permuted Markov models, Bayesian networks, homogeneous Markov models, ZOOPS models, and hidden Markov models can be created using the [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModelFactory.html TrainableStatisticalModelFactory] and the [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/hmm/HMMFactory.html HMMFactory], respectively.&lt;br /&gt;
&lt;br /&gt;
Given some model &amp;lt;code&amp;gt;pwm&amp;lt;/code&amp;gt;, we can directly infer the model parameters based on some data set &amp;lt;code&amp;gt;ds&amp;lt;/code&amp;gt; using the &amp;lt;code&amp;gt;train&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
pwm.train( ds );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the model has been trained, it can be used to score sequences using the &amp;lt;code&amp;gt;getLogProbFor&amp;lt;/code&amp;gt; methods. More information about the interface [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModel.html TrainableStatisticalModel] can be found in section [[First main course: SequenceScores#TrainableStatisticalModels]].&lt;br /&gt;
&lt;br /&gt;
Based on a set of [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModel.html TrainableStatisticalModel] s, for instance two PWM models, we can build a classifier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
AbstractClassifier cl = new TrainSMBasedClassifier( pwm, pwm );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Further statistical models and classifiers ==&lt;br /&gt;
&lt;br /&gt;
Sometimes, we like to learn statistical models by other learning principles that require numerical optimization. For this purpose, Jstacs provides the interface [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/differentiable/DifferentiableStatisticalModel.html DifferentiableStatisticalModel] and the factory [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/differentiable/DifferentiableStatisticalModelFactory.html DifferentiableStatisticalModelFactory] in close analogy to [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModel.html TrainableStatisticalModel] and [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/TrainableStatisticalModelFactory.html TrainableStatisticalModelFactory] (cf. [[First main course: SequenceScores#DifferentiableStatisticalModels]]). Creating a classifier using two PWM models and the maximum supervised posterior learning principle, can be accomplished by calling&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
DifferentiableStatisticalModel pwm = DifferentiableStatisticalModelFactory.createPWM(con, 10, 4);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
GenDisMixClassifierParameterSet pars = new GenDisMixClassifierParameterSet(con,10,(byte)10,1E-9,1E-10,1, false,KindOfParameter.PLUGIN,true,1);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
AbstractClassifier cl = new MSPClassifier( pars, pwm, pwm );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using classifiers ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Based on statistical models, we can build classifiers as we have seen in the previous subsections. The main functionality is predicting the class label of a sequence and assessing the performance of a classifier. For these tasks, Jstacs provides the methods &amp;lt;code&amp;gt;classify&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;evaluate&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
For classifying a sequence, we just call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
byte res = cl.classify( seq );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
on a trained classifier. The method returns numerical class labels starting from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; and in the same order as data is provided for training.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For evaluating the performance of a classifier, we need to compute some performance measures. For convenience, Jstacs provides the possibility of getting a bunch of standard measures including point measures and areas under curves (cf. [[Second main course: Classifiers#Performance_measures]]). Based on such measures, we can directly determine the performance of the classifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
NumericalPerformanceMeasureParameterSet params = PerformanceMeasureParameterSet.createFilledParameters();&lt;br /&gt;
System.out.println( cl.evaluate(params, true, data) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; indicates that an &amp;lt;code&amp;gt;Exception&amp;lt;/code&amp;gt; should be thrown if a measure could not be computed, and &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; is an array of data sets, where the index within this array encodes for the class.&lt;br /&gt;
&lt;br /&gt;
For assessing the performance of a classifier using some repeated procedure of training and testing, Jstacs provides the class [http://www.jstacs.de/api-2.0//de/jstacs/classifiers/assessment/ClassifierAssessment.html ClassifierAssessment] (cf. [[Second main course: Classifiers#Assessment]]).&lt;/div&gt;</summary>
		<author><name>Keilwagen</name></author>
	</entry>
</feed>