public void ComputeTest_Obsolete()
{
DataTable data = new DataTable("Mitchell's Tennis Example");
data.Columns.Add("Day", "Outlook", "Temperature", "Humidity", "Wind", "PlayTennis");
data.Rows.Add("D1", "Sunny", "Hot", "High", "Weak", "No");
data.Rows.Add("D2", "Sunny", "Hot", "High", "Strong", "No");
data.Rows.Add("D3", "Overcast", "Hot", "High", "Weak", "Yes");
data.Rows.Add("D4", "Rain", "Mild", "High", "Weak", "Yes");
data.Rows.Add("D5", "Rain", "Cool", "Normal", "Weak", "Yes");
data.Rows.Add("D6", "Rain", "Cool", "Normal", "Strong", "No");
data.Rows.Add("D7", "Overcast", "Cool", "Normal", "Strong", "Yes");
data.Rows.Add("D8", "Sunny", "Mild", "High", "Weak", "No");
data.Rows.Add("D9", "Sunny", "Cool", "Normal", "Weak", "Yes");
data.Rows.Add("D10", "Rain", "Mild", "Normal", "Weak", "Yes");
data.Rows.Add("D11", "Sunny", "Mild", "Normal", "Strong", "Yes");
data.Rows.Add("D12", "Overcast", "Mild", "High", "Strong", "Yes");
data.Rows.Add("D13", "Overcast", "Hot", "Normal", "Weak", "Yes");
data.Rows.Add("D14", "Rain", "Mild", "High", "Strong", "No");
// Create a new codification codebook to
// convert strings into discrete symbols
Codification codebook = new Codification(data,
"Outlook", "Temperature", "Humidity", "Wind", "PlayTennis");
int[] symbolCounts =
{
codebook["Outlook"].Symbols, // 3 possible values (Sunny, overcast, rain)
codebook["Temperature"].Symbols, // 3 possible values (Hot, mild, cool)
codebook["Humidity"].Symbols, // 2 possible values (High, normal)
codebook["Wind"].Symbols // 2 possible values (Weak, strong)
};
int classCount = codebook["PlayTennis"].Symbols; // 2 possible values (yes, no)
// Create a new Naive Bayes classifiers for the two classes
NaiveBayes target = new NaiveBayes(classCount, symbolCounts);
// Extract symbols from data and train the classifier
DataTable symbols = codebook.Apply(data);
int[][] inputs = symbols.ToArray<int>("Outlook", "Temperature", "Humidity", "Wind");
int[] outputs = symbols.ToArray<int>("PlayTennis");
// Compute the Naive Bayes model
target.Estimate(inputs, outputs);
double logLikelihood;
double[] responses;
// Compute the result for a sunny, cool, humid and windy day:
int[] instance = codebook.Translate("Sunny", "Cool", "High", "Strong");
int c = target.Compute(instance, out logLikelihood, out responses);
string result = codebook.Translate("PlayTennis", c);
Assert.AreEqual("No", result);
Assert.AreEqual(0, c);
Assert.AreEqual(0.795, responses[0], 1e-3);
Assert.AreEqual(1, responses.Sum(), 1e-10);
Assert.IsFalse(double.IsNaN(responses[0]));
Assert.AreEqual(2, responses.Length);
}