Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Attribute sepallength = new Attribute("sepallength");
- Attribute sepalwidth = new Attribute("sepalwidth");
- Attribute petallength = new Attribute("petallength");
- Attribute petalwidth = new Attribute("petalwidth");
- ArrayList<String> cls_atr = new ArrayList<String>();
- cls_atr.add("Iris-setosa");
- cls_atr.add("Iris-versicolor");
- cls_atr.add("Iris-virginica");
- Attribute cls= new Attribute("class",cls_atr);
- ArrayList<Attribute> attributes = new ArrayList<Attribute>();
- attributes.add(sepallength);
- attributes.add(sepalwidth);
- attributes.add(petallength);
- attributes.add(petalwidth);
- attributes.add(cls);
- Instances dataset = new Instances("Test-dataset",attributes,5);
- double[] val = new double[data.numAttributes()];
- String text = null;
- BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Podaj sepallength: ");
- text = stdin.readLine();
- val[0] = Double.parseDouble(text);
- text = null;
- System.out.println("Podaj sepalwidth: ");
- text = stdin.readLine();
- val[1] = Double.parseDouble(text);
- text = null;
- System.out.println("Podaj petallength: ");
- text = stdin.readLine();
- val[2] = Double.parseDouble(text);
- text = null;
- System.out.println("Podaj petalwidth: ");
- text = stdin.readLine();
- val[3] = Double.parseDouble(text);
- val[4]=data.attribute(4).indexOfValue("class");
- Instance inst = new DenseInstance(1.0,val);
- data.add(inst);
- double index = j48.classifyInstance(data.instance(data.numInstances()-1));
- String className = data.attribute(data.numAttributes() - 1).value((int)index);
- System.out.println(className);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement