use of edu.neu.ccs.pyramid.dataset.SparseDataSet in project pyramid by cheng-li.
the class StumpSelector method scores.
/**
* @param index
* @param labels size = num labels * num data
* @param feature
* @param idTranslator
* @param matchScoreType
* @param docFilter
*/
public static double[] scores(ESIndex index, double[][] labels, Ngram feature, IdTranslator idTranslator, FeatureLoader.MatchScoreType matchScoreType, String docFilter, Map<String, float[]> fieldLength) {
Ngram ngram = null;
try {
ngram = (Ngram) Serialization.deepCopy(feature);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
ngram.setIndex(0);
DataSet dataSet = new SparseDataSet(labels[0].length, 1, false, null);
FeatureLoader.loadNgramFeature(index, dataSet, ngram, idTranslator, matchScoreType, docFilter, fieldLength);
double[] scores = new double[labels.length];
for (int l = 0; l < scores.length; l++) {
double score = score(dataSet, labels[l]);
scores[l] = score;
}
return scores;
}
use of edu.neu.ccs.pyramid.dataset.SparseDataSet in project pyramid by cheng-li.
the class IntervalSplitterTest method test1.
private static void test1() {
SparseDataSet dataSet = new SparseDataSet(5, 2, false);
dataSet.setFeatureValue(0, 0, 0);
dataSet.setFeatureValue(1, 0, 0);
dataSet.setFeatureValue(2, 0, 0);
dataSet.setFeatureValue(3, 0, 1);
dataSet.setFeatureValue(4, 0, 1);
double[] labels = { 1, 2, 3, 3, 1 };
RegTreeConfig regTreeConfig = new RegTreeConfig();
double[] probs = { 1, 1, 1, 1, 0 };
regTreeConfig.setMinDataPerLeaf(1).setNumSplitIntervals(2);
Splitter.GlobalStats globalStats = new Splitter.GlobalStats(labels, probs);
System.out.println(IntervalSplitter.split(regTreeConfig, dataSet, labels, probs, 0, globalStats));
}
use of edu.neu.ccs.pyramid.dataset.SparseDataSet in project pyramid by cheng-li.
the class IntervalSplitterTest method test3.
private static void test3() {
SparseDataSet dataSet = new SparseDataSet(5, 2, false);
dataSet.setFeatureValue(0, 0, 0);
dataSet.setFeatureValue(1, 0, 0);
dataSet.setFeatureValue(2, 0, 0);
dataSet.setFeatureValue(3, 0, 1);
dataSet.setFeatureValue(4, 0, 1);
double[] labels = { 1, 2, 3, 3, 1 };
RegTreeConfig regTreeConfig = new RegTreeConfig();
double[] probs = { 1, 1, 1, 1, 0 };
regTreeConfig.setMinDataPerLeaf(2).setNumSplitIntervals(200);
Splitter.GlobalStats globalStats = new Splitter.GlobalStats(labels, probs);
System.out.println(IntervalSplitter.split(regTreeConfig, dataSet, labels, probs, 0, globalStats));
}
use of edu.neu.ccs.pyramid.dataset.SparseDataSet in project pyramid by cheng-li.
the class IntervalSplitterTest method test4.
private static void test4() {
SparseDataSet dataSet = new SparseDataSet(8, 1, false);
dataSet.setFeatureValue(0, 0, 0);
dataSet.setFeatureValue(1, 0, 0);
dataSet.setFeatureValue(2, 0, 0);
dataSet.setFeatureValue(3, 0, 1);
dataSet.setFeatureValue(4, 0, 1);
dataSet.setFeatureValue(5, 0, 2);
dataSet.setFeatureValue(6, 0, 2);
dataSet.setFeatureValue(6, 0, 3);
double[] labels = { 1, 2, 3, 3, 1, 5, 5, 5 };
RegTreeConfig regTreeConfig = new RegTreeConfig();
double[] probs = { 1, 1, 1, 1, 1, 1, 1, 1 };
regTreeConfig.setMinDataPerLeaf(2).setNumSplitIntervals(4);
Splitter.GlobalStats globalStats = new Splitter.GlobalStats(labels, probs);
System.out.println(IntervalSplitter.split(regTreeConfig, dataSet, labels, probs, 0, globalStats));
}
use of edu.neu.ccs.pyramid.dataset.SparseDataSet in project pyramid by cheng-li.
the class IntervalSplitterTest method test2.
private static void test2() {
SparseDataSet dataSet = new SparseDataSet(5, 2, false);
dataSet.setFeatureValue(0, 0, 0);
dataSet.setFeatureValue(1, 0, 0);
dataSet.setFeatureValue(2, 0, 0);
dataSet.setFeatureValue(3, 0, 1);
dataSet.setFeatureValue(4, 0, 1);
double[] labels = { 1, 2, 3, 3, 1 };
RegTreeConfig regTreeConfig = new RegTreeConfig();
double[] probs = { 1, 1, 1, 1, 0 };
regTreeConfig.setMinDataPerLeaf(1).setNumSplitIntervals(200);
Splitter.GlobalStats globalStats = new Splitter.GlobalStats(labels, probs);
System.out.println(IntervalSplitter.split(regTreeConfig, dataSet, labels, probs, 0, globalStats));
}
Aggregations