title: Recreating Accord.NET DecisionTree website example - Given keys not present in the dictionary
body: <p>I am following the example on the Accord.net website to the letter:</p>
  
  <p><a href="http://accord-framework.net/docs/html/T_Accord_MachineLearning_DecisionTrees_Learning_ID3Learning.htm" rel="nofollow">Link to the example, scroll to the bottom</a></p>
  
  <p>My code is a copy of the code on the website example. I have the correct NuGet packages included. </p>
  
  <pre><code>  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 integer symbols
                  Codification codebook = new Codification(data);
  
                  // Translate our training data into integer symbols using our codebook:
                  DataTable symbols = codebook.Apply(data);
                  int[][] inputs = symbols.ToArray&lt;int&gt;("Outlook", "Temperature", "Humidity", "Wind");
                  int[] outputs = symbols.ToArray&lt;int&gt;("PlayTennis");
  
                  // Gather information about decision variables
                  DecisionVariable[] attributes =
      {
        new DecisionVariable("Outlook",     3), // 3 possible values (Sunny, overcast, rain)
        new DecisionVariable("Temperature", 3), // 3 possible values (Hot, mild, cool)  
        new DecisionVariable("Humidity",    2), // 2 possible values (High, normal)    
        new DecisionVariable("Wind",        2)  // 2 possible values (Weak, strong) 
      };
  
                  int classCount = 2; // 2 possible output values for playing tennis: yes or no
  
                  //Create the decision tree using the attributes and classes
                  DecisionTree tree = new DecisionTree(attributes, classCount);
  
                  // Create a new instance of the ID3 algorithm
                  ID3Learning id3learning = new ID3Learning(tree);
  
                  // Learn the training instances!
                  id3learning.Run(inputs, outputs);
  
                  string answer = codebook.Translate("PlayTennis",
                      tree.Compute(codebook.Translate("Sunny", "Hot", "High", "Strong")));
  
                  Console.WriteLine("Calculate for: Sunny, Hot, High, Strong");
                  Console.WriteLine("Answer: " + answer);
  </code></pre>
  
  <p>I get this exception:</p>
  
  <pre><code>The given key was not present in the dictionary.
  </code></pre>
  
  <p>At this line of code:</p>
  
  <pre><code>string answer = codebook.Translate("PlayTennis",
                  tree.Compute(codebook.Translate("Sunny", "Hot", "High", "Strong")));
  </code></pre>
  
  <p>Where do I start to solve this? I've checked the codebook in the debugger and it contains elements like it should.</p>