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


Java SerializationHelper.read方法代码示例

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


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

示例1: initialise

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public static void initialise(String browserModelFilePath, String osModelFilePath, String fontsPath) throws Exception{
	browserAttributes = new ArrayList<Attribute>();
	osAttributes = new ArrayList<Attribute>();
	browserClassAttribute = new Attribute("className", browserGroupsWeCareAbout);
	osClassAttribute = new Attribute("className", osGroupsWeCareAbout);
	browserAttributes.add(browserClassAttribute);
	osAttributes.add(osClassAttribute);
	for(int i = 1; i <= 5300; ++i){
		browserAttributes.add(new Attribute(Integer.toString(i)));
		osAttributes.add(new Attribute(Integer.toString(i)));
	}
	
	browserClassifier = (Classifier) SerializationHelper.read(browserModelFilePath);
	osClassifier = (Classifier) SerializationHelper.read(osModelFilePath);
	
	BrowserOsGuessFingerprintNumericRepresentation.initialise(fontsPath);
}
 
开发者ID:qqTYXn7,项目名称:browserprint,代码行数:18,代码来源:Predictor.java

示例2: initModel

import weka.core.SerializationHelper; //导入方法依赖的package包/类
/**
 * loads the serialized model if necessary, throws an Exception if the
 * derserialization fails.
 * 
 * @throws Exception if deserialization fails
 */
protected void initModel() throws Exception {
  if (m_Model == null) {
    m_Model = (Classifier) SerializationHelper.read(m_ModelFile
      .getAbsolutePath());
  }
}
 
开发者ID:umple,项目名称:umple,代码行数:13,代码来源:SerializedClassifier.java

示例3: loadClassificationModel

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public void loadClassificationModel(InputStream modelPath) throws BadConfigException {
    try {
        mClassifier = (Classifier) SerializationHelper.read(modelPath);
    } catch (Exception e) {
        throw new BadConfigException(e.getMessage());
    } finally {
        IOUtils.closeQuietly(modelPath);
    }
}
 
开发者ID:oprisnik,项目名称:semdroid,代码行数:10,代码来源:WekaDataClassifier.java

示例4: initModel

import weka.core.SerializationHelper; //导入方法依赖的package包/类
/**
 * loads the serialized model if necessary, throws an Exception if the
 * derserialization fails. Always propagates the current debug flag.
 * 
 * @throws Exception	if deserialization fails
 */
protected void initModel() throws Exception {
  if (m_Model == null)
    m_Model = (Classifier) SerializationHelper.read(m_ModelFile.getAbsolutePath());
  
  m_Model.setDebug(getDebug());
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:13,代码来源:SerializedClassifier.java

示例5: main

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	
	if (args.length != 2) {
		System.out.println("Usage: WekaSpeechActClassifier <train_set_input_file> <test_set_input_file>");
		System.exit(0);
	}
	
	String arffFileTrain = args[0];
	String arffFileTest = args[1];

	LibSVM wekaClassifier = new LibSVM();
	wekaClassifier.setOptions(new String[] {"-B", "-H"});

	Instances preparedData = (Instances) SerializationHelper.read(arffFileTrain);
	Instances preparedTest = (Instances) SerializationHelper.read(arffFileTest);
	
	System.out.println("Reading train set and test set done!");

	System.out.print("\nTraining...");
	wekaClassifier.buildClassifier(preparedData);
	
	System.out.println("\nTraining...done!");
	
	Evaluation evalTrain = new Evaluation(preparedData);
	evalTrain.evaluateModel(wekaClassifier, preparedData);

	DecimalFormat formatter = new DecimalFormat("#0.0");
	
	System.out.println("\nEvaluating on trainSet...");
	System.out.println(evalTrain.toSummaryString());
	
	System.out.println("\nResult on trainSet...");
	System.out.println("Precision:" + formatter.format(100*evalTrain.precision(0)) + "%" +
			" - Recal: " + formatter.format(100*evalTrain.recall(0)) + "%" +
			" - F1: " + formatter.format(evalTrain.fMeasure(0)) + "%");
	
	Evaluation eval = new Evaluation(preparedTest);
	eval.evaluateModel(wekaClassifier, preparedTest);

	System.out.println("\nEvaluating on testSet...");
	System.out.println(eval.toSummaryString());
	
	System.out.println("\nResult on testSet...");
	System.out.println("Precision:" + formatter.format(100*eval.precision(0)) + "%" +
			" - Recal: " + formatter.format(100*eval.recall(0)) + "%" +
			" - F1: " + formatter.format(100*eval.fMeasure(0)) + "%");

	System.out.println("True positive rate: " + formatter.format(100*eval.truePositiveRate(0)) + "%" + 
			" - True negative rate: "  + formatter.format(100*eval.trueNegativeRate(0)) + "%");
	System.out.println("Accuracy: " + formatter.format(100*((eval.truePositiveRate(0) + eval.trueNegativeRate(0)) / 2)) + "%");
	
	System.out.println("\nDone!");
}
 
开发者ID:ParakweetLabs,项目名称:EmailIntentDataSet,代码行数:54,代码来源:WekaEmailIntentClassifier.java

示例6: initialize

import weka.core.SerializationHelper; //导入方法依赖的package包/类
@Override
public boolean initialize() {
	try {
		cls_act = (Classifier) SerializationHelper.read(Environment.getExternalStorageDirectory().getAbsolutePath()
			+ "/Android/data/tinygsn/" + fileName);
	} catch (Exception e) {
		return false;
	}
	return true;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:11,代码来源:ActivityVirtualSensor.java

示例7: readSC

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public MultilayerPerceptron readSC(String filename1, String filename2, String filename3,String filename4,String filename5) throws Exception
{
	SCA  = (BayesNet) SerializationHelper.read(filename1);
	SCB  = (MultilayerPerceptron) SerializationHelper.read(filename2);
	SCC1 = (MultilayerPerceptron) SerializationHelper.read(filename3);
	SCC2 = (MultilayerPerceptron) SerializationHelper.read(filename4);
	SCC3 = (MultilayerPerceptron) SerializationHelper.read(filename5);
	return SCC1;
}
 
开发者ID:tbluche,项目名称:MERStructure,代码行数:10,代码来源:Classifiers.java

示例8: readClassifier

import weka.core.SerializationHelper; //导入方法依赖的package包/类
/**
 * Reads a serialized Classifier from file that is specified in the fox properties.
 */
public void readClassifier(final String lang) {
  classifier = cache.get(lang);
  if (classifier == null) {
    final String name = getName(lang);
    LOG.info("readClassifier: " + name);
    try {
      classifier = (Classifier) SerializationHelper.read(name.trim());
    } catch (final Exception e) {
      LOG.error(e.getLocalizedMessage(), e);
    }
    LOG.info("readClassifier done.");
    cache.put(lang, classifier);
  }
}
 
开发者ID:dice-group,项目名称:FOX,代码行数:18,代码来源:FoxClassifier.java

示例9: loadModel

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public static Classifier loadModel(String modelName, File folder) throws Exception {
        File modelFile = FileSystemView.getFileSystemView().createFileObject(folder, modelName + ".model");
        Classifier model = (Classifier) SerializationHelper.read(modelFile.getAbsolutePath());
//        System.out.println("A "+model.getClass().getSimpleName() +" model was loaded.");
        return model;

    }
 
开发者ID:wittawatj,项目名称:ctwt,代码行数:8,代码来源:Actions.java

示例10: processCollection

import weka.core.SerializationHelper; //导入方法依赖的package包/类
@Override
public void processCollection() {

	String topic = this.parent.getTargetLocation().substring(this.parent.getTargetLocation().lastIndexOf("/") + 1);

	// get extracted concepts and propositions
	Extractor ex = this.parent.getPrevExtractor(this);
	this.concepts = ex.getConcepts();
	this.propositions = ex.getPropositions();
	for (Concept c : this.concepts)
		this.fixLemmas(c);

	// group by same label
	Map<Concept, ConceptGroup> groups = LemmaGrouper.group(this.concepts);
	List<Concept> repConcepts = new ArrayList<Concept>(groups.keySet());
	this.parent.log(this, "unique concepts: " + groups.size());

	// build all pairs for classifier
	List<CPair> pairs = this.buildPairs(repConcepts);
	this.parent.log(this, "concept pairs: " + pairs.size());

	// compute similarity features
	Instances features = this.computeFeatures(pairs, topic);

	// apply classifier
	ObjectDoubleMap<CPair> predictions = new ObjectDoubleHashMap<CPair>(pairs.size());
	try {
		Classifier clf = (Classifier) SerializationHelper.read(modelName);
		for (int i = 0; i < pairs.size(); i++) {
			CPair pair = pairs.get(i);
			Instance feat = features.instance(i);
			double[] pred = clf.distributionForInstance(feat);
			predictions.put(pair, pred[1]);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

	// clustering
	Set<List<Concept>> clusters = clusterer.createClusters(new HashSet<Concept>(repConcepts), predictions);

	// create final cluster and update relations
	this.updateDataStructures(clusters, groups);
	this.clusters = clusters;

	this.parent.log(this, "grouped concepts: " + concepts.size());
	this.parent.log(this, "relations: " + propositions.size());
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:49,代码来源:ConceptGrouperSimLog.java

示例11: main

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		String modelName = "models/wiki_scoring_noun10conjarg2_sim5log-gopt_SVMRankC10_RepDisc";

		String modelFile = modelName + ".model";
		FilteredClassifier clf = (FilteredClassifier) SerializationHelper.read(modelFile);

		RankingSVM svm = new RankingSVM();
		svm.setWeights(modelName + ".weights");

		clf.setClassifier(svm);
		System.out.println(clf);

		SerializationHelper.write(modelName + ".model_new", clf);

	}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:17,代码来源:ConvertModel.java

示例12: initModel

import weka.core.SerializationHelper; //导入方法依赖的package包/类
private void initModel() throws Exception {

		// Regex model
		regexClassifierHighScore = getRegexs("ini/regex_high_score.txt");
		regexClassifierMediumScore = getRegexs("ini/regex_medium_score.txt");
		regexClassifierLowScore = getRegexs("ini/regex_low_score.txt");

		// Open NLP classifier
		DoccatModel m = new DoccatModel(new File("model/open_comments.model"));
		openNLPClassifier = new DocumentCategorizerME(m);

		// Weka NaiveBayes classifier
		wekaNBClassifier = (Classifier) SerializationHelper.read(new FileInputStream("model/nb_comments.model"));

		// Weka SGD Classifier
		// wekaSGDClassifier = (Classifier) SerializationHelper.read(new
		// FileInputStream("model/sgd_comments.model"));

		// // Weka classifer J48
		//wekaJ48Classifier = (Classifier) SerializationHelper.read(new FileInputStream("model/j48_comments.model"));

		// // Weka SMO comments
		// wekaSMOClassifier = (Classifier) SerializationHelper.read(new
		// FileInputStream("model/smo_comments.model"));

		// This needs to be removed, only used to copy the structure when
		// classifing
		wekaARFF = getInstancesFromARFF("model/comments.arff");
		wekaARFF.setClassIndex(wekaARFF.numAttributes() - 1);

//		ObjectInputStream oin = new ObjectInputStream(new FileInputStream("model/StringToWordVector.filter"));
//		filter = (StringToWordVector) oin.readObject();
//		oin.close();
//		filter.setInputFormat(wekaARFF);
//
//		Instances trainFiltered = Filter.useFilter(wekaARFF, filter);
//		trainFiltered.setClassIndex(0);

		//System.out.println(filter);

	}
 
开发者ID:SOBotics,项目名称:SOCVFinder,代码行数:42,代码来源:CommentHeatCategory.java

示例13: init

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public final void init(String paramsFilename, String modelFilename, int startIndex, FeatureType featureType, Mode mode)
{
    try
    {            
        // load featureExtractor
        if(featureExtractor == null)
            featureExtractor = new ExtractLengthPredictionFeatures(paramsFilename, featureType, startIndex);
        this.numberOfAttributes = featureExtractor.getVectorLength();
        this.featureType = featureType;
        this.modelFilename = modelFilename;
        // load weka model (test mode)
        if(mode == Mode.test)
            model = (Classifier) SerializationHelper.read(modelFilename);
        // create host dataset
        String[] header = featureExtractor.getHeader().split(",");
        ArrayList<Attribute> attrs = new ArrayList<>(header.length);
        for(Feature feature : featureExtractor.getFeatures())
        {
            switch(featureType)
            {
                case values: // treat nominal values (if they exist) differently
                {
                    switch(feature.getType())
                    {
                        case NUM: attrs.add(new Attribute(feature.getName())); break;
                        case CAT: attrs.add(new Attribute(feature.getName(),
                                feature.getValues())); break;
                    }

                } break;
                case counts: case binary: default: attrs.add(new Attribute(feature.getName()));
            } // switch
        } // for
        dataset = new Instances("pred", attrs, 1);
        dataset.setClassIndex(numberOfAttributes);            
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:sinantie,项目名称:Generator,代码行数:42,代码来源:LinearRegressionWekaWrapper.java

示例14: convert

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public void convert() throws Exception {
	
	if( ! new File( getInputModel() ).exists() ) {
		throw new FileNotFoundException( "Input model " + getInputModel() + " does not exist!");
	}
	
	if( ! new File( getScriptPath() ).exists() ) {
		throw new FileNotFoundException( "Python script " + getScriptPath() + " does not exist!");
	}
	
	PyScriptClassifier cls = (PyScriptClassifier) SerializationHelper.read( getInputModel() );
	
	System.err.println( cls.getModelString() + "\nCurrent script path: " +
			cls.getPythonFile().getAbsolutePath() );		
	
	System.err.println("Changing script path to: " + getScriptPath() );
	
	cls.setPythonFile( new File( getScriptPath() ) );
	
	SerializationHelper.write( getOutputModel(), cls);
	
}
 
开发者ID:christopher-beckham,项目名称:weka-pyscript,代码行数:23,代码来源:ChangeScriptPath.java

示例15: readRC

import weka.core.SerializationHelper; //导入方法依赖的package包/类
public CostSensitiveClassifier readRC(String filename) throws Exception
{
	RC = (CostSensitiveClassifier) SerializationHelper.read(filename);
	return RC;
}
 
开发者ID:tbluche,项目名称:MERStructure,代码行数:6,代码来源:Classifiers.java


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