// Test the classification result of each map that a user played, // with the data available as if they were playing through it public static void classifyTest(String dataString, String playerID) { // Get the initial data (the headers and the first instance) String [] split = dataString.Split('\n'); // 19 attribute lines, 2 header lines, 1 instance line String initData = ""; for (int i = 0; i < 22; i++) initData = initData+ split[i] + '\n'; PCGWekaClassifier classifier = new PCGWekaClassifier(); classifier.InitializeClassifier(initData); // Loop through the res of the data, classifiying new instance and then // updating the classifier. -1 because the last line i believe is blank String predictions = ""; String actuals = ""; for (int i = 22; i < split.Length; i++) { if (split[i].Equals("")) break; double[] newData = instanceStringToDoubleArray(split[i]); double[] results = classifier.ClassifyNewData(newData); int finalResult = -1; if (results[1] < 0.5) finalResult = 0; else finalResult = 1; // Random classifier /*int min = 0; int max = 2; finalResult = UnityEngine.Random.Range(min,max); */ String [] lineSplit = split[i].Split(','); int userRating = int.Parse(lineSplit[lineSplit.Length-2]); //Debug.Log("Map = " + (i-20) + ", Dislike = " + results[0] + ", Like = " + results[1] + ", Result = " + finalResult); if (i != 22) { predictions = predictions + ", "; actuals = actuals + ", "; } predictions = predictions + finalResult.ToString(); actuals = actuals + userRating; classifier.UpdateClassifierFromInstanceString(split[i]); } // Write values to file for a matlab read StreamWriter writer = new StreamWriter("DataForMatlab\\"+playerID+"_ModelPredictions_RandomForest.txt"); writer.WriteLine(predictions); writer.WriteLine(actuals); writer.Close(); }
public void RunEA(List <PCGNeatNodeData> geometryData, PCGWekaClassifier updatedPlayerModel) { //yield return new WaitForSeconds(0.5f); if (contentEA == null) { Debug.LogError("Content EA not initialized"); } else { ((PCGNeatExperiment)(experiment)).geomNodeList = geometryData; ((PCGNeatExperiment)(experiment)).playerModel = updatedPlayerModel; contentEA.StartContinue(); } }
public void RunEA(List<PCGNeatNodeData> geometryData, PCGWekaClassifier updatedPlayerModel) { //yield return new WaitForSeconds(0.5f); if (contentEA == null) Debug.LogError("Content EA not initialized"); else { ((PCGNeatExperiment)(experiment)).geomNodeList = geometryData; ((PCGNeatExperiment)(experiment)).playerModel = updatedPlayerModel; contentEA.StartContinue(); } }
// Test the classification result of each map that a user played, // with the data available as if they were playing through it public static void classifyTest(String dataString, String playerID) { // Get the initial data (the headers and the first instance) String [] split = dataString.Split('\n'); // 19 attribute lines, 2 header lines, 1 instance line String initData = ""; for (int i = 0; i < 22; i++) { initData = initData + split[i] + '\n'; } PCGWekaClassifier classifier = new PCGWekaClassifier(); classifier.InitializeClassifier(initData); // Loop through the res of the data, classifiying new instance and then // updating the classifier. -1 because the last line i believe is blank String predictions = ""; String actuals = ""; for (int i = 22; i < split.Length; i++) { if (split[i].Equals("")) { break; } double[] newData = instanceStringToDoubleArray(split[i]); double[] results = classifier.ClassifyNewData(newData); int finalResult = -1; if (results[1] < 0.5) { finalResult = 0; } else { finalResult = 1; } // Random classifier /*int min = 0; * int max = 2; * finalResult = UnityEngine.Random.Range(min,max); */ String [] lineSplit = split[i].Split(','); int userRating = int.Parse(lineSplit[lineSplit.Length - 2]); //Debug.Log("Map = " + (i-20) + ", Dislike = " + results[0] + ", Like = " + results[1] + ", Result = " + finalResult); if (i != 22) { predictions = predictions + ", "; actuals = actuals + ", "; } predictions = predictions + finalResult.ToString(); actuals = actuals + userRating; classifier.UpdateClassifierFromInstanceString(split[i]); } // Write values to file for a matlab read StreamWriter writer = new StreamWriter("DataForMatlab\\" + playerID + "_ModelPredictions_RandomForest.txt"); writer.WriteLine(predictions); writer.WriteLine(actuals); writer.Close(); }