edu.illinois.cs.cogcomp.lbjava.classify.Feature.isDiscrete()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(134)

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

Feature.isDiscrete介绍

[英]Determines if this feature is discrete.
[中]确定此功能是否是离散的。

代码示例

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Returns the strength of this feature if it were to be placed in a mathematical vector space.
 **/
public double getStrength() {
  return (left.isDiscrete() ? 1 : left.getStrength())
      * (right.isDiscrete() ? 1 : right.getStrength());
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Returns a new feature object that's identical to this feature except its strength is given by
 * <code>s</code>.
 *
 * @param s The strength of the new feature.
 * @return A new feature object as above, or <code>null</code> if this feature cannot take the
 *         specified strength.
 **/
public Feature withStrength(double s) {
  RealConjunctiveFeature result = (RealConjunctiveFeature) clone();
  if (!left.isDiscrete()) {
    result.left = left.withStrength(s);
    if (!right.isDiscrete())
      result.right = right.withStrength(1);
  } else
    result.right = right.withStrength(s);
  return result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Returns a new feature object, the same as this one in all respects except the value has been
 * multiplied by the specified number.
 *
 * @param m The multiplier.
 * @return A new real feature whose value is the product of this feature's value and the
 *         specified multiplier.
 **/
public RealFeature multiply(double m) {
  RealConjunctiveFeature result = (RealConjunctiveFeature) clone();
  if (!left.isDiscrete())
    result.left = ((RealFeature) left).multiply(m);
  else
    result.right = ((RealFeature) right).multiply(m);
  return result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * A helper method for {@link #getFeatureKey(Lexicon,boolean,int)}, this method computes the
 * feature keys corresponding to the arguments of the conjunction. Here, we lookup the arguments
 * to the conjunction in the lexicon so that their counts are never less than the conjunction's,
 * and we return the actual feature object that's already a key in the lexicon.
 *
 * @param f The argument feature for which a key will be computed.
 * @param lexicon The lexicon into which this feature will be indexed.
 * @param training Whether or not the learner is currently training.
 * @param label The label of the example containing this feature, or -1 if we aren't doing per
 *        class feature counting.
 * @return A feature object appropriate for use as the key of a map.
 **/
protected Feature getArgumentKey(Feature f, Lexicon lexicon, boolean training, int label) {
  if (f.isDiscrete()) {
    if (!training)
      return f;
    if (!f.isPrimitive())
      f = f.getFeatureKey(lexicon, true, label);
  } else {
    f = f.getFeatureKey(lexicon, training, label);
    if (!training)
      return f;
  }
  return lexicon.getChildFeature(f, label);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

if (!f.isDiscrete())
  inst.setValue(attIndex, exampleValues[featureIndex]);
else { // it's a discrete or conjunctive feature.
if (!label.isDiscrete())
  inst.setValue(0, labelValues[0]);
else

代码示例来源:origin: edu.illinois.cs.cogcomp/saul

System.exit(1);
if (f.isDiscrete())
  inst.setValue(attIndex, "1"); // this feature is used in this example so we set it to "1"
else
if (!label.isDiscrete())
  inst.setValue(0, instance.labelValues[0]);
else

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

Feature f = (Feature) o;
boolean b1 = isDiscrete();
boolean b2 = f.isDiscrete();
int d = (b2 ? 1 : 0) - (b1 ? 1 : 0);
if (d != 0)

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Instantiates a feature vector from example arrays and lexicons.
 *
 * @param ex The example array.
 * @param lex The feature lexicon.
 * @param llex The label lexicon.
 **/
public FeatureVector(Object[] ex, Lexicon lex, Lexicon llex) {
  this();
  int[] fs = (int[]) ex[0];
  double[] vs = (double[]) ex[1];
  for (int i = 0; i < fs.length; ++i) {
    Feature f = lex.lookupKey(fs[i]);
    Feature ff = f.withStrength(vs[i]);
    addFeature(ff == null ? f : ff);
  }
  if (ex.length > 2) {
    int[] ls = (int[]) ex[2];
    double[] lvs = (double[]) ex[3];
    for (int i = 0; i < ls.length; ++i) {
      Feature f = llex.lookupKey(ls[i]);
      if (!f.isDiscrete())
        f = f.withStrength(lvs[i]);
      addLabel(f);
    }
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/saul

} else {
  Feature label = labelLexicon.lookupKey(0);
  if (!label.isDiscrete()) {
    Attribute a = new Attribute(label.getStringIdentifier());
    attributeInfo.addElement(a);
for (int featureIndex = 0; featureIndex < lexicon.size(); ++featureIndex) {
  Feature f = lexicon.lookupKey(featureIndex);
  Attribute a = f.isDiscrete() ?
      new Attribute(f.toString(), binaryValues) :
      new Attribute(f.toString());

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

if (label.isDiscrete())
  labelArray[f] = labelLexicon.lookup(label, true);
else

相关文章