title: Weka throws "UnassignedDatasetException"
body: <p>I am working with Weka 3.6.11 and I am having an error which I can't figure out what is causing it.
  I have followed pages 202-204 in the Weka manual and have constructed my data like they say. Still when I try t classify the data I get an error. </p>
  
  <pre><code>weka.core.UnassignedDatasetException: Instance doesn't have access to a dataset!
  </code></pre>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>public static void classifyTest()
      {
          try
          {
  
              Classifier classifier = (Classifier)weka.core.SerializationHelper.read("iris120.model");
  
              System.Console.WriteLine("----------------------------");
  
              weka.core.Attribute sepallength = new weka.core.Attribute("sepallength");
              weka.core.Attribute sepalwidth = new weka.core.Attribute("sepalwidth");
              weka.core.Attribute petallength = new weka.core.Attribute("petallength");
              weka.core.Attribute petalwidth = new weka.core.Attribute("petalwidth");
              FastVector labels = new FastVector();
              labels.addElement("Iris-setosa");
              labels.addElement("Iris-versicolor");
              labels.addElement("Iris-virginica");
              weka.core.Attribute cls = new weka.core.Attribute("class", labels);
              FastVector attributes = new FastVector();
              attributes.addElement(sepallength);
              attributes.addElement(sepalwidth);
              attributes.addElement(petallength);
              attributes.addElement(petalwidth);
              attributes.addElement(cls);
              Instances dataset = new Instances("TestInstances", attributes, 0);
  
              double[] values = new double[dataset.numAttributes()];
              values[0] = 5.0;
              values[1] = 3.5;
              values[2] = 1.3;
              values[3] = 0.3;
  
              Instance inst = new Instance(1,values);
              dataset.add(inst);
  
              // Here I try to classify the data that I have constructed.
              try
              {
  
                  double predictedClass = classifier.classifyInstance(inst);
                  System.Console.WriteLine("Class1: (irisSetosa): " + predictedClass);
  
              }
              catch (java.lang.Exception ex)
              {
                  ex.printStackTrace();
              }
  
  
              System.Console.ReadLine();
  
          }
          catch (java.lang.Exception ex)
          {
              ex.printStackTrace();
              System.Console.ReadLine();
          }
      }
  </code></pre>
  
  <p>From the error message I take it that I need to assign my dataset something but I do not know what or how.
  Can someone point out my mistake?
  Thanks.</p>