/** * Main method for testing. * @param args - Arguments passed from the command line **/ public static void main(String[] args) throws Exception{ AbstractMultiLabelClassifier.evaluation(new Maniac(), args); } }
/** * Gives the tiptext for compression. * @return the tiptext for compression. */ public String compressionTipText(){ return compressionToolTip(); }
/** * Sets the options to the given values in the array. * * @param options The options to be set. */ public void setOptions(String[] options) throws Exception { setCompression(OptionUtils.parse(options, "compression", getDefaultCompression())); setNumberAutoencoders(OptionUtils.parse(options, "numberAutoencoders", getDefaultNumberAutoencoders())); setOptimizeAE(OptionUtils.parse(options, "optimizeAE", getDefaultOptimizeAE())); super.setOptions(options); }
if (this.isOptimizeAE()) { Instances train = D.trainCV(3,1); Instances test = D.testCV(3,1); Instances labels = this.extractPart(train, true); this.getNumberAutoencoders(), // number of autoencoders = (max hidden layers + 1) / this.getCompression(), // compression from k-th layer to (k+1)-th layer Maniac candidate = new Maniac(); candidate.setOptimizeAE(false); candidate.setNumberAutoencoders(this.getNumberAutoencoders()); candidate.setCompression(this.getCompression()); candidate.setClassifier(this.getClassifier()); candidate.setAE(a); Instances features = this.extractPart(D, false); Instances labels = this.extractPart(D, true); if (this.getAE() == null) { Iterable<Autoencoder> autoencoders = autoencoderStatics .deepAutoencoderStream_java( this.getNumberAutoencoders(), // number of autoencoders = (max hidden layers + 1) / this.getCompression(), // compression from k-th layer to (k+1)-th layer itercount++;
/** * Returns an enumeration of the options. * * @return Enumeration of the options. */ public Enumeration listOptions() { Vector newVector = new Vector(); OptionUtils.addOption(newVector, compressionTipText(), ""+getDefaultCompression(), "compression"); OptionUtils.addOption(newVector, numberAutoencodersTipText(), ""+getDefaultNumberAutoencoders(), "numberAutoencoders"); OptionUtils.addOption(newVector, optimizeAETipText(), ""+getDefaultOptimizeAE(), "optimizeAE"); OptionUtils.add(newVector, super.listOptions()); return OptionUtils.toEnumeration(newVector); }
/** * Returns an array with the options of the classifier. * * @return Array of options. */ public String[] getOptions(){ List<String> result = new ArrayList<>(); OptionUtils.add(result, "compression", getCompression()); OptionUtils.add(result, "optimizeAE", isOptimizeAE()); OptionUtils.add(result, "numberAutoencoders", getNumberAutoencoders()); OptionUtils.add(result, super.getOptions()); return OptionUtils.toArray(result); }
@Override public double[] transformPredictionsBack(double[] y){ Mat matrix = new Mat(1, y.length/2); for (int i = 0; i < y.length/2; i++) { matrix.update(0, i, y[y.length/2 + i]); } Mat reconstruction = this.getAE().decompress(matrix); double[] result = new double[reconstruction.toArray()[0].length]; for(int i = 0; i < result.length; i++){ result[i] = reconstruction.apply(0,i); } return result; }
@Override public Instance transformInstance(Instance x) throws Exception{ Instances tmpInst = new Instances(x.dataset()); tmpInst.delete(); tmpInst.add(x); Instances features = this.extractPart(tmpInst, false); Instances pseudoLabels = new Instances(this.compressedTemplateInst); Instance tmpin = pseudoLabels.instance(0); pseudoLabels.delete(); pseudoLabels.add(tmpin); for ( int i = 0; i< pseudoLabels.classIndex(); i++) { pseudoLabels.instance(0).setMissing(i); } Instances newDataSet = Instances.mergeInstances(pseudoLabels, features); newDataSet.setClassIndex(pseudoLabels.numAttributes()); return newDataSet.instance(0); }
if (this.isOptimizeAE()) { Instances train = D.trainCV(3,1); Instances test = D.testCV(3,1); Instances labels = this.extractPart(train, true); this.getNumberAutoencoders(), // number of autoencoders = (max hidden layers + 1) / this.getCompression(), // compression from k-th layer to (k+1)-th layer Maniac candidate = new Maniac(); candidate.setOptimizeAE(false); candidate.setNumberAutoencoders(this.getNumberAutoencoders()); candidate.setCompression(this.getCompression()); candidate.setClassifier(this.getClassifier()); candidate.setAE(a); Instances features = this.extractPart(D, false); Instances labels = this.extractPart(D, true); if (this.getAE() == null) { Iterable<Autoencoder> autoencoders = autoencoderStatics .deepAutoencoderStream_java( this.getNumberAutoencoders(), // number of autoencoders = (max hidden layers + 1) / this.getCompression(), // compression from k-th layer to (k+1)-th layer itercount++;
/** * Returns an enumeration of the options. * * @return Enumeration of the options. */ public Enumeration listOptions() { Vector newVector = new Vector(); OptionUtils.addOption(newVector, compressionTipText(), ""+getDefaultCompression(), "compression"); OptionUtils.addOption(newVector, numberAutoencodersTipText(), ""+getDefaultNumberAutoencoders(), "numberAutoencoders"); OptionUtils.addOption(newVector, optimizeAETipText(), ""+getDefaultOptimizeAE(), "optimizeAE"); OptionUtils.add(newVector, super.listOptions()); return OptionUtils.toEnumeration(newVector); }
/** * Returns an array with the options of the classifier. * * @return Array of options. */ public String[] getOptions(){ List<String> result = new ArrayList<>(); OptionUtils.add(result, "compression", getCompression()); OptionUtils.add(result, "optimizeAE", isOptimizeAE()); OptionUtils.add(result, "numberAutoencoders", getNumberAutoencoders()); OptionUtils.add(result, super.getOptions()); return OptionUtils.toArray(result); }
@Override public double[] transformPredictionsBack(double[] y){ Mat matrix = new Mat(1, y.length/2); for (int i = 0; i < y.length/2; i++) { matrix.update(0, i, y[y.length/2 + i]); } Mat reconstruction = this.getAE().decompress(matrix); double[] result = new double[reconstruction.toArray()[0].length]; for(int i = 0; i < result.length; i++){ result[i] = reconstruction.apply(0,i); } return result; }
@Override public Instance transformInstance(Instance x) throws Exception{ Instances tmpInst = new Instances(x.dataset()); tmpInst.delete(); tmpInst.add(x); Instances features = this.extractPart(tmpInst, false); Instances pseudoLabels = new Instances(this.compressedTemplateInst); Instance tmpin = pseudoLabels.instance(0); pseudoLabels.delete(); pseudoLabels.add(tmpin); for ( int i = 0; i< pseudoLabels.classIndex(); i++) { pseudoLabels.instance(0).setMissing(i); } Instances newDataSet = Instances.mergeInstances(pseudoLabels, features); newDataSet.setClassIndex(pseudoLabels.numAttributes()); return newDataSet.instance(0); }
/** * Sets the options to the given values in the array. * * @param options The options to be set. */ public void setOptions(String[] options) throws Exception { setCompression(OptionUtils.parse(options, "compression", getDefaultCompression())); setNumberAutoencoders(OptionUtils.parse(options, "numberAutoencoders", getDefaultNumberAutoencoders())); setOptimizeAE(OptionUtils.parse(options, "optimizeAE", getDefaultOptimizeAE())); super.setOptions(options); }
/** * Gives the tiptext for compression. * @return the tiptext for compression. */ public String compressionTipText(){ return compressionToolTip(); }
/** * Main method for testing. * @param args - Arguments passed from the command line **/ public static void main(String[] args) throws Exception{ AbstractMultiLabelClassifier.evaluation(new Maniac(), args); } }