public void TestBalanced() { var frequency = new MutableIntFrequency(); frequency.DefaultValue = 0.0000001; frequency.Set(new IntArrow<double>(1, 520.0)); frequency.Set(new IntArrow<double>(2, 49, 3.0)); frequency.Set(new IntArrow<double>(50, 236.0)); frequency.Set(new IntArrow<double>(51, 100, 2.0)); const int DefaultValue = -1; var elementToAction = new MutableIntMap<int>(); elementToAction.DefaultValue = DefaultValue; elementToAction.Set(new IntArrow<int>(1, 1)); elementToAction.Set(new IntArrow<int>(2, 49, 2)); elementToAction.Set(new IntArrow<int>(50, 3)); elementToAction.Set(new IntArrow<int>(51, 100, 4)); var target = new DecisionTreeBuilder(platformInfo); var bounds = new IntInterval(int.MinValue, int.MaxValue); var node = target.Build(elementToAction, bounds, frequency); PrintProgram(node, target.DefaultActionDecision); Assert.AreEqual(-1, node.Decide(int.MinValue) ); Assert.AreEqual(-1, node.Decide(0) ); Assert.AreEqual(1, node.Decide(1) ); Assert.AreEqual(2, node.Decide(2) ); Assert.AreEqual(2, node.Decide(49) ); Assert.AreEqual(3, node.Decide(50) ); Assert.AreEqual(4, node.Decide(51) ); Assert.AreEqual(4, node.Decide(100) ); Assert.AreEqual(-1, node.Decide(200) ); Assert.AreEqual(-1, node.Decide(bounds.Last) ); }
private static MutableIntFrequency BuildDefault() { var result = new MutableIntFrequency(); result.DefaultValue = 0.0; result.Set(new IntArrow<double>(UnicodeIntSetType.UnicodeInterval, 0.0000001)); result.Set(new IntArrow<double>(0, 1)); result.Set((IntervalIntSet)UnicodeIntSetType.Instance.LetterNumber, 0.1); result.Set((IntervalIntSet)UnicodeIntSetType.Instance.AsciiPrint, 10.0); result.Set((IntervalIntSet)UnicodeIntSetType.Instance.AsciiDigit, 20.0); result.Set((IntervalIntSet)UnicodeIntSetType.Instance.AsciiAlpha, 100.0); result.Normalize(); return result; }
public void TestBalanced() { var frequency = new MutableIntFrequency(); frequency.DefaultValue = 0.0000001; frequency.Set(new IntArrow <double>(1, 520.0)); frequency.Set(new IntArrow <double>(2, 49, 3.0)); frequency.Set(new IntArrow <double>(50, 236.0)); frequency.Set(new IntArrow <double>(51, 100, 2.0)); const int DefaultValue = -1; var elementToAction = new MutableIntMap <int>(); elementToAction.DefaultValue = DefaultValue; elementToAction.Set(new IntArrow <int>(1, 1)); elementToAction.Set(new IntArrow <int>(2, 49, 2)); elementToAction.Set(new IntArrow <int>(50, 3)); elementToAction.Set(new IntArrow <int>(51, 100, 4)); var target = new DecisionTreeBuilder(platformInfo); var bounds = new IntInterval(int.MinValue, int.MaxValue); var node = target.Build(elementToAction, bounds, frequency); PrintProgram(node, target.DefaultActionDecision); Assert.AreEqual(-1, node.Decide(int.MinValue)); Assert.AreEqual(-1, node.Decide(0)); Assert.AreEqual(1, node.Decide(1)); Assert.AreEqual(2, node.Decide(2)); Assert.AreEqual(2, node.Decide(49)); Assert.AreEqual(3, node.Decide(50)); Assert.AreEqual(4, node.Decide(51)); Assert.AreEqual(4, node.Decide(100)); Assert.AreEqual(-1, node.Decide(200)); Assert.AreEqual(-1, node.Decide(bounds.Last)); }
private UnicodeFrequency(MutableIntFrequency data) { this.data = data; }