cc.mallet.types.InstanceList.getTargetAlphabet()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中cc.mallet.types.InstanceList.getTargetAlphabet()方法的一些代码示例,展示了InstanceList.getTargetAlphabet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InstanceList.getTargetAlphabet()方法的具体详情如下:
包路径:cc.mallet.types.InstanceList
类名称:InstanceList
方法名:getTargetAlphabet

InstanceList.getTargetAlphabet介绍

[英]Returns the Alphabet mapping target output labels to integers.
[中]返回将目标输出标签映射到整数的Alphabet

代码示例

代码示例来源:origin: com.github.steveash.mallet/mallet

public Alphabet[] getAlphabets () {
  return new Alphabet[] {getDataAlphabet(), getTargetAlphabet() };
}

代码示例来源:origin: cc.mallet/mallet

public Alphabet[] getAlphabets () {
  return new Alphabet[] {getDataAlphabet(), getTargetAlphabet() };
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Alphabet[] getAlphabets () {
  return new Alphabet[] {getDataAlphabet(), getTargetAlphabet() };
}

代码示例来源:origin: cc.mallet/mallet

public RankedFeatureVector newRankedFeatureVector (InstanceList ilist)
{
  assert (ilist.getTargetAlphabet() == classifications[0].getAlphabet());
  return new ExpGain (ilist, classifications, gaussianPriorVariance);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public RankedFeatureVector newRankedFeatureVector (InstanceList ilist)
{
  assert (ilist.getTargetAlphabet() == classifications[0].getAlphabet());
  return new ExpGain (ilist, classifications, gaussianPriorVariance);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public RankedFeatureVector newRankedFeatureVector (InstanceList ilist)
{
  assert (ilist.getTargetAlphabet() == classifications[0].getAlphabet());
  return new ExpGain (ilist, classifications, gaussianPriorVariance);
}

代码示例来源:origin: cc.mallet/mallet

/** Replaces the <code>Instance</code> at position <code>index</code>
 * with a new one. */
public void setInstance (int index, Instance instance)
{
  assert (this.getDataAlphabet().equals(instance.getDataAlphabet()));
  assert (this.getTargetAlphabet().equals(instance.getTargetAlphabet()));
  this.set(index, instance);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

/** Replaces the <code>Instance</code> at position <code>index</code>
 * with a new one. */
public void setInstance (int index, Instance instance)
{
  assert (this.getDataAlphabet().equals(instance.getDataAlphabet()));
  assert (this.getTargetAlphabet().equals(instance.getTargetAlphabet()));
  this.set(index, instance);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

/** Replaces the <code>Instance</code> at position <code>index</code>
 * with a new one. */
public void setInstance (int index, Instance instance)
{
  assert (this.getDataAlphabet().equals(instance.getDataAlphabet()));
  assert (this.getTargetAlphabet().equals(instance.getTargetAlphabet()));
  this.set(index, instance);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

/**
 * Calculates the minimum description length of this node, i.e., 
 * the length of the binary encoding that describes the feature 
 * and the split value used at this node
 */
public double getMDL()
{
  int numClasses = m_ilist.getTargetAlphabet().size();
  double mdl = getSize() * getGainRatio().getBaseEntropy();
  mdl += ((numClasses-1) * Math.log(getSize() / 2.0)) / (2 * GainRatio.log2);
  double piPow = Math.pow(Math.PI, numClasses/2.0);
  double gammaVal = Maths.gamma(numClasses/2.0);
  mdl += Math.log(piPow/gammaVal) / GainRatio.log2;
  return mdl;
}

代码示例来源:origin: cc.mallet/mallet

/**
 * Calculates the minimum description length of this node, i.e., 
 * the length of the binary encoding that describes the feature 
 * and the split value used at this node
 */
public double getMDL()
{
  int numClasses = m_ilist.getTargetAlphabet().size();
  double mdl = getSize() * getGainRatio().getBaseEntropy();
  mdl += ((numClasses-1) * Math.log(getSize() / 2.0)) / (2 * GainRatio.log2);
  double piPow = Math.pow(Math.PI, numClasses/2.0);
  double gammaVal = Maths.gamma(numClasses/2.0);
  mdl += Math.log(piPow/gammaVal) / GainRatio.log2;
  return mdl;
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public PerLabelInfoGain (InstanceList ilist)
{
  double[][] pcig = calcPerLabelInfoGains (ilist);
  Alphabet v = ilist.getDataAlphabet();
  int numClasses = ilist.getTargetAlphabet().size();
  ig = new InfoGain[numClasses];
  for (int i = 0; i < numClasses; i++)
    ig[i] = new InfoGain (v, pcig[i]);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public PerLabelFeatureCounts (InstanceList ilist)
{
  dataAlphabet = ilist.getDataAlphabet();
  targetAlphabet = ilist.getTargetAlphabet();
  double[][] counts = calcFeatureCounts (ilist);
  fc = new FeatureCounts[targetAlphabet.size()];
  for (int i = 0; i < fc.length; i++)
    fc[i] = new FeatureCounts (dataAlphabet, counts[i]);
}

代码示例来源:origin: cc.mallet/mallet

public PerLabelFeatureCounts (InstanceList ilist)
{
  dataAlphabet = ilist.getDataAlphabet();
  targetAlphabet = ilist.getTargetAlphabet();
  double[][] counts = calcFeatureCounts (ilist);
  fc = new FeatureCounts[targetAlphabet.size()];
  for (int i = 0; i < fc.length; i++)
    fc[i] = new FeatureCounts (dataAlphabet, counts[i]);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public PerLabelInfoGain (InstanceList ilist)
{
  double[][] pcig = calcPerLabelInfoGains (ilist);
  Alphabet v = ilist.getDataAlphabet();
  int numClasses = ilist.getTargetAlphabet().size();
  ig = new InfoGain[numClasses];
  for (int i = 0; i < numClasses; i++)
    ig[i] = new InfoGain (v, pcig[i]);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public PerLabelFeatureCounts (InstanceList ilist)
{
  dataAlphabet = ilist.getDataAlphabet();
  targetAlphabet = ilist.getTargetAlphabet();
  double[][] counts = calcFeatureCounts (ilist);
  fc = new FeatureCounts[targetAlphabet.size()];
  for (int i = 0; i < fc.length; i++)
    fc[i] = new FeatureCounts (dataAlphabet, counts[i]);
}

代码示例来源:origin: cc.mallet/mallet

public PerLabelInfoGain (InstanceList ilist)
{
  double[][] pcig = calcPerLabelInfoGains (ilist);
  Alphabet v = ilist.getDataAlphabet();
  int numClasses = ilist.getTargetAlphabet().size();
  ig = new InfoGain[numClasses];
  for (int i = 0; i < numClasses; i++)
    ig[i] = new InfoGain (v, pcig[i]);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public LabelVector targetLabelDistribution ()
{
  if (this.size() == 0) return null;
  if (!(get(0).getTarget() instanceof Labeling))
    throw new IllegalStateException ("Target is not a labeling.");
  double[] counts = new double[getTargetAlphabet().size()];
  for (int i = 0; i < this.size(); i++) {
    Instance instance =  get(i);
    Labeling l = (Labeling) instance.getTarget();
    l.addTo (counts, getInstanceWeight(i));
  }
  return new LabelVector ((LabelAlphabet)getTargetAlphabet(), counts);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public LabelVector targetLabelDistribution ()
{
  if (this.size() == 0) return null;
  if (!(get(0).getTarget() instanceof Labeling))
    throw new IllegalStateException ("Target is not a labeling.");
  double[] counts = new double[getTargetAlphabet().size()];
  for (int i = 0; i < this.size(); i++) {
    Instance instance =  get(i);
    Labeling l = (Labeling) instance.getTarget();
    l.addTo (counts, getInstanceWeight(i));
  }
  return new LabelVector ((LabelAlphabet)getTargetAlphabet(), counts);
}

代码示例来源:origin: cc.mallet/mallet

public LabelVector targetLabelDistribution ()
{
  if (this.size() == 0) return null;
  if (!(get(0).getTarget() instanceof Labeling))
    throw new IllegalStateException ("Target is not a labeling.");
  double[] counts = new double[getTargetAlphabet().size()];
  for (int i = 0; i < this.size(); i++) {
    Instance instance =  get(i);
    Labeling l = (Labeling) instance.getTarget();
    l.addTo (counts, getInstanceWeight(i));
  }
  return new LabelVector ((LabelAlphabet)getTargetAlphabet(), counts);
}

相关文章

微信公众号

最新文章

更多