Search in sources :

Example 61 with DenseVector

use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.

the class LogisticRegressionTest method test4.

private static void test4() {
    double[] prior = { 0.3, 0.7 };
    LogisticRegression logisticRegression = new LogisticRegression(2, 10, prior);
    Vector vector = new DenseVector(10);
    for (int d = 0; d < 10; d++) {
        vector.set(d, Math.random());
    }
    System.out.println(Arrays.toString(logisticRegression.predictClassProbs(vector)));
}
Also used : DenseVector(org.apache.mahout.math.DenseVector) Vector(org.apache.mahout.math.Vector) DenseVector(org.apache.mahout.math.DenseVector)

Example 62 with DenseVector

use of org.apache.mahout.math.DenseVector in project pyramid by cheng-li.

the class IntervalSplitterTest method test11.

static void test11() {
    RegTreeConfig regTreeConfig = new RegTreeConfig().setNumSplitIntervals(2);
    Vector vector = new DenseVector(4);
    vector.set(0, Double.NaN);
    vector.set(1, 1);
    vector.set(2, Double.NaN);
    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)

Aggregations

DenseVector (org.apache.mahout.math.DenseVector)62 Vector (org.apache.mahout.math.Vector)56 MultiLabelClfDataSet (edu.neu.ccs.pyramid.dataset.MultiLabelClfDataSet)7 MultiLabel (edu.neu.ccs.pyramid.dataset.MultiLabel)5 RandomAccessSparseVector (org.apache.mahout.math.RandomAccessSparseVector)5 SequentialAccessSparseVector (org.apache.mahout.math.SequentialAccessSparseVector)4 List (java.util.List)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 Pair (edu.neu.ccs.pyramid.util.Pair)1 ArrayList (java.util.ArrayList)1