/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); baseLTU = (LinearThresholdUnit) Learner.readLearner(in); conjunctiveLabels = in.readBoolean(); int N = in.readInt(); network = new OVector(N); for (int i = 0; i < N; ++i) network.add(Learner.readLearner(in)); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); forget(); read(in, table); }
/** * Reads the binary representation of any type of learner (including the label lexicon, but not * including the feature lexicon), with the option of cutting off the reading process after the * label lexicon and before any learned parameters. When <code>whole</code> is * <code>false</code>, the reading process is cut off in this way. * * <p> * This method is appropriate for reading learners as written by * {@link #write(ExceptionlessOutputStream)}. * * @param in The input stream. * @param whole Whether or not to read the whole model. * @return The learner read from the stream. **/ public static Learner readLearner(ExceptionlessInputStream in, boolean whole) { String name = in.readString(); if (name == null) return null; Learner result = ClassUtils.getLearner(name); result.unclone(); if (whole) result.read(in); // Overridden by decendents else { result.readLabelLexicon(in); // Should not be overridden by decendents Lexicon labelLexicon = result.getLabelLexicon(); result.forget(); result.setLabelLexicon(labelLexicon); } return result; }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); weakLearner = Learner.readLearner(in); rounds = in.readInt(); for (int i = 0; i < rounds; ++i) weakLearners[i] = Learner.readLearner(in); for (int i = 0; i < rounds; ++i) alpha[i] = in.readDouble(); allowableValues = new String[2]; allowableValues[0] = in.readString(); allowableValues[1] = in.readString(); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); forget(); read(in, table); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); defaultPrediction = in.readString(); setDefaultFeature(); baseLearner = Learner.readLearner(in); int N = in.readInt(); network = new OVector(N); int M = in.readInt(); for (int i = 0; i < M; ++i) network.set(in.readInt(), Learner.readLearner(in)); }
/** * Reads only the learned function's model and label lexicon from the specified location in * binary form, overwriting whatever model data may have already existed in this object. This * location is then cached in {@link #lcFilePath}. * * @param url The location from which to read the model. **/ public void readModel(URL url) { ExceptionlessInputStream in = ExceptionlessInputStream.openCompressedStream(url); String s = in.readString(); String expected = getClass().getName(); if (!s.equals(expected)) { System.err.println("Error reading model from '" + url + "':"); System.err.println(" Expected '" + expected + "' but received '" + s + "'"); new Exception().printStackTrace(); in.close(); System.exit(1); } read(in); in.close(); lcFilePath = url; }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); trained = in.readBoolean(); allowableValues = new String[in.readInt()]; for (int i = 0; i < allowableValues.length; ++i) allowableValues[i] = in.readString(); ObjectInputStream ois = null; try { ois = new ObjectInputStream(in); } catch (Exception e) { System.err.println("Can't create object stream for '" + name + "': " + e); System.exit(1); } try { baseClassifier = (weka.classifiers.Classifier) ois.readObject(); freshClassifier = (weka.classifiers.Classifier) ois.readObject(); attributeInfo = (FastVector) ois.readObject(); instances = (Instances) ois.readObject(); } catch (Exception e) { System.err.println("Can't read from object stream for '" + name + "': " + e); System.exit(1); } }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); trained = in.readBoolean(); allowableValues = new String[in.readInt()]; for (int i = 0; i < allowableValues.length; ++i) allowableValues[i] = in.readString(); ObjectInputStream ois = null; try { ois = new ObjectInputStream(in); } catch (Exception e) { System.err.println("Can't create object stream for '" + name + "': " + e); System.exit(1); } try { baseClassifier = (weka.classifiers.Classifier) ois.readObject(); freshClassifier = (weka.classifiers.Classifier) ois.readObject(); attributeInfo = (FastVector) ois.readObject(); wekaInstances = (Instances) ois.readObject(); } catch (Exception e) { System.err.println("Can't read from object stream for '" + name + "': " + e); System.exit(1); } }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); learningRate = in.readDouble(); bias = in.readDouble(); weightVector = SparseWeightVector.readWeightVector(in); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); int N = in.readInt(); network = new OVector(N); for (int i = 0; i < N; ++i) network.add(SparseWeightVector.readWeightVector(in)); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); smoothing = in.readDouble(); int N = in.readInt(); network = new OVector(N); for (int i = 0; i < N; ++i) { NaiveBayesVector nbv = new NaiveBayesVector(); nbv.read(in); network.add(nbv); } }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); int N = in.readInt(); if (N == 0) allowableValues = null; else { allowableValues = new String[N]; for (int i = 0; i < N; ++i) allowableValues[i] = in.readString(); } initialWeight = in.readDouble(); threshold = in.readDouble(); learningRate = in.readDouble(); positiveThickness = in.readDouble(); negativeThickness = in.readDouble(); bias = in.readDouble(); weightVector = SparseWeightVector.readWeightVector(in); }
super.read(in); solverType = in.readString(); C = in.readDouble();