use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.
the class IntervalSplitterTest method test6.
static void test6() {
RegTreeConfig regTreeConfig = new RegTreeConfig().setNumSplitIntervals(4);
Vector vector = new DenseVector(4);
vector.set(0, 0);
vector.set(1, 1);
vector.set(2, 2);
vector.set(3, 3);
double[] probs = { 1, 0.5, 0.2, 0.6 };
double[] labels = { 1, 2, 3, 4 };
Splitter.GlobalStats globalStats = new Splitter.GlobalStats(labels, probs);
System.out.println(IntervalSplitter.generateIntervals(regTreeConfig, vector, probs, labels, globalStats));
}
use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.
the class IntervalSplitterTest method test10.
static void test10() {
RegTreeConfig regTreeConfig = new RegTreeConfig().setNumSplitIntervals(2);
Vector vector = new DenseVector(4);
vector.set(0, Double.NaN);
vector.set(1, 1);
vector.set(2, 2);
vector.set(3, 3);
double[] probs = { 1, 0.5, 1, 0.6 };
double[] labels = { 1, 2, 3, 4 };
Splitter.GlobalStats globalStats = new Splitter.GlobalStats(labels, probs);
List<Interval> intervals = IntervalSplitter.generateIntervals(regTreeConfig, vector, probs, labels, globalStats);
System.out.println(intervals);
System.out.println(IntervalSplitter.compress(intervals));
}
use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.
the class VectorsTest method test2.
private static void test2() {
double[] d = { 1, 2, 3 };
Vector v = new DenseVector(d);
double[] a = { 7, 4, 5, 6 };
System.out.println(Vectors.concatenate(v, a));
}
use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.
the class VectorsTest method test3.
private static void test3() {
double[] d = { 1, 2, 3 };
Vector v = new DenseVector(d);
double[] a = { 4, 5, 6, 7 };
Vector t = new DenseVector(a);
System.out.println(Vectors.concatenate(v, t));
}
use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.
the class Weights method readObject.
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
numClasses = in.readInt();
numFeatures = in.readInt();
numWeightsForFeatures = in.readInt();
numWeightsForLabels = in.readInt();
serializableWeights = (double[]) in.readObject();
weightVector = new DenseVector(numWeightsForFeatures + numWeightsForLabels);
for (int i = 0; i < serializableWeights.length; i++) {
weightVector.set(i, serializableWeights[i]);
}
}
Aggregations