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


Java Model.load方法代码示例

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


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

示例1: evaluateSvm

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
public double[] evaluateSvm() throws Exception{
       	int right=0;
		Model model = Model.load(modelFile);
        for(int t=0;t<test;t++){
            double prediction = Linear.predict(model, vectest[t]);
            if(prediction==testattr[t]){
            	right++;
            }
          }
        double precision=(double)right/test;
        System.err.println("*************Precision = "+precision*100+"%*************");
        double storeResult[]=new double[3];
        storeResult[0]=right;
        storeResult[1]=test;
        storeResult[2]=precision;
        return storeResult;
}
 
开发者ID:thunlp,项目名称:MMDW,代码行数:18,代码来源:Evaluate_SVM.java

示例2: loadModels

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
/**
 * Load models and feature indexers from file
 * @return 
 */
public boolean loadModels()
{
    try
    {
        loadFeatureIndexers();
        labellerModel = Model.load(labellerModelFile);
        identifierModel = Model.load(identifierModelFile);
    } 
    catch (IOException ex)
    {
        LogInfo.error("Error opening classifier models or feature indexers.");
        return false;
    }
    return true;
}
 
开发者ID:sinantie,项目名称:PLTAG,代码行数:20,代码来源:ArgumentClassifier.java

示例3: train

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
public static void train() throws IOException, InvalidInputDataException{
	String file = "output\\svm/book_svm.svm";
	Problem problem = Problem.readFromFile(new File(file),-1);

	SolverType solver = SolverType.L2R_LR; // -s 0
	double C = 1.0;    // cost of constraints violation
	double eps = 0.01; // stopping criteria

	Parameter parameter = new Parameter(solver, C, eps);
	Model model = Linear.train(problem, parameter);
	File modelFile = new File("output/model");
	model.save(modelFile);
	System.out.println(modelFile.getAbsolutePath());
	// load model or use it directly
	model = Model.load(modelFile);

	Feature[] instance = { new FeatureNode(1, 4), new FeatureNode(2, 2) };
	double prediction = Linear.predict(model, instance);
	System.out.println(prediction);
	int nr_fold = 10;
    double[] target = new double[problem.l];
	Linear.crossValidation(problem, parameter, nr_fold, target);
}
 
开发者ID:laozhaokun,项目名称:sentimentclassify,代码行数:24,代码来源:Main.java

示例4: LibLinearModel

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
public LibLinearModel(String modelFile){
	try {
		model = Model.load(new File(modelFile));
	} catch (IOException e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:9,代码来源:LibLinearModel.java

示例5: initialize

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
@Override
public void initialize(Parameters params) throws ResourceInitializationException {
    super.initialize(params);
    try {
        model = Model.load(((ResourceReader) params.get(Constants.MODEL)).getReader());
    } catch (IOException e) {
        throw new ResourceInitializationException("Failed to load SVM model.", e);
    }

    labelIndeces = new int[labels.size()];
    labelIndeces = model.getLabels();
    representer = (TextRepresenter) params.get(Constants.REPRESENTER);
}
 
开发者ID:groupon,项目名称:nakala,代码行数:14,代码来源:LibLinearTextClassifier.java

示例6: loadModel

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
private void loadModel() {

		logger.info("Loading prediction model");
		
		try {
			if (libLinear) {

				File model_file = new File(modelFile);
				libLinearModel = Model.load(model_file);

			} else if (rankLib) {

				RankerFactory rFact = new RankerFactory();
				rankLibModel = rFact.loadRanker(modelFile);

			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:22,代码来源:Recommender.java

示例7: unpackageClassifier

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
@Override
protected void unpackageClassifier(JarInputStream modelStream) throws IOException {
  super.unpackageClassifier(modelStream);
  JarStreams.getNextJarEntry(modelStream, this.getModelName());
  this.model = Model.load(new InputStreamReader(modelStream));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:7,代码来源:GenericLibLinearClassifierBuilder.java

示例8: classify

import de.bwaldvogel.liblinear.Model; //导入方法依赖的package包/类
public static void classify(String modelfile) throws IOException{
	Model model = Model.load(new File(modelfile));
}
 
开发者ID:laozhaokun,项目名称:sentimentclassify,代码行数:4,代码来源:Main.java


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