Search in sources :

Example 1 with RegularParameterEstimation

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

the class RegularParameterEstimationTest 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"));
    RegularParameterEstimation regularParameterEstimation = new RegularParameterEstimation(expressionBasedModel, queryExpressionList);
    Map<Expression, Double> result = regularParameterEstimation.optimize();
    System.out.println(result);
    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"));
    RegularParameterEstimation regularParameterEstimation3 = new RegularParameterEstimation(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) RegularParameterEstimation(com.sri.ai.praise.learning.symbolicparameterestimation.regularparameterestimation.RegularParameterEstimation) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with RegularParameterEstimation

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

the class RegularParameterEstimationTest method testReport.

/**
 * Tests for my report
 */
@Test
public void testReport() {
    long startTime = System.nanoTime();
    ExpressionBasedModel expressionBasedModel = ExpressionBasedModelExamples.buildModel1();
    List<Expression> queryExpressionList = new LinkedList<Expression>();
    queryExpressionList.add(parse("not earthquake and not burglary"));
    for (int i = 0; i < 3; i++) {
        queryExpressionList.add(parse("earthquake and burglary and alarm"));
    }
    for (int i = 0; i < 10; i++) {
        queryExpressionList.add(parse("not earthquake and burglary and alarm"));
    }
    for (int i = 0; i < 99; i++) {
        queryExpressionList.add(parse("not earthquake and not burglary and not alarm"));
    }
    for (int i = 0; i < 5; i++) {
        queryExpressionList.add(parse("earthquake and not burglary and not alarm"));
    }
    for (int i = 0; i < 4; i++) {
        queryExpressionList.add(parse("earthquake and not burglary and alarm"));
    }
    RegularParameterEstimation regularParameterEstimation = new RegularParameterEstimation(expressionBasedModel, queryExpressionList);
    Map<Expression, Double> result = regularParameterEstimation.optimize();
    System.out.println(result);
    long endTime = System.nanoTime();
    long totalTime = endTime - startTime;
    System.out.println("running time : " + totalTime * 0.000000001);
}
Also used : ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) Expression(com.sri.ai.expresso.api.Expression) RegularParameterEstimation(com.sri.ai.praise.learning.symbolicparameterestimation.regularparameterestimation.RegularParameterEstimation) LinkedList(java.util.LinkedList) 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 RegularParameterEstimation (com.sri.ai.praise.learning.symbolicparameterestimation.regularparameterestimation.RegularParameterEstimation)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2