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);
}
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;
}
Aggregations