CSV 2 weka Arff - Java Machine Learning AI

Java examples for Machine Learning AI:weka

Description

CSV 2 weka Arff

Demo Code

import java.io.File;
import java.io.IOException;

import weka.core.Instances;
import weka.core.converters.ArffSaver;
import weka.core.converters.CSVLoader;

public class CSV2Arff {
    public static void main(String[] args) throws IOException {
        CSVLoader loader = new CSVLoader();
        loader.setSource(new File("house.csv"));
        Instances data = loader.getDataSet();

        ArffSaver saver = new ArffSaver();
        saver.setInstances(data);//from ww w .  ja v a2s  .c  om
        saver.setFile(new File("house-new.arff"));
        saver.writeBatch();

    }
}

Related Tutorials