本文整理汇总了Java中be.ac.ulg.montefiore.run.jahmm.Hmm类的典型用法代码示例。如果您正苦于以下问题:Java Hmm类的具体用法?Java Hmm怎么用?Java Hmm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hmm类属于be.ac.ulg.montefiore.run.jahmm包,在下文中一共展示了Hmm类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFeatureVector
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
@Override
public HMMFeatureVector getFeatureVector(List<ObservationDiscrete<Packet>> representation, String label) {
HMMFeatureVector v = new HMMFeatureVector();
double dMaxProb = -1.0;
//String label = null;
int count = 0;
for(String className : classModel.keySet()) {
Hmm tempModel = classModel.get(className);
double dProb = tempModel.probability(representation);
if(dProb > dMaxProb) {
dMaxProb = dProb;
//label = className;
//v.setLabel(label);
}
v.setProbArrayAtIndex(dProb, count);
count++;
}
v.setLabel(label);
return v;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:25,代码来源:HmmHandler.java
示例2: getFeatureVector
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
@Override
public HMMFeatureVector getFeatureVector(List<ObservationDiscrete<Packet>> representation, String label) {
HMMFeatureVector v = new HMMFeatureVector();
double dMaxProb = -1.0;
//String label = null;
int count = 0;
for(String className : classModel.keySet()) {
Hmm tempModel = classModel.get(className);
double dProb = tempModel.lnProbability(representation);
if(dProb > dMaxProb) {
dMaxProb = dProb;
}
// Here we normalize the probability by dividing it by the respective
// string size. This is due to the fact that the probability decreases
// as the string gets longer and longer.
v.setProbArrayAtIndex(dProb/representation.size(), count);
count++;
}
v.setLabel(label);
return v;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:26,代码来源:NormalizedHmmHandler.java
示例3: learn
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
private <O extends Observation & CentroidFactory<O>> void
learn(RelatedObjs<O> relatedObjs, Reader hmmFileReader,
Reader seqFileReader, Writer hmmFileWriter,
int nbIterations)
throws IOException, FileFormatException
{
List<List<O>> seqs = relatedObjs.readSequences(seqFileReader);
OpdfReader<? extends Opdf<O>> opdfReader = relatedObjs.opdfReader();
OpdfWriter<? extends Opdf<O>> opdfWriter = relatedObjs.opdfWriter();
Hmm<O> initHmm = HmmReader.read(hmmFileReader, opdfReader);
BaumWelchLearner bw = new BaumWelchScaledLearner();
bw.setNbIterations(nbIterations);
Hmm<O> hmm = bw.learn(initHmm, seqs);
HmmWriter.write(hmmFileWriter, opdfWriter, hmm);
}
开发者ID:tanjiti,项目名称:jahmm,代码行数:17,代码来源:BWActionHandler.java
示例4: initializeHMM
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
protected Hmm initializeHMM() {
Hmm<ObservationDiscrete<HMMSequence.Packet>> hmm =
new Hmm<>(2,
new OpdfDiscreteFactory<>(HMMSequence.Packet.class));
// Random initialization (with fixed seed to allow for reproducibility)
Random r = new Random(1L);
double dRnd = r.nextDouble();
hmm.setPi(0, dRnd);
hmm.setPi(1, 1.0 - dRnd);
// hmm.setPi(0, 0.5);
// hmm.setPi(1, 0.5);
// Non-equal probs
hmm.setOpdf(0, new OpdfDiscrete<>(HMMSequence.Packet.class,
new double[]{0.1,0.2,0.3,0.4}));
hmm.setOpdf(1, new OpdfDiscrete<>(HMMSequence.Packet.class,
new double[]{0.4,0.3,0.2,0.1}));
dRnd = r.nextDouble();
hmm.setAij(0, 0, dRnd);
hmm.setAij(0, 1, 1.0 - dRnd);
dRnd = r.nextDouble();
hmm.setAij(1, 0, dRnd);
hmm.setAij(1, 1, 1.0 - dRnd);
return hmm;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:30,代码来源:HmmHandler.java
示例5: read
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
/**
* Reads a HMM from a byte stream.
*
* @param stream Holds the byte stream the HMM is read from.
* @return The {@link be.ac.ulg.montefiore.run.jahmm.Hmm HMM} read.
*/
static public Hmm<?> read(InputStream stream)
throws IOException
{
ObjectInputStream ois = new ObjectInputStream(stream);
try {
return (Hmm) ois.readObject();
}
catch(ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
开发者ID:tanjiti,项目名称:jahmm,代码行数:19,代码来源:HmmBinaryReader.java
示例6: write
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
/**
* Writes a HMM to byte stream.
*
* @param stream Holds the byte stream the HMM is written to.
*/
static public void write(OutputStream stream, Hmm<?> hmm)
throws IOException
{
ObjectOutputStream oos = new ObjectOutputStream(stream);
oos.writeObject(hmm);
}
开发者ID:tanjiti,项目名称:jahmm,代码行数:12,代码来源:HmmBinaryWriter.java
示例7: learn
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public Hmm<ObservationVector> learn(List<ObservationVector> trainingObservations, List<ObservationInteger> trainingStates) {
this.trainingObservations = trainingObservations;
this.trainingStates = trainingStates;
initCounters();
generateCountsFromTraining();
calculateHmmParams();
Hmm<ObservationVector> hmm = new Hmm<ObservationVector>(pi, a,
generateOpdfVectors());
return hmm;
}
开发者ID:claudiotrindade,项目名称:contexttoolkit,代码行数:13,代码来源:HmmSupervisedLearner.java
示例8: main
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public static void main(String[] args) {
// learning HMM
HmmSupervisedLearner learner = new HmmSupervisedLearner(8, 14, 2);
Hmm<ObservationVector> hmm = learner.learn(
new File("demos/home-hmm/kasteren-jahmm-observations.seq"),
new File("demos/home-hmm/kasteren-jahmm-states.seq"));
try {
/*
* Save HMM to file
* Quite slow!
*/
HmmWriter.write(
new FileWriter("demos/home-hmm/kasteren-jahmm.model"),
new OpdfVectorWriter(),
hmm);
/*
* Load HMM from file
* Also slow...but since this is just an init step, it may be ok
* ~6.4s
*/
// long start = System.currentTimeMillis();
// Hmm<ObservationVector> hmm = HmmReader.read(
// new FileReader("demos/home-hmm/kasteren-jahmm.model"),
// new OpdfVectorReader());
// long end = System.currentTimeMillis();
//
// System.out.println("hmm = " + hmm.getPi(0));
// System.out.println("duration = " + (float)(end-start)/1000);
} catch (IOException e) {
e.printStackTrace();
// } catch (FileFormatException e) {
// e.printStackTrace();
}
}
开发者ID:claudiotrindade,项目名称:contexttoolkit,代码行数:37,代码来源:HmmSupervisedLearner.java
示例9: read
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
/**
* Reads a HMM from a byte stream.
*
* @param stream Holds the byte stream the HMM is read from.
* @return The {@link be.ac.ulg.montefiore.run.jahmm.Hmm HMM} read.
*/
static public Hmm<?> read(InputStream stream)
throws IOException
{
ObjectInputStream ois = new ObjectInputStream(stream);
try {
return (Hmm<?>) ois.readObject();
}
catch(ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
开发者ID:claudiotrindade,项目名称:contexttoolkit,代码行数:19,代码来源:HmmBinaryReader.java
示例10: HMMDomainGenerator
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public HMMDomainGenerator(ChipChipData ccd, double[] means, double[] covars, double[][] transition) {
ArrayList<Opdf<ObservationReal>> pdfs = new ArrayList<Opdf<ObservationReal>>();
for (int i = 0; i < numStates; i++) {
pdfs.add(new OpdfGaussian(means[i],
covars[i]));
}
hmm = new Hmm<ObservationReal>(initialProbabilities,
transition,
pdfs);
for (int i = 0; i < numStates; i++) {
System.err.println("pi[" + i + "]=" + hmm.getPi(i));
}
this.ccd = ccd;
}
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:16,代码来源:HMMDomainGenerator.java
示例11: CGHCallExpander
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public CGHCallExpander (ChipChipData data) {
this.data = data;
transition = new double[numStates][numStates];
transition[LOW][LOW] = .98;
transition[LOW][ONE] = .02;
transition[LOW][HIGH] = .00;
transition[ONE][LOW] = .02;
transition[ONE][ONE] = .94;
transition[ONE][HIGH] = .02;
transition[HIGH][LOW] = .00;
transition[HIGH][ONE] = .02;
transition[HIGH][HIGH] = .98;
initialProbabilities = new double[3];
initialProbabilities[LOW] = .01;
initialProbabilities[ONE] = .98;
initialProbabilities[HIGH] = .01;
pdfs = new ArrayList<Opdf<ObservationReal>>();
/* params are mean and variance */
pdfs.add(new OpdfGaussian(defaultParams[0][0],
defaultParams[0][1]));
pdfs.add(new OpdfGaussian(defaultParams[1][0],
defaultParams[1][1]));
pdfs.add(new OpdfGaussian(defaultParams[2][0],
defaultParams[2][1]));
hmm = new Hmm<ObservationReal>(initialProbabilities,
transition,
pdfs);
}
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:31,代码来源:CGHCallExpander.java
示例12: HMMParameterEstimator
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public HMMParameterEstimator(ChipChipData ccd, double[] means, double[] covars, double[][] transition) {
ArrayList<Opdf<ObservationReal>> pdfs = new ArrayList<Opdf<ObservationReal>>();
for (int i = 0; i < 2; i++) {
pdfs.add(new OpdfGaussian(means[i],
covars[i]));
}
hmm = new Hmm<ObservationReal>(initialProbabilities,
transition,
pdfs);
for (int i = 0; i < numStates; i++) {
System.err.println("pi[" + i + "]=" + hmm.getPi(i));
}
this.ccd = ccd;
}
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:16,代码来源:HMMParameterEstimator.java
示例13: getClassModel
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
@Override
public Map<String, Hmm> getClassModel() {
return classModel;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:5,代码来源:HmmHandler.java
示例14: getHmm
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public Hmm<ObservationVector> getHmm() {
return hmm;
}
开发者ID:claudiotrindade,项目名称:contexttoolkit,代码行数:4,代码来源:HmmWrapper.java
示例15: createHmmModel
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
private static Hmm<ObservationDiscrete<MobilityState>> createHmmModel() {
OpdfDiscreteFactory<MobilityState> factory = new OpdfDiscreteFactory<MobilityState>(
MobilityState.class);
Hmm<ObservationDiscrete<MobilityState>> hmm = new Hmm<ObservationDiscrete<MobilityState>>(
MobilityState.values().length, factory);
// Assume we will never have CYCLING and UNKNOWN state
for (MobilityState state : MobilityState.values()) {
if (state.equals(MobilityState.CYCLING) || state.equals(MobilityState.UNKNOWN)) {
hmm.setPi(state.ordinal(), 0);
} else {
hmm.setPi(state.ordinal(),
1.0 / (MobilityState.values().length - 2));
}
}
hmm.setOpdf(MobilityState.STILL.ordinal(),
new OpdfDiscrete<MobilityState>(MobilityState.class,
new double[] { 0.70, 0.005, 0.005, 0.29, 0, 0 }));
hmm.setOpdf(MobilityState.RUN.ordinal(),
new OpdfDiscrete<MobilityState>(MobilityState.class,
new double[] { 0.20, 0.50, 0.10, 0.20, 0 , 0}));
hmm.setOpdf(MobilityState.WALK.ordinal(),
new OpdfDiscrete<MobilityState>(MobilityState.class,
new double[] { 0.20, 0.10, 0.50, 0.20, 0, 0 }));
hmm.setOpdf(MobilityState.DRIVE.ordinal(),
new OpdfDiscrete<MobilityState>(MobilityState.class,
new double[] { 0.28, 0.01, 0.01, 0.70, 0, 0 }));
hmm.setAij(MobilityState.STILL.ordinal(),
MobilityState.STILL.ordinal(), 0.70);
hmm.setAij(MobilityState.STILL.ordinal(), MobilityState.RUN.ordinal(),
0.14);
hmm.setAij(MobilityState.STILL.ordinal(), MobilityState.WALK.ordinal(),
0.15);
hmm.setAij(MobilityState.STILL.ordinal(),
MobilityState.DRIVE.ordinal(), 0.01);
hmm.setAij(MobilityState.STILL.ordinal(),
MobilityState.CYCLING.ordinal(), 0.00);
hmm.setAij(MobilityState.STILL.ordinal(),
MobilityState.UNKNOWN.ordinal(), 0.00);
hmm.setAij(MobilityState.RUN.ordinal(), MobilityState.STILL.ordinal(),
0.10);
hmm.setAij(MobilityState.RUN.ordinal(), MobilityState.RUN.ordinal(),
0.49);
hmm.setAij(MobilityState.RUN.ordinal(), MobilityState.WALK.ordinal(),
0.40);
hmm.setAij(MobilityState.RUN.ordinal(), MobilityState.DRIVE.ordinal(),
0.01);
hmm.setAij(MobilityState.RUN.ordinal(),
MobilityState.CYCLING.ordinal(), 0.00);
hmm.setAij(MobilityState.RUN.ordinal(),
MobilityState.UNKNOWN.ordinal(), 0.00);
hmm.setAij(MobilityState.WALK.ordinal(), MobilityState.STILL.ordinal(),
0.10);
hmm.setAij(MobilityState.WALK.ordinal(), MobilityState.RUN.ordinal(),
0.40);
hmm.setAij(MobilityState.WALK.ordinal(), MobilityState.WALK.ordinal(),
0.49);
hmm.setAij(MobilityState.WALK.ordinal(), MobilityState.DRIVE.ordinal(),
0.01);
hmm.setAij(MobilityState.WALK.ordinal(),
MobilityState.CYCLING.ordinal(), 0.00);
hmm.setAij(MobilityState.WALK.ordinal(),
MobilityState.UNKNOWN.ordinal(), 0.00);
hmm.setAij(MobilityState.DRIVE.ordinal(),
MobilityState.STILL.ordinal(), 0.09);
hmm.setAij(MobilityState.DRIVE.ordinal(), MobilityState.RUN.ordinal(),
0.01);
hmm.setAij(MobilityState.DRIVE.ordinal(), MobilityState.WALK.ordinal(),
0.20);
hmm.setAij(MobilityState.DRIVE.ordinal(),
MobilityState.DRIVE.ordinal(), 0.70);
hmm.setAij(MobilityState.DRIVE.ordinal(),
MobilityState.CYCLING.ordinal(), 0.00);
hmm.setAij(MobilityState.DRIVE.ordinal(),
MobilityState.UNKNOWN.ordinal(), 0.00);
return (hmm);
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:82,代码来源:HMMMobilityRectifier.java
示例16: resetHMM
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
public void resetHMM() {
hmm = new Hmm<ObservationReal>(initialProbabilities,
transition,
pdfs);
}
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:6,代码来源:CGHCallExpander.java
示例17: train
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
@Override
public void train(List<List<ObservationDiscrete<Packet>>> representation, String label) {
Hmm hmmTemp = initializeHMM();
// Train the model based on the observations
BaumWelchLearner bwl = new BaumWelchLearner();
hmmTemp = bwl.learn(hmmTemp, representation);
classModel.put(label, hmmTemp);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:13,代码来源:HmmHandler.java
示例18: cluster
import be.ac.ulg.montefiore.run.jahmm.Hmm; //导入依赖的package包/类
/**
* @param data to cluster - each
* @param n
*/
public void cluster(double[][] data, int n) {
OpdfMultiGaussianFactory factory = new OpdfMultiGaussianFactory(6);
new ObservationVector(data[0]);
Hmm<ObservationVector> hmm = new Hmm<>(6, factory);
List<ObservationVector> sequences = new ArrayList<>();
/* todo
for (double[] row : data)
sequences.add(new ArrayList(new ObservationVector(row)));
//sequences.add(mg.observationSequence(100));
BaumWelchLearner bwl = new BaumWelchLearner();
Hmm<?> learntHmm = bwl.learn(hmm, sequences);
for (int i = 0; i < 10; i++) {
bwl.iterate(learntHmm);
}
List<List<ObservationVector>> sequences2 = new ArrayList<List<ObservationVector>>();
KMeansLearner<ObservationVector> kml =
new KMeansLearner <ObservationVector>(3 , new OpdfMultiGaussianFactory(6) , sequences2);
Hmm <ObservationVector> initHmm = kml.iterate() ;
*/
}
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:39,代码来源:Clustering.java
注:本文中的be.ac.ulg.montefiore.run.jahmm.Hmm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论