[marf-cvs] marf/src/marf/Classification Classification.java, 1.43, 1.44 IClassification.java, 1.5,
Brought to you by:
mokhov
From: Serguei A. M. <mo...@us...> - 2006-07-31 02:19:23
|
Update of /cvsroot/marf/marf/src/marf/Classification In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23576/marf/Classification Modified Files: Classification.java IClassification.java Log Message: Add new Classification API of train(double[]) and classify(double[]) that accept feature vectors directly withough going through the entire pipeline. These make it the Classification modules more flexible and easier to test in the distributed environment. The train() method was made generic and relies on FeatureExtraction to provide such a vector as before; thus, making train() more pipeline-oriented. Clean up some dead code away. Update some minor comments. Index: IClassification.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/Classification/IClassification.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IClassification.java 28 Jul 2006 17:13:02 -0000 1.5 --- IClassification.java 31 Jul 2006 02:19:13 -0000 1.6 *************** *** 26,29 **** --- 26,31 ---- /** * Generic classification routine. + * Assumes presence of a valid, non-null IFeatureExtraction module. + * * @return <code>true</code> if classification was successful; <code>false</code> otherwise * @throws ClassificationException if there was an error while classifying *************** *** 35,38 **** --- 37,41 ---- * Generic training routine for building/updating * mean vectors in the training set. + * Assumes presence of a valid, non-null IFeatureExtraction module. * * @return <code>true</code> if training was successful; <code>false</code> otherwise *************** *** 43,46 **** --- 46,72 ---- /** + * Generic classification routine. + * + * @param padFeatureVector vector of features to compare with the stored ones + * @return <code>true</code> if classification was successful; <code>false</code> otherwise + * @throws ClassificationException if there was an error while classifying + * @since 0.3.0.6 + */ + boolean classify(double[] padFeatureVector) + throws ClassificationException; + + /** + * Generic training routine for building/updating + * mean vectors in the training set. + * + * @param padFeatureVector vector of features to train on + * @return <code>true</code> if training was successful; <code>false</code> otherwise + * @throws ClassificationException if there was a problem while training + * @since 0.3.0.6 + */ + boolean train(double[] padFeatureVector) + throws ClassificationException; + + /** * Retrieves the likely classification result. * If there were many, this will return the result with the Index: Classification.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/Classification/Classification.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Classification.java 28 Jul 2006 17:13:01 -0000 1.43 --- Classification.java 31 Jul 2006 02:19:12 -0000 1.44 *************** *** 41,55 **** /** - * Sets the default dump mode for the training set instance. - * Allows decoupling of the dump modes for the classification - * module in general and its training sets. For example, - * NeuralNetwork's default dump mode is XML, whereas it uses - * the GZIP_BINARY training sets. - * @since 0.3.0.6 - * @see #DUMP_GZIP_BINARY - */ - //protected int iTrainingSetDumpMode = DUMP_GZIP_BINARY; - - /** * Classification result set. May contain * one or more results (in case of similarity). --- 41,44 ---- *************** *** 90,95 **** } } - - // this.iCurrentDumpMode = } --- 79,82 ---- *************** *** 98,102 **** /** * Generic training routine for building/updating ! * mean vectors in the training set. * Can be overridden, and if the overriding classifier is using * <code>TrainingSet</code>, it should call <code>super.train();</code> --- 85,90 ---- /** * Generic training routine for building/updating ! * mean vectors in the training set. Assumes presence ! * of a non-null feature extraction module for pipelining. * Can be overridden, and if the overriding classifier is using * <code>TrainingSet</code>, it should call <code>super.train();</code> *************** *** 110,113 **** --- 98,120 ---- throws ClassificationException { + return train(this.oFeatureExtraction.getFeaturesArray()); + } + + /** + * Generic training routine for building/updating + * mean vectors in the training set. + * Can be overridden, and if the overriding classifier is using + * <code>TrainingSet</code>, it should call <code>super.train();</code> + * + * @param padFeatureFector feature vector to train on + * @return <code>true</code> if training was successful + * (i.e. mean vector was updated); <code>false</code> otherwise + * @throws ClassificationException if there was a problem while training + * @see TrainingSet + * @since 0.3.0.6 + */ + public boolean train(double[] padFeatureFector) + throws ClassificationException + { // For exception handling String strPhase = "[start]"; *************** *** 145,149 **** boolean bVectorAdded = this.oTrainingSet.addFeatureVector ( ! this.oFeatureExtraction.getFeaturesArray(), MARF.getSampleFile(), MARF.getCurrentSubject(), --- 152,157 ---- boolean bVectorAdded = this.oTrainingSet.addFeatureVector ( ! //this.oFeatureExtraction.getFeaturesArray(), ! padFeatureFector, MARF.getSampleFile(), MARF.getCurrentSubject(), *************** *** 182,185 **** --- 190,205 ---- } + /** + * Generic classification routine that assumes a presence of + * a valid non-null feature extraction module for pipeline operation. + * @see marf.Classification.IClassification#classify() + * @since 0.3.0.6 + */ + public boolean classify() + throws ClassificationException + { + return classify(this.oFeatureExtraction.getFeaturesArray()); + } + /* From Storage Manager */ *************** *** 225,250 **** /** - * Generic implementation of dumpGzipBinary() to dump the TrainingSet. - * @since 0.3.0.6 - * @throws StorageException if there's a problem saving training set to disk - */ - /* public void dumpGzipBinary() - throws StorageException - { - saveTrainingSet(); - } - - /** - * Generic implementation of restore() for TrainingSet. - * @since 0.3.0.6 - * @throws StorageException if there is a problem loading the training set from disk - */ - /* public void restoreGzipBinary() - throws StorageException - { - loadTrainingSet(); - }*/ - - /** * Saves TrainingSet to a file. Called by <code>dump()</code>. * @since 0.2.0 --- 245,248 ---- |