Search in sources :

Example 1 with SparseLabeledPoint

use of com.airbnb.aerosolve.core.features.SparseLabeledPoint in project aerosolve by airbnb.

the class AdditiveModel method update.

public void update(float gradWithLearningRate, SparseLabeledPoint point, double dropout, Random rand) {
    for (int i = 0; i < point.indices.length; i++) {
        if (dropout <= 0 || rand.nextDouble() > dropout) {
            int index = point.indices[i];
            Function function = weightVector[index];
            float value = point.values[i];
            function.update(-gradWithLearningRate, value);
        }
    }
    for (int i = 0; i < point.denseIndices.length; i++) {
        if (dropout <= 0 || rand.nextDouble() > dropout) {
            int index = point.denseIndices[i];
            Function function = weightVector[index];
            float[] value = point.denseValues[i];
            function.update(-gradWithLearningRate, value);
        }
    }
}
Also used : AbstractFunction(com.airbnb.aerosolve.core.function.AbstractFunction) Function(com.airbnb.aerosolve.core.function.Function) SparseLabeledPoint(com.airbnb.aerosolve.core.features.SparseLabeledPoint)

Example 2 with SparseLabeledPoint

use of com.airbnb.aerosolve.core.features.SparseLabeledPoint in project aerosolve by airbnb.

the class AdditiveModel method scoreFeatures.

public float scoreFeatures(SparseLabeledPoint point, double dropout, Random rand) {
    float prediction = 0;
    for (int i = 0; i < point.indices.length; i++) {
        if (dropout <= 0 || rand.nextDouble() > dropout) {
            int index = point.indices[i];
            Function function = weightVector[index];
            float value = point.values[i];
            prediction += function.evaluate(value);
        }
    }
    for (int i = 0; i < point.denseIndices.length; i++) {
        if (dropout <= 0 || rand.nextDouble() > dropout) {
            int index = point.denseIndices[i];
            Function function = weightVector[index];
            float[] value = point.denseValues[i];
            prediction += function.evaluate(value);
        }
    }
    return prediction;
}
Also used : AbstractFunction(com.airbnb.aerosolve.core.function.AbstractFunction) Function(com.airbnb.aerosolve.core.function.Function) SparseLabeledPoint(com.airbnb.aerosolve.core.features.SparseLabeledPoint)

Aggregations

SparseLabeledPoint (com.airbnb.aerosolve.core.features.SparseLabeledPoint)2 AbstractFunction (com.airbnb.aerosolve.core.function.AbstractFunction)2 Function (com.airbnb.aerosolve.core.function.Function)2