更新时间:2023-10-21 23:43:46
这样的事情应该对你有用,基本上我们创建一个新实例并使用扫描仪为新实例获取用户输入(我还没有测试这个,让我知道它是否有效或有任何问题):
Something like this should work for you, basically we create a new instance and use a scanner to take user input for the new instance (I haven't test this, let me know if it works or if there are any problems):
double a, b;
Scanner s = new Scanner(System.in);
System.out.println("Please enter marks:");
a = s.nextDouble();
b = s.nextDouble();
Instance inst = new DenseInstance(3);
inst.setValue(COMS1000, a);
inst.setValue(MATH1001, b);
inst.setClassMissing();
inst.setDataset(source);
double pred = tree.classifyInstance(inst);
System.out.println(pred.value(Double.toString(pred)));