package weka.classifiers.bayes;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Vector;
import java.lang.Math;
import java.util.Random;
import weka.classifiers.*;
import weka.classifiers.RandomizableClassifier;
import weka.clusterers.SimpleKMeans;
import weka.core.*;
/*
import weka.core.Attribute;
import weka.core.Capabilities;
import weka.core.DenseInstance;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.SelectedTag;
import weka.core.Tag;
import weka.core.Utils;
*/
import weka.core.Capabilities.Capability;
import weka.core.matrix.DoubleVector;
import weka.core.matrix.Matrix;
//import weka.core.MultiInstanceCapabilitiesHandler;
import weka.estimators.DiscreteHMMEstimator;
import weka.estimators.HMMEstimator;
import weka.estimators.MultivariateNormalEstimator;
import weka.estimators.MultivariateNormalHMMEstimator;
/*
* A hidden Markov Model classifier class.
*/
public class HMM extends weka.classifiers.RandomizableClassifier implements weka.core.OptionHandler, weka.core.MultiInstanceCapabilitiesHandler {
protected class ProbabilityTooSmallException extends Exception
{
/**
*
*/
private static final long serialVersionUID = -2706223192260478060L;
ProbabilityTooSmallException(String s)
{
super(s);
}
}
/** The number of classes */
protected int m_NumStates=6;
protected int m_NumOutputs;
protected int m_OutputDimension = 1;
protected boolean m_Numeric = false;
protected double m_IterationCutoff = 0.01;
protected int m_SeqAttr = -1;
/*
* gets the index of the data attribute containing the sequence data
*/
public int getSequenceAttribute()
{
return m_SeqAttr;
}
protected Random m_rand = null;
protected double minScale = 1.0E-200;
protected boolean m_RandomStateInitializers = false;
/**
* gets whether the HMM state probabilities are randomly initialized.
* If this is false (default) the states are set using clustering on the
* dataset.
*/
public boolean isRandomStateInitializers() {
return m_RandomStateInitializers;
}
/**
* sets whether the HMM state probabilities are randomly initialized.
* If this is false (default) the states are set using clustering on the
* dataset.
*
* @param randomStateInitializers if true the HMM state probabilities will be initialized randomly, if false they will be initialized using clustering
*/
public void setRandomStateInitializers(boolean randomStateInitializers) {
this.m_RandomStateInitializers = randomStateInitializers;
}
protected boolean m_Tied = false;
/**
* gets whether the covariance matrices of guassian HMMs are tied.
* Tied covariances are the same for all states of the HMM.
* Using tied covariances makes it possible to learn models from less
* data but restricts the class of models that can be learned.
*/
public boolean isTied() {
return m_Tied;
}
/**
* sets whether the covariance matrices of guassian HMMs are tied.
* Tied covariances are the same for all states of the HMM.
* Using tied covariances makes it possible to learn models from less
* data but restricts the class of models that can be learned.
*
* @param tied if true the covariances will be tied
*/
public void setTied(boolean tied) {
m_Tied = tied;
}
/**
* the type of covariance matrices for gaussian HMMs.
* A FULL matrix allows arbitrary dependencies between variables,
* a DIAGONAL matrix assumes that all variables are independent.
* SPHERICAL models assume that variables are independent and all have
* the same variance. SPHERICAL covariances imply a more restricted
* set of models than DIAGONAL covariances which are more restricted
* than FULL matrices. Restricted models require less data to learn
* but may not be able to model all features of the data.
*/
public static final Tag [] TAGS_COVARIANCE_TYPE = {
new Tag(MultivariateNormalEstimator.COVARIANCE_FULL, "Full matrix (unconstrianed)"),
new Tag(MultivariateNormalEstimator.COVARIANCE_DIAGONAL, "Diagonal matrix (no correlation between data attributes)"),
new Tag(MultivariateNormalEstimator.COVARIANCE_SPHERICAL, "Spherical matrix (all attributes have the same variance)"),
};
protected int m_CovarianceType = MultivariateNormalEstimator.COVARIANCE_FULL;
/**
* get the type of covariance matrices for gaussian HMMs.
* A FULL matrix allows arbitrary dependencies between variables,
* a DIAGONAL matrix assumes that all variables are independent.
* SPHERICAL models assume that variables are independent and all have
* the same variance. SPHERICAL covariances imply a more restricted
* set of models than DIAGONAL covariances which are more restricted
* than FULL matrices. Restricted models require less data to learn
* but may not be able to model all features of the data.
*
*/
public SelectedTag getCovarianceType() {
return new SelectedTag(m_CovarianceType, TAGS_COVARIANCE_TYPE);
}
/**
* set the type of covariance matrices for gaussian HMMs.
* A FULL matrix allows arbitrary dependencies between variables,
* a DIAGONAL matrix assumes that all variables are independent.
* SPHERICAL models assume that variables are independent and all have
* the same variance. SPHERICAL covariances imply a more restricted
* set of models than DIAGONAL covariances which are more restricted
* than FULL matrices. Restricted models require less data to learn
* but may not be able to model all features of the data.
*
* @param covarianceType the covariance type (possibilities are COVARIANCE_FULL, COVARIANCE_DIAGONAL, COVARIANCE_SPHERICAL)
*/
public void setCovarianceType(SelectedTag covarianceType) {
if (covarianceType.getTags() == TAGS_COVARIANCE_TYPE) {
m_CovarianceType = covarianceType.getSelectedTag().getID();
}
}
protected boolean m_LeftRight = false;
/**
* gets whether the HMM has a Left-Right state structure
* In a <em>left-right</em> HMM the sequences of states are always
* passed through in a fixed order (possibly missing
* some states). The alternative is an <em>ergodic model</em> (default) in which
* arbitrary transitions can be made.
*/
public boolean isLeftRight() {
return m_LeftRight;
}
/**
* sets whether the HMM has a Left-Right state structure
* In a <em>left-right</em> HMM the sequences of states are always
* passed through in a fixed order (possibly missing
* some states). The alternative is an <em>ergodic model</em> (default) in which
* arbitrary transitions can be made.
*
* @param leftRight if true the HMM will be left-right, if false it will be ergodic
*/
public void setLeftRight(boolean leftRight) {
this.m_LeftRight = leftRight;
}
/*
* gets the dimensionality of the HMM outputs (observations)
*/
public int getOutputDimension() {
return m_OutputDimension;
}
public void setOutputDimension(int OutputDimension) {
m_OutputDimension = OutputDimension;
}
/*
* gets whether the outputs are numeric
*
* @return true if numeric, false if nominal
*/
public boolean isNumeric() {
return m_Numeric;
}
public void setNumeric(boolean Numeric) {
m_Numeric = Numeric;
if (m_Numeric)
setIterationCutoff(0.0001);
else
setIterationCutoff(0.01);
}
/*
* gets the cut off value of terminating the EM iteration.
* The EM iteration will stop when the relative change in likelihood
* between two subsequent iterations falls below this cutoff
*
* @return the cutoff value
*/
public double getIterationCutoff() {
return m_IterationCutoff;
}
/*
* sets the cut off value of terminating the EM iteration.
* The EM iteration will stop when the relative change in likelihood
* between two subsequent iterations falls below this cutoff
*
* @param iterationCutoff the cutoff value
*/
public void setIterationCutoff(double iterationCutoff) {
m_IterationCutoff = iterationCuto
没有合适的资源?快使用搜索试试~ 我知道了~
HMM.zip_HMM java_algorithms_nothingwxh_prediction
共46个文件
html:27个
java:11个
arff:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 155 浏览量
2022-09-15
01:15:21
上传
评论
收藏 133KB ZIP 举报
温馨提示
all algorithms and predicting models will be axcuting in a plateforme use the java langages.
资源推荐
资源详情
资源评论
收起资源包目录
HMM.zip (46个子文件)
NominalSequence.arff 10KB
build.xml 13KB
NumericSequence.arff 35KB
HMM.jar 28KB
Description.props 3KB
src
test
java
TestMultivariateNormalHMMEstimator.java 5KB
TestHMMClassifiers.java 41KB
TestDiscreteHMMEstimator.java 11KB
TestMultivariateNormalEstimator.java 6KB
main
java
weka
core
matrix
SerializableDoubleVector.java 407B
classifiers
bayes
HMM.java 44KB
estimators
DiscreteHMMEstimator.java 5KB
MultivariateNormalHMMEstimator.java 8KB
MultivariateNormalEstimator.java 8KB
AbstractHMMEstimator.java 2KB
HMMEstimator.java 3KB
doc
package-list 56B
weka
core
matrix
package-summary.html 6KB
package-frame.html 876B
package-tree.html 6KB
SerializableDoubleVector.html 21KB
classifiers
bayes
package-summary.html 6KB
package-frame.html 858B
package-tree.html 7KB
HMM.html 55KB
estimators
DiscreteHMMEstimator.html 33KB
package-summary.html 7KB
MultivariateNormalEstimator.html 23KB
package-frame.html 2KB
package-tree.html 7KB
HMMEstimator.html 23KB
MultivariateNormalHMMEstimator.html 41KB
AbstractHMMEstimator.html 14KB
deprecated-list.html 5KB
help-doc.html 9KB
allclasses-frame.html 2KB
overview-summary.html 5KB
index.html 3KB
allclasses-noframe.html 1KB
resources
inherit.gif 57B
serialized-form.html 43KB
overview-frame.html 1KB
stylesheet.css 1KB
constant-values.html 7KB
index-all.html 47KB
overview-tree.html 9KB
共 46 条
- 1
资源评论
邓凌佳
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功