Package weka.core

Examples of weka.core.SerializedObject


   * @param source the object to copy
   * @return a copy of the source object
   * @exception Exception if the copy fails
   */
  public static Object makeCopy(Object source) throws Exception {
    SerializedObject so = new SerializedObject(source);
    Object result = so.getObject();
    return result;
  }
View Full Code Here


   * @param model the clusterer to copy
   * @return a deep copy of the clusterer
   * @exception Exception if an error occurs
   */
  public static Clusterer makeCopy(Clusterer model) throws Exception {
    return (Clusterer) new SerializedObject(model).getObject();
  }
View Full Code Here

          int num) throws Exception {
     if (model == null) {
      throw new Exception("No model clusterer set");
    }
    Clusterer [] clusterers = new Clusterer [num];
    SerializedObject so = new SerializedObject(model);
    for(int i = 0; i < clusterers.length; i++) {
      clusterers[i] = (Clusterer) so.getObject();
    }
    return clusterers;
  }
View Full Code Here

   * @return a deep copy of the classifier
   * @exception Exception if an error occurs
   */
  public static Classifier makeCopy(Classifier model) throws Exception {

    return (Classifier)new SerializedObject(model).getObject();
  }
View Full Code Here

    if (model == null) {
      throw new Exception("No model classifier set");
    }
    Classifier [] classifiers = new Classifier [num];
    SerializedObject so = new SerializedObject(model);
    for(int i = 0; i < classifiers.length; i++) {
      classifiers[i] = (Classifier) so.getObject();
    }
    return classifiers;
  }
View Full Code Here

      clone.m_trainInstances = new Instances(m_trainInstances); // copy training instances
     
      // deep copy the random object
      if (m_random != null) {
  SerializedObject randomSerial = null;
  try {
    randomSerial = new SerializedObject(m_random);
  } catch (Exception ignored) {} // we know that Random is serializable
  clone.m_random = (Random) randomSerial.getObject();
      }

      clone.m_lastAddedSplitNum = m_lastAddedSplitNum;
      clone.m_numericAttIndices = m_numericAttIndices;
      clone.m_nominalAttIndices = m_nominalAttIndices;
View Full Code Here

        // unbiased predictions
        insts.randomize(random);
        insts.stratify(numFolds);
        for (int i = 0; i < numFolds; i++) {
          Instances train = insts.trainCV(numFolds, i, random);
          SerializedObject so = new SerializedObject(this);
          BinaryMISMO smo = (BinaryMISMO)so.getObject();
          smo.buildClassifier(train, cl1, cl2, false, -1, -1);
          Instances test = insts.testCV(numFolds, i);
          for (int j = 0; j < test.numInstances(); j++) {
            double[] vals = new double[2];
            vals[0] = smo.SVMOutput(-1, test.instance(j));
View Full Code Here

   * The environment variables.
   */
  protected transient Environment m_env;
 
  private weka.core.converters.Saver makeCopy() throws Exception {
    return (weka.core.converters.Saver)new SerializedObject(m_SaverTemplate).getObject();
  }
View Full Code Here

    DeleteNodeAction(int nTargetNode) {
      m_nTargetNode = nTargetNode;
      m_att = m_Instances.attribute(nTargetNode);
      try {
        SerializedObject so = new SerializedObject(m_Distributions[nTargetNode]);
        m_CPT = (Estimator[]) so.getObject();
        ;
        so = new SerializedObject(m_ParentSets[nTargetNode]);
        m_ParentSet = (ParentSet) so.getObject();
      } catch (Exception e) {
        e.printStackTrace();
      }
      m_deleteArcActions = new FastVector();
      for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
View Full Code Here

        // update parentsets
        ParentSet[] parentSets = new ParentSet[nAtts];
        int nX = 0;
        for (int iParentSet = 0; iParentSet < nAtts; iParentSet++) {
          if (iParentSet == m_nTargetNode) {
            SerializedObject so = new SerializedObject(m_ParentSet);
            parentSets[iParentSet] = (ParentSet) so.getObject();
            nX = 1;
          } else {
            parentSets[iParentSet] = m_ParentSets[iParentSet - nX];
            for (int iParent = 0; iParent < parentSets[iParentSet].getNrOfParents(); iParent++) {
              int nParent = parentSets[iParentSet].getParent(iParent);
              if (nParent >= m_nTargetNode) {
                parentSets[iParentSet].SetParent(iParent, nParent + 1);
              }
            }
          }
        }
        m_ParentSets = parentSets;
        // update distributions
        Estimator[][] distributions = new Estimator[nAtts][];
        nX = 0;
        for (int iNode = 0; iNode < nAtts; iNode++) {
          if (iNode == m_nTargetNode) {
            SerializedObject so = new SerializedObject(m_CPT);
            distributions[iNode] = (Estimator[]) so.getObject();
            nX = 1;
          } else {
            distributions[iNode] = m_Distributions[iNode - nX];
          }
        }
View Full Code Here

TOP

Related Classes of weka.core.SerializedObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.