本文整理匯總了Java中weka.classifiers.Classifier.forName方法的典型用法代碼示例。如果您正苦於以下問題:Java Classifier.forName方法的具體用法?Java Classifier.forName怎麽用?Java Classifier.forName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.classifiers.Classifier
的用法示例。
在下文中一共展示了Classifier.forName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: train
import weka.classifiers.Classifier; //導入方法依賴的package包/類
/**
* This function only train the model with the trainSet as it is.
* In other words, no feature removal will done here.
*
* @param trainSet
* @throws Exception
*/
public void train(Instances trainSet) throws Exception {
trainSet.setClassIndex(trainSet.numAttributes() - 1);
// set classifier: use linear SVM only
String[] options = weka.core.Utils.splitOptions("-K 0");
String classifierName = "weka.classifiers.functions.LibSVM";
this.m_Classifier = Classifier.forName(classifierName, options);
// get probability instead of explicit prediction
LibSVM libsvm = (LibSVM) this.m_Classifier;
libsvm.setProbabilityEstimates(true);
// build model
this.m_Classifier.buildClassifier(trainSet);
}
示例2: trainModel
import weka.classifiers.Classifier; //導入方法依賴的package包/類
protected void trainModel(Instances trainData) throws Exception {
// set class attribute
trainData.setClassIndex(trainData.numAttributes() - 1);
// set classifier: use linear SVM only
String[] options = weka.core.Utils.splitOptions("-K 0");
String classifierName = "weka.classifiers.functions.LibSVM";
this.m_Classifier = Classifier.forName(classifierName, options);
// get probability instead of explicit prediction
LibSVM libsvm = (LibSVM) this.m_Classifier;
libsvm.setProbabilityEstimates(true);
// build model
this.m_Classifier.buildClassifier(trainData);
}
示例3: createClassifier
import weka.classifiers.Classifier; //導入方法依賴的package包/類
private Classifier createClassifier() throws Exception {
Classifier baseClassifier = Classifier.forName(getAlgorithm(), getClassifierOptions());
FilteredClassifier result = new FilteredClassifier();
result.setClassifier(baseClassifier);
Remove filter = new Remove();
filter.setAttributeIndicesArray(new int[] { 0 });
result.setFilter(filter);
return result;
}
示例4: regressionBean
import weka.classifiers.Classifier; //導入方法依賴的package包/類
/**
* The core class that implements Weka functions.
* @return
* @throws Exception
*/
@Bean
public RegressionModelEngine regressionBean() throws Exception
{
Classifier c = Classifier.forName(wekaClassifier, null);
if (StringUtils.hasText(options)) {
c.setOptions(Utils.splitOptions(options));
}
return new CachedIncrementalClassifierBean(c, 1000);
}