Java Code Examples for weka.core.converters.ArffLoader#setSource()
The following examples show how to use
weka.core.converters.ArffLoader#setSource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: logistic_regression.java From CompetitiveJava with MIT License | 6 votes |
@param fileName * @return * @throws IOException */ public static Instances getDataSet(String fileName) throws IOException { /** * we can set the file i.e., loader.setFile("finename") to load the data */ int classIdx = 1; /** the arffloader to load the arff file */ ArffLoader loader = new ArffLoader(); //loader.setFile(new File(fileName)); /** load the traing data */ loader.setSource(LogisticRegressionDemo.class.getResourceAsStream("/" + fileName)); /** * we can also set the file like loader3.setFile(new * File("test-confused.arff")); */ Instances dataSet = loader.getDataSet(); /** set the index based on the data given in the arff files */ dataSet.setClassIndex(classIdx); return dataSet; }
Example 2
Source File: Arff2CSV.java From Hands-On-Artificial-Intelligence-with-Java-for-Beginners with MIT License | 6 votes |
/** * @param args the command line arguments */ public static void main(String[] args) throws Exception { ArffLoader loader = new ArffLoader(); loader.setSource(new File("/Users/admin/Documents/NetBeansProjects/Datasets/weather.arff")); Instances data = loader.getDataSet(); CSVSaver saver = new CSVSaver(); saver.setInstances(data); saver.setFile(new File("weather.csv")); saver.writeBatch(); }
Example 3
Source File: DataIOFile.java From bestconf with Apache License 2.0 | 5 votes |
/** * Return the data set loaded from the Arff file at @param path */ public static Instances loadDataFromArffFile(String path) throws IOException{ ArffLoader loader = new ArffLoader(); loader.setSource(new File(path)); Instances data = loader.getDataSet(); System.out.println("\nHeader of dataset:\n"); System.out.println(new Instances(data, 0)); return data; }