Search in sources :

Example 16 with DenseVector

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));
}
Also used : DenseVector(org.apache.mahout.math.DenseVector) Vector(org.apache.mahout.math.Vector) DenseVector(org.apache.mahout.math.DenseVector)

Example 17 with DenseVector

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));
}
Also used : DenseVector(org.apache.mahout.math.DenseVector) Vector(org.apache.mahout.math.Vector) DenseVector(org.apache.mahout.math.DenseVector)

Example 18 with DenseVector

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));
}
Also used : DenseVector(org.apache.mahout.math.DenseVector) Vector(org.apache.mahout.math.Vector) DenseVector(org.apache.mahout.math.DenseVector)

Example 19 with DenseVector

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));
}
Also used : DenseVector(org.apache.mahout.math.DenseVector) Vector(org.apache.mahout.math.Vector) DenseVector(org.apache.mahout.math.DenseVector)

Example 20 with DenseVector

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]);
    }
}
Also used : DenseVector(org.apache.mahout.math.DenseVector)

Aggregations

DenseVector (org.apache.mahout.math.DenseVector)79 Vector (org.apache.mahout.math.Vector)73 MultiLabel (edu.neu.ccs.pyramid.dataset.MultiLabel)9 RandomAccessSparseVector (org.apache.mahout.math.RandomAccessSparseVector)8 MultiLabelClfDataSet (edu.neu.ccs.pyramid.dataset.MultiLabelClfDataSet)7 SequentialAccessSparseVector (org.apache.mahout.math.SequentialAccessSparseVector)6 Pair (edu.neu.ccs.pyramid.util.Pair)4 List (java.util.List)3 IntStream (java.util.stream.IntStream)3 EnumeratedIntegerDistribution (org.apache.commons.math3.distribution.EnumeratedIntegerDistribution)3 LogisticRegression (edu.neu.ccs.pyramid.classification.logistic_regression.LogisticRegression)2 DataSet (edu.neu.ccs.pyramid.dataset.DataSet)2 EmpiricalCDF (edu.neu.ccs.pyramid.util.EmpiricalCDF)2 IntegerDistribution (org.apache.commons.math3.distribution.IntegerDistribution)2 MultivariateNormalDistribution (org.apache.commons.math3.distribution.MultivariateNormalDistribution)2 Classifier (edu.neu.ccs.pyramid.classification.Classifier)1 Weights (edu.neu.ccs.pyramid.classification.logistic_regression.Weights)1 RegDataSet (edu.neu.ccs.pyramid.dataset.RegDataSet)1 ConstantRegressor (edu.neu.ccs.pyramid.regression.ConstantRegressor)1 BernoulliDistribution (edu.neu.ccs.pyramid.util.BernoulliDistribution)1