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


Java AbstractClassifier.forName方法代码示例

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


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

示例1: buildClassifier

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
@Override
public void buildClassifier(Instances D) throws Exception {
  	testCapabilities(D);
  	
	int N = D.numInstances();
	int L = D.classIndex();
	h = new Classifier[L];
	u = new Random(m_S);
	D_templates = new Instances[L];

	// Build L probabilistic models, each to predict Y_i | X, Y_{-y}; save the templates.
	for(int j = 0; j < L; j++) {
		// X = [Y[0],...,Y[j-1],Y[j+1],...,Y[L],X]
		D_templates[j] = new Instances(D);
		D_templates[j].setClassIndex(j);
		// train H[j] : X -> Y
		h[j] = AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions());
		h[j].buildClassifier(D_templates[j]);
	}
}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:21,代码来源:CDN.java

示例2: getIterativeClassifier

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
/**
 * Get classifier for string.
 * 
 * @return a classifier
 * @throws exception if a problem occurs
 */
protected IterativeClassifier getIterativeClassifier(String name,
  String[] options) throws Exception {

  Classifier c = AbstractClassifier.forName(name, options);
  if (c instanceof IterativeClassifier) {
    return (IterativeClassifier) c;
  } else {
    throw new IllegalArgumentException(name
      + " is not an IterativeClassifier.");
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:18,代码来源:IterativeClassifierOptimizer.java

示例3: main

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
/**
 * Main method for testing this class
 * 
 * @param args a <code>String[]</code> value
 */
public static void main(String[] args) {
  weka.core.logging.Logger.log(weka.core.logging.Logger.Level.INFO,
    "Logging started");
  try {
    if (args.length < 2) {
      createNewVisualizerWindow(null, null);
    } else {
      String[] argsR = null;
      if (args.length > 2) {
        argsR = new String[args.length - 2];
        for (int j = 2; j < args.length; j++) {
          argsR[j - 2] = args[j];
        }
      }
      Classifier c = AbstractClassifier.forName(args[1], argsR);

      System.err.println("Loading instances from : " + args[0]);
      java.io.Reader r = new java.io.BufferedReader(new java.io.FileReader(
        args[0]));
      Instances i = new Instances(r);

      createNewVisualizerWindow(c, i);
    }

  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:34,代码来源:BoundaryVisualizer.java

示例4: evaluateModel

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
/**
 * Evaluates a classifier with the options given in an array of strings.
 * 
 * @param classifierString class of machine learning classifier as a string
 * @param options the array of string containing the options
 * @throws Exception if model could not be evaluated successfully
 * @return a string describing the results
 */
public static String evaluateModel(String classifierString, String[] options) throws Exception {
  Classifier classifier;

  try {
    classifier = AbstractClassifier.forName(classifierString, null);
  } 
  catch (Exception e) {
    throw new Exception("Can't find class with name " + classifierString + '.');
  }

  return evaluateModel(classifier, options);
}
 
开发者ID:fracpete,项目名称:collective-classification-weka-package,代码行数:21,代码来源:Evaluation.java

示例5: main

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
/**
  * Main method for testing this class
  *
  * @param args a <code>String[]</code> value
  */
 public static void main(String [] args) {
   weka.core.logging.Logger.log(weka.core.logging.Logger.Level.INFO, "Logging started");
   try {
   	if (args.length < 2) {
	createNewVisualizerWindow(null, null);
}
else {
	String [] argsR = null;
	if (args.length > 2) {
		argsR = new String [args.length-2];
		for (int j = 2; j < args.length; j++) {
		argsR[j-2] = args[j];
		}
	}
	Classifier c = AbstractClassifier.forName(args[1], argsR);
	
	System.err.println("Loading instances from : "+args[0]);
	java.io.Reader r = new java.io.BufferedReader(
				new java.io.FileReader(args[0]));
	Instances i = new Instances(r);

	createNewVisualizerWindow(c, i);
}
     
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:34,代码来源:BoundaryVisualizer.java

示例6: Link

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
public Link(int chain[], int j, Instances train) throws Exception {
	this.j = j;

	this.index = chain[j];

	// sort out excludes [4|5,1,0,2,3]
	this.excld = Arrays.copyOfRange(chain,j+1,chain.length); 
	// sort out excludes [0,1,2,3,5]
	Arrays.sort(this.excld); 

	this.classifier = (AbstractClassifier)AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions());

	Instances new_train = new Instances(train);

	// delete all except one (leaving a binary problem)
	if(getDebug()) System.out.print(" "+this.index);
	new_train.setClassIndex(-1); 
	// delete all the attributes (and track where our index ends up)
	int c_index = chain[j]; 
	for(int i = excld.length-1; i >= 0; i--) {
		new_train.deleteAttributeAt(excld[i]);
		if (excld[i] < this.index)
			c_index--; 
	}
	new_train.setClassIndex(c_index); 

	_template = new Instances(new_train,0);

	this.classifier.buildClassifier(new_train);
	new_train = null;

	if(j+1 < chain.length) 
		next = new meka.classifiers.multitarget.CCp.Link(chain, ++j, train);
}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:35,代码来源:CCp.java

示例7: buildClassifier

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
@Override
public void buildClassifier(Instances data) throws Exception {
  	testCapabilities(data);
  	
	int c = data.classIndex();

	// Base BR

	if (getDebug()) System.out.println("Build BR Base ("+c+" models)");
	m_BASE = (BR)AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions());
	m_BASE.buildClassifier(data);

	// Meta BR

	if (getDebug()) System.out.println("Prepare Meta data           ");
	Instances meta_data = new Instances(data);

	FastVector BinaryClass = new FastVector(c);
	BinaryClass.addElement("0");
	BinaryClass.addElement("1");

	for(int i = 0; i < c; i++) {
		meta_data.insertAttributeAt(new Attribute("metaclass"+i,BinaryClass),c);
	}

	for(int i = 0; i < data.numInstances(); i++) {
		double cfn[] = m_BASE.distributionForInstance(data.instance(i));
		for(int a = 0; a < cfn.length; a++) {
			meta_data.instance(i).setValue(a+c,cfn[a]);
		}
	}

	meta_data.setClassIndex(c);
	m_InstancesTemplate = new Instances(meta_data, 0);

	if (getDebug()) System.out.println("Build BR Meta ("+c+" models)");

	m_META = (BR)AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions());
	m_META.buildClassifier(meta_data);
}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:41,代码来源:MBR.java

示例8: ULink

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
public ULink(int chain[], int j, Instances train) throws Exception {
	this.j = j;

	this.index = chain[j];

	// sort out excludes [4|5,1,0,2,3]
	this.excld = Arrays.copyOfRange(chain,j+1,chain.length); 
	// sort out excludes [0,1,2,3,5]
	Arrays.sort(this.excld); 

	this.classifier = (AbstractClassifier)AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions());

	Instances new_train = new Instances(train);

	// delete all except one (leaving a binary problem)
	if(getDebug()) System.out.print(" "+this.index);
	new_train.setClassIndex(-1); 
	// delete all the attributes (and track where our index ends up)
	this.value = chain[j];
	int c_index = value; 
	for(int i = excld.length-1; i >= 0; i--) {
		new_train.deleteAttributeAt(excld[i]);
		if (excld[i] < this.index)
			c_index--; 
	}
	new_train.setClassIndex(c_index); 

	_template = new Instances(new_train,0);

	this.classifier.buildClassifier(new_train);
	new_train = null;

	if(j+1 < chain.length) 
		next = new ULink(chain, ++j, train);
}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:36,代码来源:CCUpdateable.java

示例9: configure

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
/**
 * @param classifierName A class name of a weka classifier. Example:
 *  "weka.classifiers.rules.ZeroR"
 * @param options Options for the classifier. This can be null. Any options which equal "$RANDOM"
 * will be replaced with a random integer.
 * @param normalizeOutputWeights If true, then the weights assigned
 * to each output in innerGetOutputWeights will be normalized to sum to 1.
 */
private void configure(String classifierName, String[] options, boolean normalizePredictedWeights)
{
	// Copy options so we don't mutate it.
	options = Arrays.copyOf(options, options.length);
	this.normalizePredictedWeights = normalizePredictedWeights;
	
	for (int i : new Range(options.length))
	{
		// Replace occurrences of "$RANDOM" with a random integer.
		if (options[i].equals("$RANDOM"))
		{
			options[i] = String.valueOf(rand.nextInt());
		}
		// Remove double and single qoates from the beginning and end of the option.
		if (options[i].startsWith("'") && options[i].endsWith("'") 
				|| options[i].startsWith("\"") && options[i].endsWith("\""))
		{
			options[i] = options[i].substring(1, options[i].length() - 1);
		}
	}
	try
	{
		classifier = AbstractClassifier.forName(classifierName, options);
	} catch (Exception e)
	{
		throw new RuntimeException(e);
	}
}
 
开发者ID:jeheydorn,项目名称:smodelkit,代码行数:37,代码来源:WekaWrapper.java

示例10: setClassifier

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
@Override
public void setClassifier(String classifier, String[] classifierOptions) {
    try {
        this.classifier = AbstractClassifier.forName(classifier, classifierOptions);
    } catch (Exception e) {
        e.printStackTrace();
    }
    ;
}
 
开发者ID:kokojumbo,项目名称:master-thesis,代码行数:10,代码来源:DBScanImbalancedAlgorithm.java

示例11: QLink

import weka.classifiers.AbstractClassifier; //导入方法依赖的package包/类
public QLink(int chain[], int j, Instances train) throws Exception {
	this.j = j;

	this.index = chain[j];

	// sort out excludes [4|5,1,0,2,3]
	this.excld = Arrays.copyOfRange(chain,j+1,chain.length); 
	// sort out excludes [0,1,2,3,5]
	Arrays.sort(this.excld); 

	this.classifier = AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions());

	Instances new_train = new Instances(train);

	// delete all except one (leaving a binary problem)
	if(getDebug()) System.out.print(" "+this.index);
	new_train.setClassIndex(-1); 
	// delete all the attributes (and track where our index ends up)
	int c_index = chain[j]; 
	for(int i = excld.length-1; i >= 0; i--) {
		new_train.deleteAttributeAt(excld[i]);
		if (excld[i] < this.index)
			c_index--; 
	}
	new_train.setClassIndex(c_index); 

	/* BEGIN downsample for this link */
	new_train.randomize(m_Random);
	int numToRemove = new_train.numInstances() - (int)Math.round(new_train.numInstances() * m_DownSampleRatio);
	for(int i = 0, removed = 0; i < new_train.numInstances(); i++) {
		if (new_train.instance(i).classValue() <= 0.0) {
			new_train.instance(i).setClassMissing();
			if (++removed >= numToRemove)
				break;
		}
	}
	new_train.deleteWithMissingClass();
	/* END downsample for this link */

	_template = new Instances(new_train,0);

	this.classifier.buildClassifier(new_train);
	new_train = null;

	if(j+1 < chain.length) 
		next = new QLink(chain, ++j, train);
}
 
开发者ID:IsaacHaze,项目名称:meka,代码行数:48,代码来源:CCq.java


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