forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecisionTreeTest.cs
More file actions
38 lines (32 loc) · 1.24 KB
/
DecisionTreeTest.cs
File metadata and controls
38 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using BotSharp.Algorithm.DecisionTree;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Data;
using System.IO;
namespace BotSharp.Algorithm.UnitTest
{
[TestClass]
public class DecisionTreeTest : TestEssential
{
[TestMethod]
public void TestID3()
{
// train
string dataDir = Configuration.GetSection("dataDir").Value;
string filePath = Path.Combine(dataDir, "training", "DecisionTree.csv");
var data = new DataReader().Read(filePath);
var decisionTree = new Tree();
decisionTree.Root = Tree.Learn(data, "");
// predict
Dictionary<string, string> testValues = new Dictionary<string, string>();
testValues.Add("Outlook", "Rain");
testValues.Add("Temperatur", "Mild");
testValues.Add("Humidity", "High");
testValues.Add("Wind", "Weak");
var result = Tree.CalculateResult(decisionTree.Root, testValues, "");
Tree.Print(null, result);
Tree.PrintLegend("The colors indicate the following values:");
Assert.IsTrue(result.Equals("OUTLOOK -- rain --> WIND -- weak --> NO"));
}
}
}