use of edu.neu.ccs.pyramid.dataset.SequentialSparseDataSet in project pyramid by cheng-li.
the class CMLCRFElasticNet method expandData.
private DataSet expandData(int l) {
SequentialSparseDataSet newData = new SequentialSparseDataSet(numData, numParameters, false);
MultiLabel label = supportedCombinations.get(l);
List<Integer> labelPairForL = combinationToLabelPair.get(l);
// TODO: parallelism
for (int i = 0; i < numData; i++) {
// add feature-label feature
for (int y : label.getMatchedLabels()) {
// set bias as 1
newData.setFeatureValue(i, (numFeature + 1) * y, 1.0);
for (Vector.Element element : dataSet.getRow(i).nonZeroes()) {
int index = element.index();
double value = element.get();
newData.setFeatureValue(i, (numFeature + 1) * y + index + 1, value);
}
}
for (int y : labelPairForL) {
newData.setFeatureValue(i, (numWeightsForFeatures + y), 1.0);
}
}
return newData;
}
Aggregations