use of com.yahoo.searchlib.rankingexpression.RankingExpression in project vespa by vespa-engine.
the class GBDTOptimizerTestCase method testSimpleNodeOptimization.
public void testSimpleNodeOptimization() throws ParseException {
RankingExpression gbdt = new RankingExpression("if (a < 2, if (b < 2, 5, 6), 4) + if (a < 3, 7, 8)");
// Optimized evaluation
ArrayContext arguments = new ArrayContext(gbdt);
ExpressionOptimizer optimizer = new ExpressionOptimizer();
optimizer.getOptimizer(GBDTForestOptimizer.class).setEnabled(false);
OptimizationReport report = optimizer.optimize(gbdt, arguments);
assertEquals(2, report.getMetric("Optimized GDBT trees"));
arguments.put("a", 1d);
arguments.put("b", 2d);
assertEquals(13.0, gbdt.evaluate(arguments).asDouble());
}
use of com.yahoo.searchlib.rankingexpression.RankingExpression in project vespa by vespa-engine.
the class GBDTOptimizerTestCase method testBug4009433.
public void testBug4009433() throws ParseException {
RankingExpression exp = new RankingExpression("10*if(two>35,if(two>one,if(two>=670,4,8),if(two>8000,5,3)),if(two==478,90,91))");
new GBDTOptimizer().optimize(exp, new ArrayContext(exp), new OptimizationReport());
}
use of com.yahoo.searchlib.rankingexpression.RankingExpression in project vespa by vespa-engine.
the class Benchmark method evaluateForestOptimized.
private static Result evaluateForestOptimized(String str, int numRuns) throws ParseException {
Result ret = new Result();
ret.name = "Optimized forest";
RankingExpression exp = new RankingExpression(str);
List<String> vars = new LinkedList<String>();
getFeatures(exp.getRoot(), vars);
ArrayContext ctx = new ArrayContext(exp);
ExpressionOptimizer optimizer = new ExpressionOptimizer();
optimizer.optimize(exp, ctx);
benchmark(exp, vars, ctx, numRuns, ret);
return ret;
}
use of com.yahoo.searchlib.rankingexpression.RankingExpression in project vespa by vespa-engine.
the class Benchmark method evaluateTree.
private static Result evaluateTree(String str, int numRuns) throws ParseException {
Result ret = new Result();
ret.name = "Unoptimized";
RankingExpression exp = new RankingExpression(str);
List<String> vars = new LinkedList<String>();
getFeatures(exp.getRoot(), vars);
benchmark(exp, vars, new MapContext(), numRuns, ret);
return ret;
}
use of com.yahoo.searchlib.rankingexpression.RankingExpression in project vespa by vespa-engine.
the class Benchmark method evaluateTreeOptimized.
private static Result evaluateTreeOptimized(String str, int numRuns) throws ParseException {
Result ret = new Result();
ret.name = "Optimized tree";
RankingExpression exp = new RankingExpression(str);
List<String> vars = new LinkedList<String>();
getFeatures(exp.getRoot(), vars);
ArrayContext ctx = new ArrayContext(exp);
ExpressionOptimizer optimizer = new ExpressionOptimizer();
optimizer.getOptimizer(GBDTForestOptimizer.class).setEnabled(false);
optimizer.optimize(exp, ctx);
benchmark(exp, vars, ctx, numRuns, ret);
return ret;
}
Aggregations