Search in sources :

Example 11 with Function

use of com.airbnb.aerosolve.core.function.Function in project aerosolve by airbnb.

the class AdditiveModel method scoreDenseFeatures.

public float scoreDenseFeatures(Map<String, List<Double>> denseFeatures) {
    float sum = 0;
    if (denseFeatures != null && !denseFeatures.isEmpty()) {
        Map<String, Function> denseWeights = getOrCreateDenseWeights();
        for (Map.Entry<String, List<Double>> feature : denseFeatures.entrySet()) {
            String featureName = feature.getKey();
            Function fun = denseWeights.get(featureName);
            if (fun == null)
                continue;
            sum += fun.evaluate(toFloat(feature.getValue()));
        }
    }
    return sum;
}
Also used : AbstractFunction(com.airbnb.aerosolve.core.function.AbstractFunction) Function(com.airbnb.aerosolve.core.function.Function) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Aggregations

Function (com.airbnb.aerosolve.core.function.Function)11 AbstractFunction (com.airbnb.aerosolve.core.function.AbstractFunction)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AbstractMap (java.util.AbstractMap)6 SparseLabeledPoint (com.airbnb.aerosolve.core.features.SparseLabeledPoint)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ModelRecord (com.airbnb.aerosolve.core.ModelRecord)2 Linear (com.airbnb.aerosolve.core.function.Linear)2 Spline (com.airbnb.aerosolve.core.function.Spline)2 DebugScoreRecord (com.airbnb.aerosolve.core.DebugScoreRecord)1 ModelHeader (com.airbnb.aerosolve.core.ModelHeader)1 FunctionUtil.toFloat (com.airbnb.aerosolve.core.function.FunctionUtil.toFloat)1 PriorityQueue (java.util.PriorityQueue)1 Test (org.junit.Test)1