void Compete(Recipe entry, RecipeIndex first, RecipeIndex second, Ranking winsBr, Ranking winsLu, Ranking winsDi, Ranking winsDe) { var res = GetPrediction(entry, first, second); if (res > .5f - TOLERANCE && res < .5f + TOLERANCE) { return; //No winner } var diff = (float)Math.Abs(res - 0.5); var winner = (res < 0.5 ? second : first); if (winner == BreakfastIndex) { winsBr.Score += diff; } if (winner == LunchIndex) { winsLu.Score += diff; } if (winner == DinnerIndex) { winsDi.Score += diff; } if (winner == DessertIndex) { winsDe.Score += diff; } }
public void LoadTrainingData(IDBLoader loader) { this.trainingData = new Dictionary<Guid, IRecipeClassification>(); this.breakfastIndex = new RecipeIndex(); this.lunchIndex = new RecipeIndex(); this.dinnerIndex = new RecipeIndex(); this.dessertIndex = new RecipeIndex(); var data = loader.LoadTrainingData(); foreach (var recipe in data) { this.trainingData.Add(recipe.Recipe.Id, recipe); if (recipe.IsBreakfast) { this.breakfastIndex.Add(recipe.Recipe); } if (recipe.IsLunch) { this.lunchIndex.Add(recipe.Recipe); } if (recipe.IsDinner) { this.dinnerIndex.Add(recipe.Recipe); } if (recipe.IsDessert) { this.dessertIndex.Add(recipe.Recipe); } } }
public void LoadTrainingData(IDBLoader loader) { trainingData = new Dictionary <Guid, IRecipeClassification>(); BreakfastIndex = new RecipeIndex(); LunchIndex = new RecipeIndex(); DinnerIndex = new RecipeIndex(); DessertIndex = new RecipeIndex(); var data = loader.LoadTrainingData(); foreach (var recipe in data) { trainingData.Add(recipe.Recipe.Id, recipe); if (recipe.IsBreakfast) { BreakfastIndex.Add(recipe.Recipe); } if (recipe.IsLunch) { LunchIndex.Add(recipe.Recipe); } if (recipe.IsDinner) { DinnerIndex.Add(recipe.Recipe); } if (recipe.IsDessert) { DessertIndex.Add(recipe.Recipe); } } }
float GetPrediction(Recipe recipe, RecipeIndex first, RecipeIndex second) { invI = I = 0; //Reset I/invI var tokens = Tokenizer.Tokenize(recipe); foreach (var token in tokens) { var firstCount = first.GetTokenCount(token); var secondCount = second.GetTokenCount(token); CalcProbability(firstCount, first.EntryCount, secondCount, second.EntryCount); } var prediction = CombineProbability(); return(prediction); }
private float GetPrediction(Recipe recipe, RecipeIndex firstIndex, RecipeIndex secondIndex) { // Reset I and invI this.invI = 0; this.i = 0; var tokens = Tokenizer.Tokenize(recipe); foreach (var token in tokens) { int firstCount = firstIndex.GetTokenCount(token); int secondCount = secondIndex.GetTokenCount(token); this.CalculateProbability(firstCount, firstIndex.EntryCount, secondCount, secondIndex.EntryCount); } float prediction = this.CombineProbability(); return prediction; }
private void Compete(Recipe entryRecipe, RecipeIndex firstIndex, RecipeIndex secondIndex, Ranking winsBreakfast, Ranking winsLunch, Ranking winsDinner, Ranking winsDessert) { var prediction = this.GetPrediction(entryRecipe, firstIndex, secondIndex); if (.5f - Tolerance < prediction && prediction < .5f + Tolerance) { return; // No winner } float difference = (float)Math.Abs(prediction - 0.5); var winner = prediction >= 0.5 ? firstIndex : secondIndex; if (winner == this.breakfastIndex) { winsBreakfast.Score += difference; } if (winner == this.lunchIndex) { winsLunch.Score += difference; } if (winner == this.dinnerIndex) { winsDinner.Score += difference; } if (winner == this.dessertIndex) { winsDessert.Score += difference; } }
float GetPrediction(Recipe recipe, RecipeIndex first, RecipeIndex second) { invI = I = 0; //Reset I/invI var tokens = Tokenizer.Tokenize(recipe); foreach (var token in tokens) { var firstCount = first.GetTokenCount(token); var secondCount = second.GetTokenCount(token); CalcProbability(firstCount, first.EntryCount, secondCount, second.EntryCount); } var prediction = CombineProbability(); return prediction; }
void Compete(Recipe entry, RecipeIndex first, RecipeIndex second, Ranking winsBr, Ranking winsLu, Ranking winsDi, Ranking winsDe) { var res = GetPrediction(entry, first, second); if (res > .5f - TOLERANCE && res < .5f + TOLERANCE) return; //No winner var diff = (float) Math.Abs(res - 0.5); var winner = (res < 0.5 ? second : first); if (winner == BreakfastIndex) winsBr.Score += diff; if (winner == LunchIndex) winsLu.Score += diff; if (winner == DinnerIndex) winsDi.Score += diff; if (winner == DessertIndex) winsDe.Score += diff; }
private void Compete( Recipe entry, RecipeIndex first, RecipeIndex second, Ranking winsBr, Ranking winsLu, Ranking winsDi, Ranking winsDe) { var res = this.GetPrediction(entry, first, second); if (res > .5f - Tolerance && res < .5f + Tolerance) { return; // No winner } var diff = (float)Math.Abs(res - 0.5); var winner = res < 0.5 ? second : first; if (winner == this.breakfastIndex) { winsBr.Score += diff; } if (winner == this.lunchIndex) { winsLu.Score += diff; } if (winner == this.dinnerIndex) { winsDi.Score += diff; } if (winner == this.dessertIndex) { winsDe.Score += diff; } }