当前位置: 首页>>代码示例>>Java>>正文


Java Remove.setOptions方法代码示例

本文整理汇总了Java中weka.filters.unsupervised.attribute.Remove.setOptions方法的典型用法代码示例。如果您正苦于以下问题:Java Remove.setOptions方法的具体用法?Java Remove.setOptions怎么用?Java Remove.setOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.filters.unsupervised.attribute.Remove的用法示例。


在下文中一共展示了Remove.setOptions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFilter

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
public Filter createFilter(Instances data) throws Exception {
    Set<Integer> indexes = new HashSet<Integer>();
    for (int i = 0, cnt = this.size(); i < cnt; i++) {
        indexes.add(this.get(i).index());
    } // FOR
    
    SortedSet<Integer> to_remove = new TreeSet<Integer>(); 
    for (int i = 0, cnt = data.numAttributes(); i < cnt; i++) {
        if (indexes.contains(i) == false) {
            to_remove.add(i+1);
        }
    } // FOR
    
    Remove filter = new Remove();
    filter.setInputFormat(data);
    String options[] = { "-R", StringUtil.join(",", to_remove) };
    filter.setOptions(options);
    return (filter);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:MarkovAttributeSet.java

示例2: removeFirstAttribute

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
private Instances removeFirstAttribute(Instances inst) {
	
	String[] options = new String[2];
	// "range"
	options[0] = "-R";
	// first attribute
	options[1] = "1";
	// new instance of filter
	Remove remove = new Remove();
	// set options
	try {
		remove.setOptions(options);
		// inform filter about dataset **AFTER** setting options
		remove.setInputFormat(inst);
		// apply filter
		return Filter.useFilter(inst, remove);
	} catch (Exception e) {
		System.err.println("Can't remove first attribute.");
		return null;
	}
	
}
 
开发者ID:mommi84,项目名称:BALLAD,代码行数:23,代码来源:WekaClassifier.java

示例3: dropClass

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
private Instances dropClass(Instances instances) throws Exception {
	
	if (instances.classIndex() == -1) {
		return instances;
	}
	
	Remove removeFilter = new Remove();
	String[] options = new String[2];
	options[0] = "-R";
	options[1] = Integer.toString(instances.classIndex());
	removeFilter.setOptions(options);
	removeFilter.setInputFormat(instances);
	return Filter.useFilter(instances, removeFilter);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:15,代码来源:IndependentComponents.java

示例4: getReducedDataSet

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
/**
 * Read a dataset from the given file and remove the specified attributes,
 * then return it.
 *
 * @param fileInDataFolder name of file in the project data folder
 * @param ignoreAtts       A string like "5-10, 12" specififying which attributes should be removed. These numbers
 *                         should be 1-indexed (required by Weka API here).
 * @return The altered dataset
 * @throws Exception if there is a problem loading the dataset
 */
public static Instances getReducedDataSet(String fileInDataFolder, String ignoreAtts) throws Exception {

    Instances data = getDataSet(fileInDataFolder);

    Remove remove = new Remove(); // new instance of filter
    remove.setOptions(new String[]{"-R", ignoreAtts});
    remove.setInputFormat(data);

    Instances newData = Filter.useFilter(data, remove); // apply filter
    newData.setClassIndex(newData.numAttributes() - 1);

    return newData;
}
 
开发者ID:garfieldnate,项目名称:Weka_AnalogicalModeling,代码行数:24,代码来源:TestUtils.java

示例5: buildClassifier

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
/**
  * builds the classifier.
  *
  * @param data 	the training data to be used for generating the
  * 			classifier.
  * @throws Exception 	if the classifier could not be built successfully
  */
 public void buildClassifier(Instances data) throws Exception {

   // can classifier handle the data?
   getCapabilities().testWithFail(data);

   // get fresh Instances object
   m_data = new Instances(data);
      
   // only class? -> build ZeroR model
   if (m_data.numAttributes() == 1) {
     System.err.println(
  "Cannot build model (only class attribute present in data!), "
  + "using ZeroR model instead!");
     m_ZeroR = new weka.classifiers.rules.ZeroR();
     m_ZeroR.buildClassifier(m_data);
     return;
   }
   else {
     m_ZeroR = null;
   }
   
   super.buildClassifier(data);

   Integer[] indices = new Integer[data.numAttributes()-1];
   int classIndex = data.classIndex();
   int offset = 0;
   for(int i = 0; i < indices.length+1; i++) {
     if (i != classIndex) {
indices[offset++] = i+1;
     }
   }
   int subSpaceSize = numberOfAttributes(indices.length, getSubSpaceSize());
   Random random = data.getRandomNumberGenerator(m_Seed);
   
   for (int j = 0; j < m_Classifiers.length; j++) {
     if (m_Classifier instanceof Randomizable) {
((Randomizable) m_Classifiers[j]).setSeed(random.nextInt());
     }
     FilteredClassifier fc = new FilteredClassifier();
     fc.setClassifier(m_Classifiers[j]);
     m_Classifiers[j] = fc;
     Remove rm = new Remove();
     rm.setOptions(new String[]{"-V", "-R", randomSubSpace(indices,subSpaceSize,classIndex+1,random)});
     fc.setFilter(rm);

     // build the classifier
     //m_Classifiers[j].buildClassifier(m_data);
   }
   
   buildClassifiers();
   
   // save memory
   m_data = null;
 }
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:62,代码来源:RandomSubSpace.java

示例6: buildClassifier

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
/**
  * builds the classifier.
  *
  * @param data 	the training data to be used for generating the
  * 			classifier.
  * @throws Exception 	if the classifier could not be built successfully
  */
 public void buildClassifier(Instances data) throws Exception {

   // can classifier handle the data?
   getCapabilities().testWithFail(data);

   // remove instances with missing class
   m_data = new Instances(data);
   m_data.deleteWithMissingClass();
   
   // only class? -> build ZeroR model
   if (m_data.numAttributes() == 1) {
     System.err.println(
  "Cannot build model (only class attribute present in data!), "
  + "using ZeroR model instead!");
     m_ZeroR = new weka.classifiers.rules.ZeroR();
     m_ZeroR.buildClassifier(m_data);
     return;
   }
   else {
     m_ZeroR = null;
   }
   
   super.buildClassifier(data);

   Integer[] indices = new Integer[data.numAttributes()-1];
   int classIndex = data.classIndex();
   int offset = 0;
   for(int i = 0; i < indices.length+1; i++) {
     if (i != classIndex) {
indices[offset++] = i+1;
     }
   }
   int subSpaceSize = numberOfAttributes(indices.length, getSubSpaceSize());
   Random random = data.getRandomNumberGenerator(m_Seed);
   
   for (int j = 0; j < m_Classifiers.length; j++) {
     if (m_Classifier instanceof Randomizable) {
((Randomizable) m_Classifiers[j]).setSeed(random.nextInt());
     }
     FilteredClassifier fc = new FilteredClassifier();
     fc.setClassifier(m_Classifiers[j]);
     m_Classifiers[j] = fc;
     Remove rm = new Remove();
     rm.setOptions(new String[]{"-V", "-R", randomSubSpace(indices,subSpaceSize,classIndex+1,random)});
     fc.setFilter(rm);

     // build the classifier
     //m_Classifiers[j].buildClassifier(m_data);
   }
   
   buildClassifiers();
   
   // save memory
   m_data = null;
 }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:63,代码来源:RandomSubSpace.java

示例7: buildClassifier

import weka.filters.unsupervised.attribute.Remove; //导入方法依赖的package包/类
/**
  * builds the classifier.
  *
  * @param data 	the training data to be used for generating the
  * 			classifier.
  * @throws Exception 	if the classifier could not be built successfully
  */
 public void buildClassifier(Instances data) throws Exception {

   // can classifier handle the data?
   getCapabilities().testWithFail(data);

   // remove instances with missing class
   data = new Instances(data);
   data.deleteWithMissingClass();
   
   // only class? -> build ZeroR model
   if (data.numAttributes() == 1) {
     System.err.println(
  "Cannot build model (only class attribute present in data!), "
  + "using ZeroR model instead!");
     m_ZeroR = new weka.classifiers.rules.ZeroR();
     m_ZeroR.buildClassifier(data);
     return;
   }
   else {
     m_ZeroR = null;
   }
   
   super.buildClassifier(data);

   Integer[] indices = new Integer[data.numAttributes()-1];
   int classIndex = data.classIndex();
   int offset = 0;
   for(int i = 0; i < indices.length+1; i++) {
     if (i != classIndex) {
indices[offset++] = i+1;
     }
   }
   int subSpaceSize = numberOfAttributes(indices.length, getSubSpaceSize());
   Random random = data.getRandomNumberGenerator(m_Seed);
   
   for (int j = 0; j < m_Classifiers.length; j++) {
     if (m_Classifier instanceof Randomizable) {
((Randomizable) m_Classifiers[j]).setSeed(random.nextInt());
     }
     FilteredClassifier fc = new FilteredClassifier();
     fc.setClassifier(m_Classifiers[j]);
     m_Classifiers[j] = fc;
     Remove rm = new Remove();
     rm.setOptions(new String[]{"-V", "-R", randomSubSpace(indices,subSpaceSize,classIndex+1,random)});
     fc.setFilter(rm);

     // build the classifier
     m_Classifiers[j].buildClassifier(data);
   }
   
 }
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:59,代码来源:RandomSubSpace.java


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