Using CSV file as a stream resource in MOA

684 Views Asked by At

how can I use a csv file as source of stream in MOA? In the GUI of MOA, there is only some options to use generators. Can I use my own data which is stored in csv file to be a source of streaming?

1

There are 1 best solutions below

1
Mahdi Mohamadian On

you can use SimpleCSVStream class like this:

        SimpleCSVStream stream = new SimpleCSVStream();
        stream.csvFileOption.setValue("d:\\your_filename.csv");
        stream.classIndexOption.setValue(true); //last column is class lable 
        stream.prepareForUse();
        while (stream.hasMoreInstances()) {
            InstanceExample trainInst = stream.nextInstance();

            //learning code
        }