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


Java LibSVM.setProbabilityEstimates方法代码示例

本文整理汇总了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;
    }
 
开发者ID:NLPReViz,项目名称:emr-nlp-server,代码行数:19,代码来源:CertSVMPredictor.java

示例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");
}
 
开发者ID:venilnoronha,项目名称:movie-rating-prediction,代码行数:28,代码来源:SVMPredictorImpl.java

示例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);
}
 
开发者ID:NLPReViz,项目名称:emr-nlp-server,代码行数:20,代码来源:SVMPredictor.java

示例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);
}
 
开发者ID:NLPReViz,项目名称:emr-nlp-server,代码行数:14,代码来源:CertSVMPredictor.java


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