当前位置: 首页>>代码示例>>Java>>正文


Java Feature.getName方法代码示例

本文整理汇总了Java中org.cleartk.ml.Feature.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Feature.getName方法的具体用法?Java Feature.getName怎么用?Java Feature.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cleartk.ml.Feature的用法示例。


在下文中一共展示了Feature.getName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encode

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
public List<NameNumber> encode(Feature feature) {
  StringBuffer buffer = new StringBuffer();
  String name = feature.getName();
  Object value = feature.getValue();
  if (name != null) {
    buffer.append(name);
  }
  if (value != null) {
    if (name != null) {
      buffer.append("_");
    }
    buffer.append(value.toString());
  }

  NameNumber fve = new NameNumber(buffer.toString(), 1.0);
  return Collections.singletonList(fve);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:18,代码来源:StringEncoder.java

示例2: encodeAll

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public TreeFeatureVector encodeAll(Iterable<Feature> features) throws CleartkEncoderException {
  List<Feature> fves = new ArrayList<Feature>();
  LinkedHashMap<String, TreeFeature> trs = new LinkedHashMap<String, TreeFeature>();
  for (Feature feature : features) {
    if (feature instanceof TreeFeature){
      trs.put(feature.getName(), (TreeFeature) feature);
    } else if (feature.getName() != null && feature.getName().matches("^TK.*")) {
      TreeFeature tf = new TreeFeature(feature.getName(), feature.getValue());
      trs.put(feature.getName(), tf);
    } else {
      fves.add(feature);
    }
  }
  FeatureVector f = nameNumberEncoder.encodeAll(fves);
  TreeFeatureVector tfv = new TreeFeatureVector();
  tfv.setFeatures(f);
  tfv.setTrees(trs);
  return tfv;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:21,代码来源:TreeFeatureVectorFeaturesEncoder.java

示例3: encode

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public List<String> encode(Feature feature) throws CleartkEncoderException {
    StringBuilder sb = new StringBuilder();
    if (feature.getName() != null) {
        sb.append(feature.getName()).append(VALUE_DELIMITER);
    }
    sb.append(feature.getValue());
    return ImmutableList.of(sb.toString());
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:10,代码来源:String2StringFeatureEncoder.java

示例4: featureToAttribute

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
/**
 * @param feature
 * @return
 */
private Attribute featureToAttribute(Feature feature) {
  String name = feature.getName();
  Attribute attribute = attributeMap.get(name);
  if (attribute == null) {
    attribute = featureToAttribute(feature, attributes.size());
    attributes.add(attribute);
    attributeMap.put(name, attribute);
  }
  return attribute;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:15,代码来源:WekaFeaturesEncoder.java

示例5: transform

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
protected Feature transform(Feature feature) {
  String featureName = feature.getName();
  MeanStddevTuple stats = this.meanStddevMap.get(featureName);
  double value = ((Number) feature.getValue()).doubleValue();

  double zmus = 0.0d;
  if (stats != null && stats.stddev > 0) {
    zmus = (value - stats.mean) / stats.stddev;
    return new Feature("ZMUS_" + featureName, zmus);
  } else {
    return null;
  }
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:15,代码来源:ZeroMeanUnitStddevExtractor.java

示例6: featuresToFeatureMap

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
public Map<String, Double> featuresToFeatureMap(List<Feature> features) {
  Map<String, Double> featureMap = new HashMap<String, Double>();
  for (Feature feature : features) {
    String termName = feature.getName();
    int tf = (Integer) feature.getValue();
    featureMap.put(termName, tf * this.idfMap.getIDF(termName));
  }
  return featureMap;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:10,代码来源:CentroidTfidfSimilarityExtractor.java

示例7: computeCentroid

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
protected Map<String, Double> computeCentroid(Iterable<Instance<OUTCOME_T>> instances, IDFMap idfs) {

    // Now compute centroid of all applicable terms (features) in all instances
    int numDocuments = idfs.getTotalDocumentCount();
    Map<String, Double> newCentroidMap = new HashMap<String, Double>();
    for (Instance<OUTCOME_T> instance : instances) {

      // Grab the matching tf*idf features from the set of all features in an instance
      for (Feature feature : instance.getFeatures()) {
        if (this.isTransformable(feature)) {
          // tf*idf features contain a list of features, these are actually what get added
          // to our document frequency map
          for (Feature untransformedFeature : ((TransformableFeature) feature).getFeatures()) {
            String termName = untransformedFeature.getName();
            int tf = (Integer) untransformedFeature.getValue();
            double tfidf = tf * idfs.getIDF(termName);
            double sumTfidf = (newCentroidMap.containsKey(termName))
                ? sumTfidf = newCentroidMap.get(termName)
                : 0.0;
            newCentroidMap.put(termName, sumTfidf + tfidf);
          }
        }
      }
    }

    for (Map.Entry<String, Double> entry : newCentroidMap.entrySet()) {
      double mean = entry.getValue() / numDocuments;
      newCentroidMap.put(entry.getKey(), mean);
    }
    return newCentroidMap;
  }
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:32,代码来源:CentroidTfidfSimilarityExtractor.java

示例8: transform

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
protected Feature transform(Feature feature) {
  String featureName = feature.getName();
  MinMaxPair stats = this.minMaxMap.get(featureName);

  double mmn = 0.5d; // this is the default value we will return if we've never seen the feature
                     // before

  double value = ((Number) feature.getValue()).doubleValue();
  // this is the typical case
  if (stats != null && stats.min < stats.max) {
    mmn = (value - stats.min) / (stats.max - stats.min);
  }
  // this is an edge case that could happen when the value is always the same
  if (stats != null && stats.min == stats.max) {
    if (value == stats.min) {
      mmn = 0.5d;
    } else {
      mmn = value < stats.min ? 0 : 1;
    }
  }
  mmn = Math.max(0, mmn); // if mmn is negative, then return zero (this would happen if the
                          // feature value was a the smallest value yet seen)
  mmn = Math.min(1, mmn); // if mmn is more than one, then return 1 (this would happen if the
                          // feature value was the largest value yet seen)
  return new Feature("MINMAX_NORMED_" + featureName, mmn);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:28,代码来源:MinMaxNormalizationExtractor.java

示例9: encodeAll

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public ContextValues encodeAll(Iterable<Feature> featuresIterable) throws CleartkEncoderException {
  // this is not guaranteed to work, however with normal use of ClearTK, it will
  Collection<Feature> features = (Collection<Feature>) featuresIterable;
  
  // populate context array and values array from the features
  String[] context = new String[features.size()];
  float[] values = new float[features.size()];
  int i = -1;
  for (Feature feature : features) {
    ++i;

    // convert features to a String name and a float value
    if (feature.getValue() instanceof Number) {
      context[i] = feature.getName();
      values[i] = ((Number) feature.getValue()).floatValue();
    } else if (feature.getValue() instanceof Boolean) {
      context[i] = feature.getName();
      values[i] = (Boolean) feature.getValue() ? 1.0f : 0.0f;
    } else {
      Object value = feature.getValue();
      context[i] = Feature.createName(feature.getName(), value == null ? null : value.toString());
      values[i] = 1.0f;
    }
  }
  
  return new ContextValues(context, values);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:29,代码来源:ContextValuesFeaturesEncoder.java

示例10: encode

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
public List<NameNumber> encode(Feature feature) {
  String name = feature.getName();
  Number number = (Number) feature.getValue();

  return Collections.singletonList(new NameNumber(name, number));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:7,代码来源:NumberEncoder.java

示例11: encode

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
public List<NameNumber> encode(Feature feature) {
  String name = feature.getName();
  Number number = ((Boolean) feature.getValue()).booleanValue() ? 1.0 : 0.0;
  return Collections.singletonList(new NameNumber(name, number));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:6,代码来源:BooleanEncoder.java

示例12: transform

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
protected Feature transform(Feature feature) {
  int tf = (Integer) feature.getValue();
  double tfidf = tf * this.idfMap.getIDF(feature.getName());
  return new Feature("TF-IDF_" + feature.getName(), tfidf);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:7,代码来源:TfidfExtractor.java

示例13: nameFeature

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
public String nameFeature(Feature feature) {
  return (feature.getValue() instanceof Number)
      ? feature.getName()
      : feature.getName() + ":" + feature.getValue();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:6,代码来源:MutualInformationFeatureSelectionExtractor.java


注:本文中的org.cleartk.ml.Feature.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。