weka.core.converters.ArffLoader Java Examples
The following examples show how to use
weka.core.converters.ArffLoader.
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: RelExTool.java From Criteria2Query with Apache License 2.0 | 5 votes |
public void trainClassifier(String trainfile,String modelpath) throws Exception{ Classifier m_classifier = new RandomForest(); File inputFile = new File(trainfile); ArffLoader atf = new ArffLoader(); atf.setFile(inputFile); Instances instancesTrain = atf.getDataSet(); instancesTrain.setClassIndex(6); m_classifier.buildClassifier(instancesTrain); saveModel(m_classifier, modelpath); }
Example #4
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; }