How to use date type in weka in java code?

六月ゝ 毕业季﹏ 提交于 2019-12-06 03:06:41

This is how I solved the problem:

    Attribute dateTimeAttribute = new Attribute("dateTime","yyyy-MM-dd HH:mm");
    Attribute valueAttribute = new Attribute("value");

    FastVector fvWekaAttributesLinear = new FastVector(2);          
    fvWekaAttributesLinear.addElement(dateTimeAttribute);
    fvWekaAttributesLinear.addElement(valueAttribute); 

    Instances isTrainingSet = new Instances("Relation", fvWekaAttributesLinear, 100000);
    double[] attValues = new double[isTrainingSet.numAttributes()];

    attValues[0] = isTrainingSet.attribute("dateTime").parseDate("2009-07-15 10:00");
    attValues[1] = 0.5;

Here is a link that I found useful: http://zitnik.si/wordpress/2011/09/25/quick-intro-to-weka/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!