public List <int> GetInputVectorFromShapeFeatures(ShapeFeatures shapeFeatures) { var acuteSerialCode = SerialCoding.GetSeriallyCodedValue(shapeFeatures.AcuteAngles, serialCodeLength); var rightSerialCode = SerialCoding.GetSeriallyCodedValue(shapeFeatures.RightAngles, serialCodeLength); var wideSerialCode = SerialCoding.GetSeriallyCodedValue(shapeFeatures.WideAngles, serialCodeLength); var straightSerialCode = SerialCoding.GetSeriallyCodedValue(shapeFeatures.StraightAngles, serialCodeLength); return(acuteSerialCode.Concat(rightSerialCode).Concat(wideSerialCode).Concat(straightSerialCode).ToList()); }
public void TestThatNetworkTrainedWith2GroupsOfNumbersCanRecognizeNumberFromTheSecondGroup() { var expectedClass = "second group"; TrainNetworkWith2GroupsOfNumbers("first group", expectedClass); var valueFromGroup1 = SerialCoding.GetSeriallyCodedValue(85, 100); var result = bswNeuralNetwork.PredictClass(valueFromGroup1); Assert.AreEqual(expectedClass, result); }
public void TestThatGetSeriallyCodedValueReturnsExpectedSerialCodingFor5() { var length = 5; var value = 5; var expectedSerialCoding = new List <int> { 1, 1, 1, 1, 1 }; var result = SerialCoding.GetSeriallyCodedValue(value, length); CollectionAssert.AreEqual(expectedSerialCoding, result); }
private void TrainNetworkWith2GroupsOfNumbers(string class1, string class2) { var group1 = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 50 }; var group2 = new List <int> { 60, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 }; var group1Samples = group1.Select(x => new Sample { InputVector = SerialCoding.GetSeriallyCodedValue(x, 100), OutputClass = class1 }); var group2Samples = group2.Select(x => new Sample { InputVector = SerialCoding.GetSeriallyCodedValue(x, 100), OutputClass = class2 }); var allSamples = group1Samples.Concat(group2Samples).ToList(); var trainedModel = algorithm.Train(allSamples); bswNeuralNetwork = new BSWNeuralNetwork(trainedModel); }
public void TestThatWhenValueIsNegativeGetSeriallyCodedValueThrowsArgumentException() { var result = SerialCoding.GetSeriallyCodedValue(-1, 5); }
public void TestThatWhenValueIsGreaterThanLengthGetSeriallyCodedValueThrowsArgumentException() { SerialCoding.GetSeriallyCodedValue(6, 5); }