• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ArffReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中weka.core.converters.ArffLoader.ArffReader的典型用法代码示例。如果您正苦于以下问题:Java ArffReader类的具体用法?Java ArffReader怎么用?Java ArffReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArffReader类属于weka.core.converters.ArffLoader包,在下文中一共展示了ArffReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: mapStringToModel

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
@Override
public Dataset mapStringToModel(JsonRequest request) throws ParseException {
  if(!(request instanceof ArffJsonRequest))
  {
    throw new ParseException("Not an instance of "+ArffJsonRequest.class, -1);
  }
  try 
  {
    ArffJsonRequest arff = (ArffJsonRequest) request;
    ArffReader ar = new ArffReader(new StringReader(request.toString()));
    Instances ins = ar.getData();
    ins.setClassIndex(arff.getClassIndex() >= 0 ? arff.getClassIndex() : ins.numAttributes()-1);
    return new Dataset(ins);
  } catch (Exception e) {
    ParseException pe = new ParseException("Cannot convert JSON stream to ARFF", -1);
    pe.initCause(e);
    throw pe;
  }
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:20,代码来源:ARFFDataMapper.java


示例2: loadInstancesFromArffFile

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
public Instances loadInstancesFromArffFile(String filename) throws IOException
{
    LOGGER.trace("Loading data from ARFF file [{}].", filename);

    FileReader fileReader = new FileReader(filename);
    BufferedReader bufferedReader = new BufferedReader(fileReader);
    ArffReader arffReader = new ArffReader(bufferedReader);
    Instances data = arffReader.getData();
    data.setClassIndex(data.numAttributes() - 1);

    bufferedReader.close();
    fileReader.close();

    return data;
}
 
开发者ID:marcelovca90,项目名称:anti-spam-weka-gui,代码行数:16,代码来源:InputOutputHelper.java


示例3: Instances

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads an ARFF file from a reader, and assigns a weight of one to each
 * instance. Lets the index of the class attribute be undefined (negative).
 * 
 * @param reader the reader
 * @throws IOException if the ARFF file is not read successfully
 */
public Instances(/* @[email protected] */Reader reader) throws IOException {
  ArffReader arff = new ArffReader(reader, 1000, false);
  initialize(arff.getData(), 1000);
  arff.setRetainStringValues(true);
  Instance inst;
  while ((inst = arff.readInstance(this)) != null) {
    m_Instances.add(inst);
  }
  compactify();
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:18,代码来源:Instances.java


示例4: getDataSet

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
@Override
public Instances getDataSet() throws IOException {

  if (m_sourceReader == null) {
    throw new IOException("No source has been specified");
  }

  if (getRetrieval() == INCREMENTAL) {
    throw new IOException(
      "Cannot mix getting instances in both incremental and batch modes");
  }
  setRetrieval(BATCH);

  if (m_structure == null) {
    getStructure();
  }

  while (readData(true)) {
    ;
  }

  m_dataDumper.flush();
  m_dataDumper.close();

  // make final structure
  makeStructure();

  Reader sr = new BufferedReader(new FileReader(m_tempFile));
  ArffReader initialArff =
    new ArffReader(sr, m_structure, 0, m_fieldSeparatorAndEnclosures);

  Instances initialInsts = initialArff.getData();
  sr.close();
  initialArff = null;

  return initialInsts;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:38,代码来源:CSVLoader.java


示例5: Instances

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads an ARFF file from a reader, and assigns a weight of one to each
 * instance. Lets the index of the class attribute be undefined (negative).
 * 
 * @param reader the reader
 * @throws IOException if the ARFF file is not read successfully
 */
public Instances(/* @[email protected] */Reader reader) throws IOException {
  ArffReader arff = new ArffReader(reader);
  Instances dataset = arff.getData();
  initialize(dataset, dataset.numInstances());
  dataset.copyInstances(0, this, dataset.numInstances());
  compactify();
}
 
开发者ID:umple,项目名称:umple,代码行数:15,代码来源:Instances.java


示例6: Instances

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads an ARFF file from a reader, and assigns a weight of one to each
 * instance. Lets the index of the class attribute be undefined (negative).
 *
 * @param reader the reader
 * @throws IOException if the ARFF file is not read successfully
 */
public Instances(/* @[email protected] */Reader reader) throws IOException {
    ArffReader arff = new ArffReader(reader);
    Instances dataset = arff.getData();
    initialize(dataset, dataset.numInstances());
    dataset.copyInstances(0, this, dataset.numInstances());
    compactify();
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:15,代码来源:Instances.java


示例7: readData

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
protected Instances readData(String data) throws IOException{
	String trainFileName = "src/main/resources/"+data+".arff";
	BufferedReader reader = new BufferedReader(new FileReader(trainFileName));
	ArffReader arff = new ArffReader(reader);
	Instances instances = arff.getData();
	reader.close();
	return instances;
}
 
开发者ID:amplia,项目名称:weka-classifier-examples,代码行数:9,代码来源:AbstractClassifier.java


示例8: loadDataset

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * This method loads a dataset in ARFF format. If the file does not exist,
 * or it has a wrong format, the attribute trainData is null.
 * 
 * @param fileName
 *            The name of the file that stores the dataset.
 */
public void loadDataset(String fileName) {
	try {
		BufferedReader reader = new BufferedReader(new FileReader(fileName));
		ArffReader arff = new ArffReader(reader);
		trainData = arff.getData();
		System.out.println("===== Loaded dataset: " + fileName + " =====");
		reader.close();
	} catch (IOException e) {
		System.out.println("Problem found when reading: " + fileName);
	}
}
 
开发者ID:amplia,项目名称:weka-classifier-examples,代码行数:19,代码来源:Learner.java


示例9: mergeAndWrite

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
public static void mergeAndWrite(String relationName, String destPath, String... dataSetPaths) throws IOException {
    ArffSaver saver = new ArffSaver();
    saver.setFile(new File(destPath));
    saver.setRetrieval(Saver.INCREMENTAL);
    boolean first = true;

    for (String p : dataSetPaths) {
        ArffReader reader = new ArffReader(new BufferedReader(new FileReader(p)));
        Instances dataSet = reader.getData();

        if (first) {
            dataSet.setRelationName(relationName);
            saver.setStructure(dataSet);


            first = false;
        }
        for (int i = 0; i < dataSet.numInstances(); ++i) {
            saver.writeIncremental(dataSet.instance(i));
        }

    }
    saver.getWriter().flush();
    


}
 
开发者ID:wittawatj,项目名称:ctwt,代码行数:28,代码来源:Actions.java


示例10: makeModelData

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/** Make a lattice over the given variables of the dataset.*/
public static ChordalysisModeller.Data makeModelData(Instances structure, ArffReader loader) throws IOException {
  return makeModelData(structure, loader, true);
}
 
开发者ID:fpetitjean,项目名称:Chordalysis,代码行数:5,代码来源:LoadWekaInstances.java


示例11: loadDataSet

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
public static Instances loadDataSet(File dataSetPath) throws IOException, FileNotFoundException {
    ArffReader reader = new ArffReader(new BufferedReader(new FileReader(dataSetPath)));
    Instances dataSet = reader.getData();
    dataSet.setClassIndex(dataSet.numAttributes() - 1);
    return dataSet;
}
 
开发者ID:wittawatj,项目名称:ctwt,代码行数:7,代码来源:Actions.java


示例12: readInstance

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads a single instance from the reader and appends it to the dataset.
 * Automatically expands the dataset if it is not large enough to hold the
 * instance. This method does not check for carriage return at the end of the
 * line.
 * 
 * @param reader the reader
 * @return false if end of file has been reached
 * @throws IOException if the information is not read successfully
 * @deprecated instead of using this method in conjunction with the
 *             <code>readInstance(Reader)</code> method, one should use the
 *             <code>ArffLoader</code> or <code>DataSource</code> class
 *             instead.
 * @see weka.core.converters.ArffLoader
 * @see weka.core.converters.ConverterUtils.DataSource
 */
@Deprecated
public boolean readInstance(Reader reader) throws IOException {

  ArffReader arff = new ArffReader(reader, this, m_Lines, 1);
  Instance inst = arff.readInstance(arff.getData(), false);
  m_Lines = arff.getLineNo();
  if (inst != null) {
    add(inst);
    return true;
  } else {
    return false;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:30,代码来源:Instances.java


示例13: Instances

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads an ARFF file from a reader, and assigns a weight of
 * one to each instance. Lets the index of the class 
 * attribute be undefined (negative).
 *
 * @param reader the reader
 * @throws IOException if the ARFF file is not read 
 * successfully
 */
public Instances(/*@[email protected]*/Reader reader) throws IOException {
  ArffReader arff = new ArffReader(reader);
  Instances dataset = arff.getData();
  initialize(dataset, dataset.numInstances());
  dataset.copyInstances(0, this, dataset.numInstances());
  compactify();
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:17,代码来源:Instances.java


示例14: readInstance

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads a single instance from the reader and appends it
 * to the dataset.  Automatically expands the dataset if it
 * is not large enough to hold the instance. This method does
 * not check for carriage return at the end of the line.
 *
 * @param reader the reader 
 * @return false if end of file has been reached
 * @throws IOException if the information is not read 
 * successfully
 * @deprecated instead of using this method in conjunction with the
 * <code>readInstance(Reader)</code> method, one should use the 
 * <code>ArffLoader</code> or <code>DataSource</code> class instead.
 * @see weka.core.converters.ArffLoader
 * @see weka.core.converters.ConverterUtils.DataSource
 */ 
@Deprecated public boolean readInstance(Reader reader) throws IOException {

  ArffReader arff = new ArffReader(reader, this, m_Lines, 1);
  Instance inst = arff.readInstance(arff.getData(), false);
  m_Lines = arff.getLineNo();
  if (inst != null) {
    add(inst);
    return true;
  }
  else {
    return false;
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:30,代码来源:Instances.java


示例15: readInstance

import weka.core.converters.ArffLoader.ArffReader; //导入依赖的package包/类
/**
 * Reads a single instance from the reader and appends it to the dataset.
 * Automatically expands the dataset if it is not large enough to hold the
 * instance. This method does not check for carriage return at the end of the
 * line.
 *
 * @param reader the reader
 * @return false if end of file has been reached
 * @throws IOException if the information is not read successfully
 * @see weka.core.converters.ArffLoader
 * @see weka.core.converters.ConverterUtils.DataSource
 * @deprecated instead of using this method in conjunction with the
 * <code>readInstance(Reader)</code> method, one should use the
 * <code>ArffLoader</code> or <code>DataSource</code> class
 * instead.
 */
@Deprecated
public boolean readInstance(Reader reader) throws IOException {

    ArffReader arff = new ArffReader(reader, this, m_Lines, 1);
    Instance inst = arff.readInstance(arff.getData(), false);
    m_Lines = arff.getLineNo();
    if (inst != null) {
        add(inst);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:30,代码来源:Instances.java



注:本文中的weka.core.converters.ArffLoader.ArffReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProtoReader类代码示例发布时间:2022-05-22
下一篇:
Java SuggestResponse类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap