/// <summary> /// foamliu, 2009/04/15, 生成样本. /// </summary> /// <param name="set"></param> private static ExampleSet GetExamples(CategoryCollection collect) { const int Rows = 4; const int Columns = 4; const int CellWidth = 100; const int CellHeight = 100; const int ExampleNumber = 640; ExampleSet set = new ExampleSet(); set.Examples.Clear(); Random rand = new Random(); for (int i = 0; i < ExampleNumber; i++) { int x = (int)(rand.NextDouble() * Columns * CellWidth); int y = (int)(rand.NextDouble() * Rows * CellHeight); Example e = new Example(); e.X = new SparseVector(2); e.X[0] = x; e.X[1] = y; e.Label = collect.GetCategoryById( GetCat(x, y, CellWidth, CellHeight)); set.AddExample(e); } return(set); }