本文整理汇总了Java中weka.classifiers.functions.LibSVM.setProbabilityEstimates方法的典型用法代码示例。如果您正苦于以下问题:Java LibSVM.setProbabilityEstimates方法的具体用法?Java LibSVM.setProbabilityEstimates怎么用?Java LibSVM.setProbabilityEstimates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.classifiers.functions.LibSVM
的用法示例。
在下文中一共展示了LibSVM.setProbabilityEstimates方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: predictDataDistribution
import weka.classifiers.functions.LibSVM; //导入方法依赖的package包/类
protected double[][] predictDataDistribution(Instances unlabeled) throws Exception {
// set class attribute
unlabeled.setClassIndex(unlabeled.numAttributes() - 1);
// distribution for instance
double[][] dist = new double[unlabeled.numInstances()][unlabeled.numClasses()];
// label instances
for (int i = 0; i < unlabeled.numInstances(); i++) {
// System.out.println("debug: "+this.getClass().getName()+": classifier: "+m_Classifier.toString());
LibSVM libsvm = (LibSVM) m_Classifier;
libsvm.setProbabilityEstimates(true);
double[] instanceDist = libsvm.distributionForInstance(unlabeled.instance(i));
dist[i] = instanceDist;
}
return dist;
}
示例2: afterPropertiesSet
import weka.classifiers.functions.LibSVM; //导入方法依赖的package包/类
/**
* Loads the training data as configured in {@link #dataConfig} and trains a
* 3-gram SVM classifier.
*/
@Override
public void afterPropertiesSet() throws Exception {
this.trainingData = svmTrainer.train();
StringToWordVector stwvFilter = createFilter(this.trainingData);
// Instances filterdInstances = Filter.useFilter(data, stwv);
LibSVM svm = new LibSVM();
svm.setKernelType(new SelectedTag(0, LibSVM.TAGS_KERNELTYPE));
svm.setSVMType(new SelectedTag(0, LibSVM.TAGS_SVMTYPE));
svm.setProbabilityEstimates(true);
// svm.buildClassifier(filterdInstances);
FilteredClassifier filteredClassifier = new FilteredClassifier();
filteredClassifier.setFilter(stwvFilter);
filteredClassifier.setClassifier(svm);
filteredClassifier.buildClassifier(this.trainingData);
this.classifier = filteredClassifier;
// predict("nice cool amazing awesome beautiful");
// predict("this movie is simply awesome");
// predict("its very bad");
// predict("Not that great");
}
示例3: train
import weka.classifiers.functions.LibSVM; //导入方法依赖的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);
}
示例4: trainModel
import weka.classifiers.functions.LibSVM; //导入方法依赖的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);
}