Search in sources :

Example 1 with RegularSymbolicParameterEstimation

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

the class RegularSymbolicParameterEstimationTest method testOptimization.

@Test
public void testOptimization() {
    ExpressionBasedModel expressionBasedModel = buildModel1();
    List<Expression> queryExpressionList = new LinkedList<Expression>();
    queryExpressionList.add(parse("not earthquake and not burglary"));
    queryExpressionList.add(parse("not earthquake and not burglary"));
    queryExpressionList.add(parse("earthquake and burglary"));
    queryExpressionList.add(parse("not earthquake and burglary"));
    queryExpressionList.add(parse("earthquake and not burglary"));
    queryExpressionList.add(parse("earthquake and burglary"));
    queryExpressionList.add(parse("earthquake and burglary"));
    queryExpressionList.add(parse("earthquake and burglary"));
    queryExpressionList.add(parse("earthquake and burglary"));
    queryExpressionList.add(parse("not earthquake and burglary"));
    RegularSymbolicParameterEstimation regularParameterEstimation = new RegularSymbolicParameterEstimation(expressionBasedModel, queryExpressionList);
    Map<Expression, Double> result = regularParameterEstimation.optimize();
    System.out.println(result);
    ExpressionBasedModel expressionBasedModel2 = buildModel3();
    RegularSymbolicParameterEstimation regularParameterEstimation2 = new RegularSymbolicParameterEstimation(expressionBasedModel2, queryExpressionList);
    Map<Expression, Double> result2 = regularParameterEstimation2.optimize();
    System.out.println(result2);
    ExpressionBasedModel expressionBasedModel3 = buildModel1();
    List<Expression> queryExpressionList3 = new LinkedList<Expression>();
    queryExpressionList3.add(parse("not earthquake and not burglary"));
    queryExpressionList3.add(parse("not earthquake and not burglary"));
    queryExpressionList3.add(parse("earthquake and burglary"));
    RegularSymbolicParameterEstimation regularParameterEstimation3 = new RegularSymbolicParameterEstimation(expressionBasedModel3, queryExpressionList3);
    Map<Expression, Double> result3 = regularParameterEstimation3.optimize();
    System.out.println(result3);
}
Also used : ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) Expression(com.sri.ai.expresso.api.Expression) LinkedList(java.util.LinkedList) RegularSymbolicParameterEstimation(com.sri.ai.praise.learning.symbolicparameterestimation.RegularSymbolicParameterEstimation) Test(org.junit.Test)

Example 2 with RegularSymbolicParameterEstimation

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

the class RegularSymbolicParameterEstimationTest method testCountOccurencesGivenParameter.

@Test
public void testCountOccurencesGivenParameter() {
    List<Expression> queryExpressionList = new LinkedList<Expression>();
    queryExpressionList.add(parse("earthquake and burglary"));
    queryExpressionList.add(parse("earthquake"));
    queryExpressionList.add(parse("earthquake"));
    queryExpressionList.add(parse("burglary"));
    ExpressionBasedModel expressionBasedModel = buildModel1();
    RegularSymbolicParameterEstimation regularParameterEstimation = new RegularSymbolicParameterEstimation(expressionBasedModel, queryExpressionList);
    int nbAlpha = regularParameterEstimation.countOccurencesGivenParameter(parse("Alpha"));
    int nbBeta = regularParameterEstimation.countOccurencesGivenParameter(parse("Beta"));
    Assert.assertEquals(3, nbAlpha);
    Assert.assertEquals(2, nbBeta);
}
Also used : Expression(com.sri.ai.expresso.api.Expression) ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) LinkedList(java.util.LinkedList) RegularSymbolicParameterEstimation(com.sri.ai.praise.learning.symbolicparameterestimation.RegularSymbolicParameterEstimation) Test(org.junit.Test)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)2 ExpressionBasedModel (com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel)2 RegularSymbolicParameterEstimation (com.sri.ai.praise.learning.symbolicparameterestimation.RegularSymbolicParameterEstimation)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2