Search in sources :

Example 1 with ParameterEstimationForExpressionBasedModel

use of com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel in project aic-praise by aic-sri-international.

the class ParameterEstimationForExpressionBasedModelTest method testBuildOptimizedExpressionBasedModel.

// @Test
public void testBuildOptimizedExpressionBasedModel() {
    ExpressionBasedModel expressionBasedModel = ExpressionBasedModelExamples.buildModel1();
    System.out.println("expressionBasedModel before optimization : " + expressionBasedModel);
    List<Pair<Expression, Expression>> pairsQueryEvidence = new LinkedList<Pair<Expression, Expression>>();
    Pair<Expression, Expression> pair = new Pair<Expression, Expression>(parse("earthquake"), parse("null"));
    pairsQueryEvidence.add(pair);
    ParameterEstimationForExpressionBasedModel parameterEstimationForExpressionBasedModel = new ParameterEstimationForExpressionBasedModel(expressionBasedModel, pairsQueryEvidence);
    HashMap<Expression, Double> result = parameterEstimationForExpressionBasedModel.optimize(new double[] { 0 });
    ExpressionBasedModel newModel = buildOptimizedExpressionBasedModel(result, expressionBasedModel);
    System.out.println(newModel);
    List<Pair<Expression, Expression>> pairsQueryEvidence2 = new LinkedList<Pair<Expression, Expression>>();
    Pair<Expression, Expression> pair2 = new Pair<Expression, Expression>(parse("burglary"), parse("null"));
    pairsQueryEvidence2.add(pair2);
    ParameterEstimationForExpressionBasedModel parameterEstimationForExpressionBasedModel2 = new ParameterEstimationForExpressionBasedModel(newModel, pairsQueryEvidence2);
    HashMap<Expression, Double> result2 = parameterEstimationForExpressionBasedModel2.optimize(new double[] { 0 });
    ExpressionBasedModel newModel2 = buildOptimizedExpressionBasedModel(result2, newModel);
    System.out.println(newModel2);
}
Also used : UsefulOperationsParameterEstimation.buildOptimizedExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.util.UsefulOperationsParameterEstimation.buildOptimizedExpressionBasedModel) ParameterEstimationForExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel) ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) Expression(com.sri.ai.expresso.api.Expression) LinkedList(java.util.LinkedList) ParameterEstimationForExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel) Pair(com.sri.ai.util.base.Pair)

Example 2 with ParameterEstimationForExpressionBasedModel

use of com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel in project aic-praise by aic-sri-international.

the class ParameterEstimationForExpressionBasedModelTest method runTestExpressionBased.

private HashMap<Expression, Double> runTestExpressionBased(List<Pair<Expression, Expression>> pairsQueryEvidence, ExpressionBasedModel expressionBasedModel, double[] startPoint) {
    ParameterEstimationForExpressionBasedModel parameterEstimationForExpressionBasedModel = new ParameterEstimationForExpressionBasedModel(expressionBasedModel, pairsQueryEvidence);
    HashMap<Expression, Double> result = parameterEstimationForExpressionBasedModel.optimize(startPoint);
    ExpressionBasedModel newModel = buildOptimizedExpressionBasedModel(result, expressionBasedModel);
    System.out.println(" New Model : " + newModel);
    return result;
}
Also used : Expression(com.sri.ai.expresso.api.Expression) UsefulOperationsParameterEstimation.buildOptimizedExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.util.UsefulOperationsParameterEstimation.buildOptimizedExpressionBasedModel) ParameterEstimationForExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel) ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) ParameterEstimationForExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)2 ExpressionBasedModel (com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel)2 ParameterEstimationForExpressionBasedModel (com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForExpressionBasedModel)2 UsefulOperationsParameterEstimation.buildOptimizedExpressionBasedModel (com.sri.ai.praise.learning.symbolicparameterestimation.util.UsefulOperationsParameterEstimation.buildOptimizedExpressionBasedModel)2 Pair (com.sri.ai.util.base.Pair)1 LinkedList (java.util.LinkedList)1