本文整理汇总了Java中cc.mallet.types.FeatureVectorSequence.get方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureVectorSequence.get方法的具体用法?Java FeatureVectorSequence.get怎么用?Java FeatureVectorSequence.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.types.FeatureVectorSequence
的用法示例。
在下文中一共展示了FeatureVectorSequence.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preProcess
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public BitSet preProcess(InstanceList data) {
// count
int ii = 0;
int fi;
FeatureVector fv;
BitSet bitSet = new BitSet(data.size());
for (Instance instance : data) {
FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
for (int ip = 0; ip < fvs.size(); ip++) {
fv = fvs.get(ip);
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
if (constraints.containsKey(fi)) {
constraints.get(fi).count += 1;
bitSet.set(ii);
}
}
}
ii++;
}
return bitSet;
}
示例2: preProcess
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public BitSet preProcess(InstanceList data) {
// count
int ii = 0;
int fi;
FeatureVector fv;
BitSet bitSet = new BitSet(data.size());
for (Instance instance : data) {
FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
for (int ip = 0; ip < fvs.size(); ip++) {
fv = fvs.get(ip);
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
if (constraints.containsKey(fi)) {
constraints.get(fi).count += 1;
bitSet.set(ii);
}
}
if (constraints.containsKey(fv.getAlphabet().size())) {
bitSet.set(ii);
constraints.get(fv.getAlphabet().size()).count += 1;
}
}
ii++;
}
return bitSet;
}
示例3: TransitionIterator
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public TransitionIterator (State source,
FeatureVectorSequence inputSeq,
int inputPosition,
String output, CRF crf)
{
this (source, inputSeq.get(inputPosition), output, crf);
}
示例4: getUnnormalizedClassificationScores
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
/** returns unnormalized scores, corresponding to the score an
* element of the InstanceList being the "top" instance
* @param instance instance with data field a {@link InstanceList}.
* @param scores has length = number of Instances in Instance.data,
* which is of type InstanceList */
public void getUnnormalizedClassificationScores (Instance instance, double[] scores)
{
FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
assert (scores.length == fvs.size());
int numFeatures = instance.getDataAlphabet().size()+1;
for (int instanceNumber=0; instanceNumber < fvs.size(); instanceNumber++) {
FeatureVector fv = (FeatureVector)fvs.get(instanceNumber);
// Make sure the feature vector's feature dictionary matches
// what we are expecting from our data pipe (and thus our notion
// of feature probabilities.
assert (fv.getAlphabet ()
== this.instancePipe.getDataAlphabet ());
// Include the feature weights according to each label xxx is
// this correct ? we only calculate the dot prod of the feature
// vector with the "positiveLabel" weights
// xxx include multiple labels
scores[instanceNumber] = parameters[0*numFeatures + defaultFeatureIndex]
+ MatrixOps.rowDotProduct (parameters, numFeatures,
0, fv,
defaultFeatureIndex,
(perClassFeatureSelection == null
? featureSelection
: perClassFeatureSelection[0]));
}
}
示例5: getClassificationScores
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void getClassificationScores (Instance instance, double[] scores)
{
FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
int numFeatures = instance.getDataAlphabet().size()+1;
int numLabels = fvs.size();
assert (scores.length == fvs.size());
for (int instanceNumber=0; instanceNumber < fvs.size(); instanceNumber++) {
FeatureVector fv = (FeatureVector)fvs.get(instanceNumber);
// Make sure the feature vector's feature dictionary matches
// what we are expecting from our data pipe (and thus our notion
// of feature probabilities.
assert (fv.getAlphabet ()
== this.instancePipe.getDataAlphabet ());
// Include the feature weights according to each label
scores[instanceNumber] = parameters[0*numFeatures + defaultFeatureIndex]
+ MatrixOps.rowDotProduct (parameters, numFeatures,
0, fv,
defaultFeatureIndex,
(perClassFeatureSelection == null
? featureSelection
: perClassFeatureSelection[0]));
}
// Move scores to a range where exp() is accurate, and normalize
double max = MatrixOps.max (scores);
double sum = 0;
for (int li = 0; li < numLabels; li++)
sum += (scores[li] = Math.exp (scores[li] - max));
for (int li = 0; li < numLabels; li++) {
scores[li] /= sum;
// xxxNaN assert (!Double.isNaN(scores[li]));
}
}
示例6: pipe
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
@Override
public Instance pipe(Instance inst) {
FeatureVectorSequence vs = (FeatureVectorSequence) inst.getData();
for (int i = 0; i < vs.size(); i++) {
AugmentableFeatureVector v = (AugmentableFeatureVector) vs.get(i);
// System.out.println("Before augment: " + v.numLocations());
double[] values = scl.transform(v);
for (int j = 0; j < values.length; j++) {
String key = "SCL_AUG" + j;
// if (values[j] != 0)
// v.add("SCL_AUG" + j, values[j]);
// if (values[j] < -1) {
// v.add(key + "(<-1)", 1);
// } else if (values[j] < -0.5) {
// v.add(key + "(<-0.5)", 1);
// } else if (values[j] < 0) {
// v.add(key + "(<0)", 1);
// } else if (values[j] > 1) {
// v.add(key + "(>1)", 1);
// } else if (values[j] > 0.5) {
// v.add(key + "(>0.5)", 1);
// } else if (values[j] > 0) {
// v.add(key + "(>0)", 1);
// } else {
// v.add(key + "(=0)", 1);
// }
// if (values[j] > 0) {
// v.add(key + "(>0)", 1);
// } else if (values[j] < 0) {
// v.add(key + "(<0)", 1);
// }
if (values[j] != 0)
v.add(key, values[j]);
}
// System.out.println(v);
// System.out.println("After augment: " + v.numLocations());
}
return inst;
}
示例7: getUnnormalizedClassificationScores
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
/** returns unnormalized scores, corresponding to the score an
* element of the InstanceList being the "top" instance
* @param instance instance with data field a {@link cc.mallet.types.InstanceList}.
* @param scores has length = number of Instances in Instance.data,
* which is of type InstanceList */
public void getUnnormalizedClassificationScores (Instance instance, double[] scores)
{
FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
assert (scores.length == fvs.size());
int numFeatures = instance.getDataAlphabet().size()+1;
for (int instanceNumber=0; instanceNumber < fvs.size(); instanceNumber++) {
FeatureVector fv = (FeatureVector)fvs.get(instanceNumber);
// Make sure the feature vector's feature dictionary matches
// what we are expecting from our data pipe (and thus our notion
// of feature probabilities.
assert (fv.getAlphabet ()
== this.instancePipe.getDataAlphabet ());
// Include the feature weights according to each label xxx is
// this correct ? we only calculate the dot prod of the feature
// vector with the "positiveLabel" weights
// xxx include multiple labels
scores[instanceNumber] = parameters[0*numFeatures + defaultFeatureIndex]
+ MatrixOps.rowDotProduct (parameters, numFeatures,
0, fv,
defaultFeatureIndex,
(perClassFeatureSelection == null
? featureSelection
: perClassFeatureSelection[0]));
}
}