Revised modeling

This commit is contained in:
dkohl
2012-03-12 21:41:20 -04:00
parent 12b4bab59d
commit 60ef59e00b
3 changed files with 26 additions and 11 deletions

View File

@@ -86,8 +86,11 @@ public class FoodNetBuilder {
DataPoint normPoint = new DataPoint(point);
for (String key : point.keySet()) {
if (onto.getInheritance().containsKey(key)) {
normPoint
.add(build(onto.getInheritance().get(key), TRUE_VALUE));
if(point.get(key).getValue().equals(TRUE_VALUE)){
normPoint.add(build(onto.getInheritance().get(key), TRUE_VALUE));
} else {
normPoint.add(build(onto.getInheritance().get(key), FALSE_VALUE));
}
}
}
@@ -125,17 +128,32 @@ public class FoodNetBuilder {
Ingredients ingredients = recipe.getIngredients();
if (ingredients.contains(TYPE.BEEF)) {
point.add(build(CONTAINS_BEEF, TRUE_VALUE));
if(weight > 5) {
point.add(build(CONTAINS_BEEF, TRUE_VALUE));
} else {
point.add(build(CONTAINS_BEEF, FALSE_VALUE));
}
}
if (ingredients.contains(TYPE.PORK)) {
point.add(build(CONTAINS_PORK, TRUE_VALUE));
if(weight > 5) {
point.add(build(CONTAINS_PORK, TRUE_VALUE));
} else {
point.add(build(CONTAINS_PORK, FALSE_VALUE));
}
}
if (ingredients.contains(TYPE.POTATO)) {
point.add(build(CONTAINS_POTATOS, TRUE_VALUE));
if(weight > 5) {
point.add(build(CONTAINS_POTATOS, TRUE_VALUE));
} else {
point.add(build(CONTAINS_POTATOS, FALSE_VALUE));
}
}
if (ingredients.contains(TYPE.TOMATO)) {
point.add(build(CONTAINS_TOMATOS, TRUE_VALUE));
}
if(weight > 5) {
point.add(build(CONTAINS_TOMATOS, TRUE_VALUE));
} else {
point.add(build(CONTAINS_TOMATOS, FALSE_VALUE));
} }
/*
* if (ingredients.contains(TYPE.GENERIC_NUTS)) {
* point.add(build(CONTAINS_GENERIC_NUTS, TRUE_VALUE)); }

View File

@@ -99,9 +99,6 @@ public class EnumerateAll {
temp.addAll(assignments);
temp.add(new Assignment(variable, value));
if(net.getNodes().get(variable.getName()).eval(temp) == null) {
System.out.println(variable.getName());
}
// then evaluate this variable
double val = net.getNodes().get(variable.getName()).eval(temp)
.getProbability();

View File

@@ -43,7 +43,7 @@ public class BayesChef {
int comparisonIndexEnd = numSurveyDishes;
//TODO change this to include min/max recipe indices for building the net
BayesNet net = FoodNetBuilder.createDishNet(survey, recipeBook, bayesNetIndexStart, bayesNetIndexEnd);
BayesNet net = FoodNetBuilder.createDishNet(survey, recipeBook, bayesNetIndexStart, bayesNetIndexEnd);// FoodNetBuilder.createDishNet(survey, recipeBook, bayesNetIndexStart, bayesNetIndexEnd);
System.out.println("Querying Bayes net for predicted flavor preferences: ");
//TODO change this to query actual flavor combos from latter half of survey