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


Java SerializationHelper类代码示例

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


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

示例1: train

import weka.core.SerializationHelper; //导入依赖的package包/类
public void train(String datasetFilename, boolean serialise)
{
    String[] lines = Utils.readLines(datasetFilename);
    int i = 1; // skip legend
    try
    {            
        for(i = 1; i < lines.length; i++) // skip legend
        {
            dataset.add(createFeatureVector(lines[i].split(","), true));
        }
        model = (Classifier) new LinearRegression();
        ((LinearRegression)model).setRidge(1.0e-10);
        model.buildClassifier(dataset);
        if(serialise)
        {                
            SerializationHelper.write(new FileOutputStream(modelFilename), model);
        }
    }
    catch(Exception e)
    {
        System.err.println("Error in line " + i + ": " + lines[i]);
        e.printStackTrace();
    }
}
 
开发者ID:sinantie,项目名称:Generator,代码行数:25,代码来源:LinearRegressionWekaWrapper.java

示例2: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare a
 * UID.
 * 
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];

  print("serialVersionUID...");

  result[0] = !SerializationHelper.needsUID(m_Clusterer.getClass());

  if (result[0]) {
    println("yes");
  } else {
    println("no");
  }

  return result;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:22,代码来源:CheckClusterer.java

示例3: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare a
 * UID.
 * 
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];

  print("serialVersionUID...");

  result[0] = !SerializationHelper.needsUID(m_Associator.getClass());

  if (result[0]) {
    println("yes");
  } else {
    println("no");
  }

  return result;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:22,代码来源:CheckAssociator.java

示例4: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the schemes don't declare a UID
 * (both must!).
 * 
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];
  boolean eval;
  boolean search;

  print("serialVersionUID...");

  eval = !SerializationHelper.needsUID(m_Evaluator.getClass());
  search = !SerializationHelper.needsUID(m_Search.getClass());

  result[0] = eval && search;

  if (result[0]) {
    println("yes");
  } else {
    println("no");
  }

  return result;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:27,代码来源:CheckAttributeSelection.java

示例5: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare a
 * UID.
 * 
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];

  print("serialVersionUID...");

  result[0] = !SerializationHelper.needsUID(m_Classifier.getClass());

  if (result[0]) {
    println("yes");
  } else {
    println("no");
  }

  return result;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:22,代码来源:CheckClassifier.java

示例6: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare a
 * UID.
 * 
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];

  print("serialVersionUID...");

  result[0] = !SerializationHelper.needsUID(m_Kernel.getClass());

  if (result[0]) {
    println("yes");
  } else {
    println("no");
  }

  return result;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:22,代码来源:CheckKernel.java

示例7: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the schemes don't declare
 * a UID (both must!).
 *
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];
  boolean eval;
  boolean search;
  
  print("serialVersionUID...");
  
  eval   = !SerializationHelper.needsUID(m_Evaluator.getClass());
  search = !SerializationHelper.needsUID(m_Search.getClass());
  
  result[0] = eval && search;
  
  if (result[0])
    println("yes");
  else
    println("no");
  
  return result;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:26,代码来源:CheckAttributeSelection.java

示例8: 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

示例9: train

import weka.core.SerializationHelper; //导入依赖的package包/类
@Override
public void train(List<MLExample> pTrainExamples) throws Exception {
	ConfigurationUtil.TrainingMode = true;
	setPaths();

	//This part added since the session was so slow
	List<Integer> train_example_ids = new ArrayList<Integer>();
	for(MLExample example : pTrainExamples)
	{
		train_example_ids.add(example.getExampleId());
	}
	WekaFormatConvertor.writeToFile(train_example_ids, trainFile,taskName, new String[]{"1", "2"});

	DataSource source = new DataSource(trainFile);
	Instances data = source.getDataSet();
	// setting class attribute if the data format does not provide this information
	if (data.classIndex() == -1)
		data.setClassIndex(data.numAttributes() - 1);

	if(options!=null)
		wekaAlgorithm.setOptions(options);     // set the options
	wekaAlgorithm.buildClassifier(data);   // build classifier
	
	 // serialize model
	 SerializationHelper.write(modelFile, wekaAlgorithm);
}
 
开发者ID:ehsane,项目名称:rainbownlp,代码行数:27,代码来源:WekaClassifier.java

示例10: loadModel

import weka.core.SerializationHelper; //导入依赖的package包/类
private void loadModel(Context context) {
	// For complex models serialization overflows the stack, so run in on a different thread with a big stack!
	Log.d(TAG, "Beginning model load...");
	final Resources resources = context.getResources();
	new Thread(null, new Runnable() {

		@Override
		public void run() {
			try {
				setModel((Classifier) SerializationHelper.read(resources.openRawResource(mModelResourceID)));
				Log.d(TAG, "Model load complete!");
			} catch (Exception e) {
				e.printStackTrace();
				throw new RuntimeException("Error de-serializing model!");
			}		
		}
		
	}, "cookeaseModelLoader", 262144L).start();
}
 
开发者ID:thisisdhaas,项目名称:CookEase,代码行数:20,代码来源:KitchenEventDetector.java

示例11: saveModel

import weka.core.SerializationHelper; //导入依赖的package包/类
public void saveModel(Classifier model, String modelpath) {
    try {
        SerializationHelper.write(modelpath, model);
    } catch (Exception ex) {
        Logger.getLogger(ModelGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:sfahadahmed,项目名称:hungrydragon,代码行数:8,代码来源:ModelGenerator.java

示例12: saveModel

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * Save the currently selected experiment output to a file.
 * 
 * @param name 	the name of the buffer to save
 */
protected void saveModel(Object[] data) {
  int retVal = m_ModelFileChooser.showSaveDialog(CollectiveClassifierPanel.this);
  if (retVal != JFileChooser.APPROVE_OPTION)
    return;
  try {
    SerializationHelper.writeAll(m_ModelFileChooser.getSelectedFile().getAbsolutePath(), data);
    m_Log.logMessage("Model saved successfully");
  }
  catch (Exception ex) {
    String msg = "Failed to save model to '" + m_ModelFileChooser.getSelectedFile() + "': " + ex;
    m_Log.logMessage(msg);
    JOptionPane.showMessageDialog(CollectiveClassifierPanel.this, msg);
  }
}
 
开发者ID:fracpete,项目名称:collective-classification-weka-package,代码行数:20,代码来源:CollectiveClassifierPanel.java

示例13: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare
 * a UID.
 *
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];
  
  print("serialVersionUID...");
  
  result[0] = !SerializationHelper.needsUID(m_Clusterer.getClass());
  
  if (result[0])
    println("yes");
  else
    println("no");
  
  return result;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:21,代码来源:CheckClusterer.java

示例14: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare
 * a UID.
 *
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];
  
  print("serialVersionUID...");
  
  result[0] = !SerializationHelper.needsUID(m_Associator.getClass());
  
  if (result[0])
    println("yes");
  else
    println("no");
  
  return result;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:21,代码来源:CheckAssociator.java

示例15: declaresSerialVersionUID

import weka.core.SerializationHelper; //导入依赖的package包/类
/**
 * tests for a serialVersionUID. Fails in case the scheme doesn't declare
 * a UID.
 *
 * @return index 0 is true if the scheme declares a UID
 */
protected boolean[] declaresSerialVersionUID() {
  boolean[] result = new boolean[2];

  print("serialVersionUID...");

  result[0] = !SerializationHelper.needsUID(m_Classifier.getClass());

  if (result[0])
    println("yes");
  else
    println("no");

  return result;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:21,代码来源:CheckClassifier.java


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