private DataFloat[] CreateFloatCbAdfData(int numSamples, int randomSeed = 0) { var random = new Random(randomSeed); var sampleData = new DataFloat[numSamples]; for (int i = 0; i < numSamples; i++) { int numActions = random.Next(2, 5); int[] fIndex = Enumerable.Range(1, numActions).OrderBy(ind => random.Next()).Take(numActions).ToArray(); var features = new float[numActions][]; for (int j = 0; j < numActions; j++) { features[j] = new float[] { (fIndex[j] + 0) / (float)numActions, (fIndex[j] + 1) / (float)numActions, (fIndex[j] + 2) / (float)numActions, (fIndex[j] + 3) / (float)numActions }; } var adf = new DataFloatADF[numActions]; int labelIndex = random.Next(-1, numActions); for (int j = 0; j < numActions; j++) { adf[j] = new DataFloatADF { Features = features[j] }; if (j == labelIndex) { adf[j].Label = new ContextualBanditLabel { Cost = (float)random.NextDouble(), Probability = (float)random.NextDouble() }; } } sampleData[i] = new DataFloat { ActionDependentFeatures = adf }; } return(sampleData); }
private DataFloat[] CreateFloatCbAdfData(int numSamples, int randomSeed = 0) { var random = new Random(randomSeed); var sampleData = new DataFloat[numSamples]; for (int i = 0; i < numSamples; i++) { int numActions = random.Next(2, 5); int[] fIndex = Enumerable.Range(1, numActions).OrderBy(ind => random.Next()).Take(numActions).ToArray(); var features = new float[numActions][]; for (int j = 0; j < numActions; j++) { features[j] = new float[] { (fIndex[j] + 0) / (float)numActions, (fIndex[j] + 1) / (float)numActions, (fIndex[j] + 2) / (float)numActions, (fIndex[j] + 3) / (float)numActions }; } var adf = new DataFloatADF[numActions]; for (int j = 0; j < numActions; j++) { adf[j] = new DataFloatADF { Features = features[j] }; } sampleData[i] = new DataFloat { ActionDependentFeatures = adf, SelectedActionIndex = random.Next(-1, numActions), Label = new ContextualBanditLabel { Cost = (float)random.NextDouble(), Probability = (float)random.NextDouble() } }; } return sampleData; }