Java Examples for weka.core.Copyable
The following java examples will help you to understand the usage of weka.core.Copyable. These source code samples are taken from different open source projects.
Example 1
Project: TimeSeriesClassification-master File: Kernel.java View source code |
/** * 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; }