static void Main(string[] args) { Assembly assembly = Assembly.GetExecutingAssembly(); Assembly.LoadFile(Path.GetDirectoryName(assembly.Location) + Path.DirectorySeparatorChar + "MyMediaLiteExperimental.dll"); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Handlers.UnhandledExceptionHandler); Console.CancelKeyPress += new ConsoleCancelEventHandler(AbortHandler); // check number of command line parameters if (args.Length < 1) { Usage("Not enough arguments."); } // read command line parameters string method = args[0]; RecommenderParameters parameters = null; try { parameters = new RecommenderParameters(args, 1); } catch (ArgumentException e) { Usage(e.Message); } // arguments for iteration search find_iter = parameters.GetRemoveInt32("find_iter", 0); max_iter = parameters.GetRemoveInt32("max_iter", 500); epsilon = parameters.GetRemoveDouble("epsilon", 1); err_cutoff = parameters.GetRemoveDouble("err_cutoff", 2); // data arguments string data_dir = parameters.GetRemoveString("data_dir"); if (data_dir != string.Empty) { data_dir = data_dir + "/mml-track2"; } else { data_dir = "mml-track2"; } sample_data = parameters.GetRemoveBool("sample_data", false); predict_rated = parameters.GetRemoveBool("predict_rated", false); predict_score = parameters.GetRemoveBool("predict_score", false); // other arguments save_model_file = parameters.GetRemoveString("save_model"); load_model_file = parameters.GetRemoveString("load_model"); int random_seed = parameters.GetRemoveInt32("random_seed", -1); prediction_file = parameters.GetRemoveString("prediction_file"); if (predict_rated) { predict_score = true; } Console.Error.WriteLine("predict_score={0}", predict_score); if (random_seed != -1) { MyMediaLite.Util.Random.InitInstance(random_seed); } recommender_validate = Recommender.CreateItemRecommender(method); if (recommender_validate == null) { Usage(string.Format("Unknown method: '{0}'", method)); } Recommender.Configure(recommender_validate, parameters, Usage); recommender_final = recommender_validate.Clone() as ItemRecommender; if (parameters.CheckForLeftovers()) { Usage(-1); } // load all the data LoadData(data_dir); if (load_model_file != string.Empty) { Recommender.LoadModel(recommender_validate, load_model_file + "-validate"); Recommender.LoadModel(recommender_final, load_model_file + "-final"); } Console.Write(recommender_validate.ToString()); DoTrack2(); }
static void Main(string[] args) { Assembly assembly = Assembly.GetExecutingAssembly(); Assembly.LoadFile(Path.GetDirectoryName(assembly.Location) + Path.DirectorySeparatorChar + "MyMediaLiteExperimental.dll"); double min_rating = 0; double max_rating = 100; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Handlers.UnhandledExceptionHandler); Console.CancelKeyPress += new ConsoleCancelEventHandler(AbortHandler); // check number of command line parameters if (args.Length < 1) { Usage("Not enough arguments."); } // read command line parameters string method = args[0]; RecommenderParameters parameters = null; try { parameters = new RecommenderParameters(args, 1); } catch (ArgumentException e) { Usage(e.Message); } // arguments for iteration search find_iter = parameters.GetRemoveInt32("find_iter", 0); max_iter = parameters.GetRemoveInt32("max_iter", 500); compute_fit = parameters.GetRemoveBool("compute_fit", false); epsilon = parameters.GetRemoveDouble("epsilon", 0); rmse_cutoff = parameters.GetRemoveDouble("rmse_cutoff", double.MaxValue); mae_cutoff = parameters.GetRemoveDouble("mae_cutoff", double.MaxValue); // data arguments string data_dir = parameters.GetRemoveString("data_dir"); track2 = parameters.GetRemoveBool("track2", false); if (data_dir != string.Empty) { data_dir = data_dir + (track2 ? "/mml-track2" : "/track1"); } else { data_dir = track2 ? "/mml-track2" : "track1"; } sample_data = parameters.GetRemoveBool("sample_data", false); // other arguments save_model_file = parameters.GetRemoveString("save_model"); load_model_file = parameters.GetRemoveString("load_model"); int random_seed = parameters.GetRemoveInt32("random_seed", -1); no_eval = parameters.GetRemoveBool("no_eval", false); prediction_file = parameters.GetRemoveString("prediction_file"); cross_validation = parameters.GetRemoveInt32("cross_validation", 0); good_rating_prob = parameters.GetRemoveBool("good_rating_prob", false); if (good_rating_prob) { max_rating = 1; } if (random_seed != -1) { MyMediaLite.Util.Random.InitInstance(random_seed); } recommender = Recommender.CreateRatingPredictor(method); if (recommender == null) { Usage(string.Format("Unknown method: '{0}'", method)); } Recommender.Configure(recommender, parameters, Usage); if (parameters.CheckForLeftovers()) { Usage(-1); } // load all the data TimeSpan loading_time = Utils.MeasureTime(delegate() { LoadData(data_dir); }); Console.Error.WriteLine(string.Format(CultureInfo.InvariantCulture, "loading_time {0,0:0.##}", loading_time.TotalSeconds)); recommender.Ratings = training_ratings; recommender.MinRating = min_rating; recommender.MaxRating = max_rating; Console.Error.WriteLine(string.Format(CultureInfo.InvariantCulture, "ratings range: [{0}, {1}]", recommender.MinRating, recommender.MaxRating)); if (load_model_file != string.Empty) { Recommender.LoadModel(recommender, load_model_file); } DoTrack1(); Console.Error.WriteLine("memory {0}", Memory.Usage); }
static void Main(string[] args) { Assembly assembly = Assembly.GetExecutingAssembly(); Assembly.LoadFile(Path.GetDirectoryName(assembly.Location) + Path.DirectorySeparatorChar + "MyMediaLiteExperimental.dll"); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Handlers.UnhandledExceptionHandler); Console.CancelKeyPress += new ConsoleCancelEventHandler(AbortHandler); // check number of command line parameters if (args.Length < 1) Usage("Not enough arguments."); // read command line parameters string method = args[0]; RecommenderParameters parameters = null; try { parameters = new RecommenderParameters(args, 1); } catch (ArgumentException e) { Usage(e.Message); } // arguments for iteration search find_iter = parameters.GetRemoveInt32( "find_iter", 0); max_iter = parameters.GetRemoveInt32( "max_iter", 500); epsilon = parameters.GetRemoveDouble( "epsilon", 1); err_cutoff = parameters.GetRemoveDouble( "err_cutoff", 2); // data arguments string data_dir = parameters.GetRemoveString( "data_dir"); if (data_dir != string.Empty) data_dir = data_dir + "/mml-track2"; else data_dir = "mml-track2"; sample_data = parameters.GetRemoveBool( "sample_data", false); predict_rated = parameters.GetRemoveBool( "predict_rated", false); predict_score = parameters.GetRemoveBool( "predict_score", false); // other arguments save_model_file = parameters.GetRemoveString( "save_model"); load_model_file = parameters.GetRemoveString( "load_model"); int random_seed = parameters.GetRemoveInt32( "random_seed", -1); prediction_file = parameters.GetRemoveString( "prediction_file"); if (predict_rated) predict_score = true; Console.Error.WriteLine("predict_score={0}", predict_score); if (random_seed != -1) MyMediaLite.Util.Random.InitInstance(random_seed); recommender_validate = Recommender.CreateItemRecommender(method); if (recommender_validate == null) Usage(string.Format("Unknown method: '{0}'", method)); Recommender.Configure(recommender_validate, parameters, Usage); recommender_final = recommender_validate.Clone() as ItemRecommender; if (parameters.CheckForLeftovers()) Usage(-1); // load all the data LoadData(data_dir); if (load_model_file != string.Empty) { Recommender.LoadModel(recommender_validate, load_model_file + "-validate"); Recommender.LoadModel(recommender_final, load_model_file + "-final"); } Console.Write(recommender_validate.ToString()); DoTrack2(); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Handlers.UnhandledExceptionHandler); Console.CancelKeyPress += new ConsoleCancelEventHandler(AbortHandler); // check number of command line parameters if (args.Length < 1) Usage("Not enough arguments."); // read command line parameters string method = args[0]; RecommenderParameters parameters = null; try { parameters = new RecommenderParameters(args, 1); } catch (ArgumentException e) { Usage(e.Message); } // arguments for iteration search find_iter = parameters.GetRemoveInt32( "find_iter", 0); max_iter = parameters.GetRemoveInt32( "max_iter", 500); compute_fit = parameters.GetRemoveBool( "compute_fit", false); epsilon = parameters.GetRemoveDouble( "epsilon", 0); rmse_cutoff = parameters.GetRemoveDouble( "rmse_cutoff", double.MaxValue); mae_cutoff = parameters.GetRemoveDouble( "mae_cutoff", double.MaxValue); // data arguments string data_dir = parameters.GetRemoveString( "data_dir"); track2 = parameters.GetRemoveBool( "track2", false); if (data_dir != string.Empty) data_dir = data_dir + (track2 ? "/mml-track2" : "/track1"); else data_dir = track2 ? "/mml-track2" : "track1"; sample_data = parameters.GetRemoveBool( "sample_data", false); // other arguments save_model_file = parameters.GetRemoveString( "save_model"); load_model_file = parameters.GetRemoveString( "load_model"); int random_seed = parameters.GetRemoveInt32( "random_seed", -1); no_eval = parameters.GetRemoveBool( "no_eval", false); prediction_file = parameters.GetRemoveString( "prediction_file"); cross_validation = parameters.GetRemoveUInt32( "cross_validation", 0); good_rating_prob = parameters.GetRemoveBool( "good_rating_prob", false); if (random_seed != -1) MyMediaLite.Util.Random.Seed = random_seed; recommender = Recommender.CreateRatingPredictor(method); if (recommender == null) Usage(string.Format("Unknown method: '{0}'", method)); Recommender.Configure(recommender, parameters, Usage); if (parameters.CheckForLeftovers()) Usage(-1); // load all the data TimeSpan loading_time = Wrap.MeasureTime(delegate() { LoadData(data_dir); }); Console.Error.WriteLine(string.Format(CultureInfo.InvariantCulture, "loading_time {0,0:0.##}", loading_time.TotalSeconds)); recommender.Ratings = training_ratings; Console.Error.WriteLine(string.Format(CultureInfo.InvariantCulture, "ratings range: [{0}, {1}]", recommender.MinRating, recommender.MaxRating)); if (load_model_file != string.Empty) Model.Load(recommender, load_model_file); DoTrack1(); Console.Error.WriteLine("memory {0}", Memory.Usage); }