private void WriteErrorEvalReport(ErrorEvaluation con) { string path = Setting.OutPutErrorEvalReportFileLocation; if (!File.Exists(path)) { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine("This is a document for error evaluation"); sw.WriteLine(" "); } } // This text is always added, making the file longer over time // if it is not deleted. using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine(" "); sw.WriteLine($"Date: : {DateTime.Now}"); //sw.WriteLine($"AnimeList file : {Setting._AnimelistFileName } , amount of lines {File.ReadAllLines(Setting.AnimelistFileName).Count()}"); sw.WriteLine($"Matrix file: {Setting.InputMatrixFileName} "); sw.WriteLine($"Testing useranimelist file (matrix tester): {Setting.EvalUserAnimeListFileName}, amount of lines {File.ReadAllLines(Setting.EvalUserAnimeListLocation).Count()}"); sw.WriteLine($"Base MAE SCORE: {Math.Round(con.BaseMAE, 4)}"); sw.WriteLine($"Base RMSE SCORE: {Math.Round(con.BaseRMSE, 4)}"); sw.WriteLine($"----"); sw.WriteLine($"MAE SCORE: {Math.Round(con.MAE, 4)}"); sw.WriteLine($"RMSE SCORE: {Math.Round(con.RMSE, 4)}"); sw.WriteLine($"Progress time: {Math.Round(con.ProgressingTime.TotalSeconds, 2)} Sec"); sw.WriteLine(" "); } Console.WriteLine("Report is updated"); }
public void CalcErrorEval() { Console.WriteLine($"Start error eval"); DateTime startTime = DateTime.Now; //List<List<AnimeStat>> UsersAnimes = reader.GetAnimeListForEval(); double totalBaseMAE = 0; double totalBaseRMSE = 0; double totalMAE = 0; double totalRMSE = 0; int N = 0; int counter = 0; foreach (var userAnimes in reader.GetAnimeListForEval()) { if (counter % 1000 == 0) { Console.WriteLine($" current user nr: {counter}"); } counter++; if (userAnimes.Count < 2) { continue; } ErrorEvaluation x = PrepareEvaluation(userAnimes); //TODO discuss if one of the 2 is not available if (x.MAE == -1 || x.RMSE == -1 || x.BaseMAE == -1 || x.BaseRMSE == -1) { continue; } totalBaseMAE = totalBaseMAE + x.BaseMAE; totalBaseRMSE = totalBaseRMSE + x.BaseRMSE; totalMAE = totalMAE + x.MAE; totalRMSE = totalRMSE + x.RMSE; N++; } ErrorEvaluation conclusion = new ErrorEvaluation(totalMAE / N, totalRMSE / N, totalBaseMAE / N, totalBaseRMSE / N, DateTime.Now - startTime); WriteErrorEvalReport(conclusion); Console.WriteLine($"----- Error eval Complete -----"); Console.WriteLine($""); }