Java Code Examples for weka.core.SerializedObject#getObject()
The following examples show how to use
weka.core.SerializedObject#getObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Kernel.java From tsml with GNU General Public License v3.0 | 6 votes |
/** * Creates a given number of deep or shallow (if the kernel implements Copyable) * copies of the given kernel using serialization. * * @param model the kernel to copy * @param num the number of kernel copies to create. * @return an array of kernels. * @throws Exception if an error occurs */ public static Kernel[] makeCopies(Kernel model, int num) throws Exception { if (model == null) throw new Exception("No model kernel set"); Kernel[] kernels = new Kernel[num]; if (model instanceof Copyable) { for (int i = 0; i < kernels.length; i++) { kernels[i] = (Kernel) ((Copyable) model).copy(); } } else { SerializedObject so = new SerializedObject(model); for (int i = 0; i < kernels.length; i++) kernels[i] = (Kernel) so.getObject(); } return kernels; }
Example 2
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 6 votes |
DelValueAction(int nTargetNode, String sValue) { try { m_nTargetNode = nTargetNode; m_sValue = sValue; m_att = m_Instances.attribute(nTargetNode); SerializedObject so = new SerializedObject(m_Distributions[nTargetNode]); m_CPT = (Estimator[]) so.getObject(); ; m_children = new FastVector(); for (int iNode = 0; iNode < getNrOfNodes(); iNode++) { if (m_ParentSets[iNode].contains(nTargetNode)) { m_children.addElement(iNode); } } m_childAtts = new Estimator[m_children.size()][]; for (int iChild = 0; iChild < m_children.size(); iChild++) { int nChild = (Integer) m_children.elementAt(iChild); m_childAtts[iChild] = m_Distributions[nChild]; } } catch (Exception e) { e.printStackTrace(); } }
Example 3
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
public void undo() { try { SerializedObject so = new SerializedObject(m_CPT); m_Distributions[m_nChild] = (Estimator[]) so.getObject(); ParentSet parentSet = new ParentSet(); for (int iParent = 0; iParent < m_nParents.length; iParent++) { parentSet.addParent(m_nParents[iParent], m_Instances); } m_ParentSets[m_nChild] = parentSet; } catch (Exception e) { e.printStackTrace(); } }
Example 4
Source File: AbstractMultiLabelClassifier.java From meka with GNU General Public License v3.0 | 5 votes |
/** * Creates a given number of deep copies of the given multi-label classifier using serialization. * * @param model the classifier to copy * @param num the number of classifier copies to create. * @return an array of classifiers. * @exception Exception if an error occurs */ public static MultiLabelClassifier[] makeCopies(MultiLabelClassifier model, int num) throws Exception { if (model == null) { throw new Exception("No model classifier set"); } MultiLabelClassifier classifiers[] = new MultiLabelClassifier[num]; SerializedObject so = new SerializedObject(model); for(int i = 0; i < classifiers.length; i++) { classifiers[i] = (MultiLabelClassifier) so.getObject(); } return classifiers; }
Example 5
Source File: Classifier.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** * Creates a given number of deep copies of the given classifier using serialization. * * @param model the classifier to copy * @param num the number of classifier copies to create. * @return an array of classifiers. * @exception Exception if an error occurs */ public static Classifier [] makeCopies(Classifier model, int num) throws Exception { 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; }
Example 6
Source File: Estimator.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates a given number of deep copies of the given estimator using serialization. * * @param model the estimator to copy * @param num the number of estimator copies to create. * @return an array of estimators. * @exception Exception if an error occurs */ public static Estimator [] makeCopies(Estimator model, int num) throws Exception { if (model == null) { throw new Exception("No model estimator set"); } Estimator [] estimators = new Estimator [num]; SerializedObject so = new SerializedObject(model); for(int i = 0; i < estimators.length; i++) { estimators[i] = (Estimator) so.getObject(); } return estimators; }
Example 7
Source File: Filter.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates a given number of deep copies of the given filter using * serialization. * * @param model the filter to copy * @param num the number of filter copies to create. * @return an array of filters. * @throws Exception if an error occurs */ public static Filter[] makeCopies(Filter model, int num) throws Exception { if (model == null) { throw new Exception("No model filter set"); } Filter[] filters = new Filter[num]; SerializedObject so = new SerializedObject(model); for (int i = 0; i < filters.length; i++) { filters[i] = (Filter) so.getObject(); } return filters; }
Example 8
Source File: AbstractClassifier.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates a given number of deep copies of the given classifier using serialization. * * @param model the classifier to copy * @param num the number of classifier copies to create. * @return an array of classifiers. * @exception Exception if an error occurs */ public static Classifier [] makeCopies(Classifier model, int num) throws Exception { 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; }
Example 9
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
public void undo() { try { SerializedObject so = new SerializedObject(m_CPT); m_Distributions[m_nTargetNode] = (Estimator[]) so.getObject(); } catch (Exception e) { e.printStackTrace(); } }
Example 10
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
SetDistributionAction(int nTargetNode, double[][] P) { try { m_nTargetNode = nTargetNode; SerializedObject so = new SerializedObject(m_Distributions[nTargetNode]); m_CPT = (Estimator[]) so.getObject(); ; m_P = P; } catch (Exception e) { e.printStackTrace(); } }
Example 11
Source File: AbstractClusterer.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates copies of the current clusterer. Note that this method * now uses Serialization to perform a deep copy, so the Clusterer * object must be fully Serializable. Any currently built model will * now be copied as well. * * @param model an example clusterer to copy * @param num the number of clusterer copies to create. * @return an array of clusterers. * @exception Exception if an error occurs */ public static Clusterer [] makeCopies(Clusterer model, 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; }
Example 12
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
DeleteArcAction(int nParent, int nChild) { try { m_nChild = nChild; m_nParent = nParent; m_nParents = new int[getNrOfParents(nChild)]; for (int iParent = 0; iParent < m_nParents.length; iParent++) { m_nParents[iParent] = getParent(nChild, iParent); } SerializedObject so = new SerializedObject(m_Distributions[nChild]); m_CPT = (Estimator[]) so.getObject(); } catch (Exception e) { e.printStackTrace(); } }
Example 13
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
public void undo() { try { for (int iChild = 0; iChild < m_children.size(); iChild++) { int nChild = (Integer) m_children.elementAt(iChild); deleteArc(m_nParent, nChild); SerializedObject so = new SerializedObject(m_CPT[iChild]); m_Distributions[nChild] = (Estimator[]) so.getObject(); } } catch (Exception e) { e.printStackTrace(); } }
Example 14
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
AddArcAction(int nParent, FastVector children) { try { m_nParent = nParent; m_children = new FastVector(); m_CPT = new Estimator[children.size()][]; for (int iChild = 0; iChild < children.size(); iChild++) { int nChild = (Integer) children.elementAt(iChild); m_children.addElement(nChild); SerializedObject so = new SerializedObject(m_Distributions[nChild]); m_CPT[iChild] = (Estimator[]) so.getObject(); } } catch (Exception e) { e.printStackTrace(); } }
Example 15
Source File: EditableBayesNet.java From tsml with GNU General Public License v3.0 | 5 votes |
AddArcAction(int nParent, int nChild) { try { m_nParent = nParent; m_children = new FastVector(); m_children.addElement(nChild); //m_nChild = nChild; SerializedObject so = new SerializedObject(m_Distributions[nChild]); m_CPT = new Estimator[1][]; m_CPT[0] = (Estimator[]) so.getObject(); ; } catch (Exception e) { e.printStackTrace(); } }
Example 16
Source File: CheckAttributeSelection.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * returns deep copies of the given object * * @param obj the object to copy * @param num the number of copies * @return the deep copies * @throws Exception if copying fails */ protected Object[] makeCopies(Object obj, int num) throws Exception { if (obj == null) throw new Exception("No object set"); Object[] objs = new Object[num]; SerializedObject so = new SerializedObject(obj); for(int i = 0; i < objs.length; i++) { objs[i] = so.getObject(); } return objs; }
Example 17
Source File: ASSearch.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates copies of the current search scheme. Note that this method * now uses Serialization to perform a deep copy, so the search * object must be fully Serializable. Any currently built model will * now be copied as well. * * @param model an example search scheme to copy * @param num the number of search scheme copies to create. * @return an array of search schemes. * @throws Exception if an error occurs */ public static ASSearch[] makeCopies(ASSearch model, int num) throws Exception { if (model == null) throw new Exception("No model search scheme set"); ASSearch[] result = new ASSearch[num]; SerializedObject so = new SerializedObject(model); for (int i = 0; i < result.length; i++) result[i] = (ASSearch) so.getObject(); return result; }
Example 18
Source File: ASEvaluation.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates copies of the current evaluator. Note that this method * now uses Serialization to perform a deep copy, so the evaluator * object must be fully Serializable. Any currently built model will * now be copied as well. * * @param model an example evaluator to copy * @param num the number of evaluator copies to create. * @return an array of evaluators. * @exception Exception if an error occurs */ public static ASEvaluation [] makeCopies(ASEvaluation model, int num) throws Exception { if (model == null) { throw new Exception("No model evaluator set"); } ASEvaluation [] evaluators = new ASEvaluation [num]; SerializedObject so = new SerializedObject(model); for(int i = 0; i < evaluators.length; i++) { evaluators[i] = (ASEvaluation) so.getObject(); } return evaluators; }
Example 19
Source File: AbstractAssociator.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates copies of the current associator. Note that this method * now uses Serialization to perform a deep copy, so the Associator * object must be fully Serializable. Any currently built model will * now be copied as well. * * @param model an example associator to copy * @param num the number of associators copies to create. * @return an array of associators. * @exception Exception if an error occurs */ public static Associator[] makeCopies(Associator model, int num) throws Exception { if (model == null) { throw new Exception("No model associator set"); } Associator [] associators = new Associator [num]; SerializedObject so = new SerializedObject(model); for(int i = 0; i < associators.length; i++) { associators[i] = (Associator) so.getObject(); } return associators; }
Example 20
Source File: AbstractDensityBasedClusterer.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Creates copies of the current clusterer. Note that this method * now uses Serialization to perform a deep copy, so the Clusterer * object must be fully Serializable. Any currently built model will * now be copied as well. * * @param model an example clusterer to copy * @param num the number of clusterer copies to create. * @return an array of clusterers. * @exception Exception if an error occurs */ public static DensityBasedClusterer [] makeCopies(DensityBasedClusterer model, int num) throws Exception { if (model == null) { throw new Exception("No model clusterer set"); } DensityBasedClusterer [] clusterers = new DensityBasedClusterer [num]; SerializedObject so = new SerializedObject(model); for(int i = 0; i < clusterers.length; i++) { clusterers[i] = (DensityBasedClusterer) so.getObject(); } return clusterers; }