Ignore:
Timestamp:
Feb 29, 2008, 11:14:04 AM (14 years ago)
Author:
Markus Ringnér
Message:

Fixed KNN and SupervisedClassfier? for #75

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/SupervisedClassifier.h

    r1176 r1188  
    4242  class Target;
    4343
    44   ///
    45   /// @brief Interface class for supervised classifiers that use data
    46   /// in a matrix format with data points as columns and each row
    47   /// corresponding to a variable for the data points. Supervised
    48   /// classifiers that do not use data in this format include
    49   /// kernel-based classifiers such as SVM.
    50   ///
     44  /**
     45     \brief Interface class for supervised classifiers that use data
     46     in a matrix format.
     47
     48     The data matrix is organized with data points (samples) as
     49     columns with rows corresponding to variables for the data
     50     points. Supervised classifiers that do not use data in this
     51     format include kernel-based classifiers such as SVM. A supervised
     52     %classifier is trained on training data for which a class of each
     53     data point is known and used in the training. A trained
     54     supervised %classifier can be used to predict the class of test
     55     samples.
     56  */
    5157  class SupervisedClassifier
    5258  {
    5359   
    5460  public:
    55     ///
    56     /// @brief Constructor
    57     ///
     61    /**
     62       \brief Constructor
     63    */
    5864    SupervisedClassifier(void);
    5965   
    6066
    61     ///
    62     /// @brief Destructor
    63     ///
     67    /**
     68       \brief Destructor
     69    */
    6470    virtual ~SupervisedClassifier(void);
    6571
    6672
    67     ///
    68     /// An interface for making new %classifier objects. This function
    69     /// allows for specification at run-time of which %classifier type
    70     /// to instatiate (see 'Prototype' in Design Patterns). Derived
    71     /// classes should implement this function with DerivedClass* as
    72     /// the return type and not SupervisedClassifier*, and a
    73     /// dynamically allocated %classifier should be returned. The
    74     /// implementation of this function should correspond to a copy
    75     /// constructor with the exception that the returned %classifier
    76     /// is not trained.
    77     ///
    78     /// @note Returns a dynamically allocated %classifier, which has
    79     /// to be deleted by the caller to avoid memory leaks.
    80     ///
     73    /**
     74       @brief Create an untrained copy of the %classifier.
     75       
     76       An interface for making new %classifier objects. This function
     77       allows for specification at run-time of which %classifier type
     78       to instatiate (see 'Prototype' in Design Patterns). Derived
     79       classes should implement this function with DerivedClass* as
     80       the return type and not SupervisedClassifier*. A dynamically
     81       allocated DerivedClassifier should be returned. The implementation
     82       of this function should correspond to a copy constructor with
     83       the exception that the returned %classifier is not trained.
     84       
     85       @returns A dynamically allocated %classifier, which has
     86       to be deleted by the caller to avoid memory leaks.
     87    */
    8188    virtual SupervisedClassifier*
    8289    make_classifier() const =0;
    8390   
    8491
    85 
    86     ///
    87     /// Generate output values for a data set
    88     ///
    89     virtual void predict(const MatrixLookup&, utility::Matrix&) const =0;   
    90 
    91     ///
    92     /// Generate output values for a weighted data set
    93     ///
    94     virtual void predict(const MatrixLookupWeighted&, utility::Matrix&) const =0;   
     92    /**
     93       \brief Make predictions for unweighted test data.
     94       
     95       Samples in \a data are predicted and predictions for all
     96       classes are returned in \a result.  The test data \a data
     97       should have one column per test sample and one row for each
     98       variable measured for the test samples. The rows of \a data
     99       should be ordered identical to the rows of the data used to
     100       train the %classifier, so that a given row corresponds to the
     101       same variable for both training and test data. The predictions
     102       in \a result have one column for each sample in \a data,
     103       ordered in the same order, and one row for each class as
     104       defined by the targets used to train the %classifier. Derived
     105       classes should implement this function such that unweighted
     106       calculations are used throughout when both training and test
     107       data are unweighted.
     108    */       
     109    virtual void predict(const MatrixLookup& data, utility::Matrix& result) const =0;   
    95110
    96111
    97     ///
    98     /// Train the %classifier using unweighted training data and
    99     /// targets. The training data \a data should have one column per
    100     /// training sample and one row for each variable measured for the
    101     /// training samples. The size of \a target should be the number
    102     /// of samples in \a data and \a target should contain the class
    103     /// for each sample ordered in the same order as columns in \a data.
    104     ///
     112    /**
     113       \brief Make predictions for weighted test data.
     114       
     115       Both \a data and \a result follow the description for
     116       predict(const MatrixLookup& data, utility::Matrix& result).
     117    */
     118    virtual void predict(const MatrixLookupWeighted& data, utility::Matrix& result) const =0;   
     119
     120
     121    /**
     122       \brief Train the %classifier using unweighted training data with known
     123       targets.
     124   
     125       The training data \a data should have one column per training
     126       sample and one row for each variable measured for the training
     127       samples. The size of \a target should be the number of samples
     128       in \a data and \a target should contain the class for each
     129       sample ordered in the same order as columns in \a data.
     130    */
    105131    virtual void train(const MatrixLookup& data, const Target& targets)=0;
    106 
    107     ///
    108     /// Train the %classifier using weighted training data and
    109     /// targets. Both \a data and \a targets should follow the
    110     /// description for train(const MatrixLookup& data, const Target& targets)
    111     ///
     132   
     133    /**
     134       \brief Train the %classifier using weighted training data with
     135       known targets.
     136       
     137       Both \a data and \a targets should follow the description for
     138       train(const MatrixLookup& data, const Target& targets).
     139    */
    112140    virtual void train(const MatrixLookupWeighted& data, const Target& targets)=0;
    113141
Note: See TracChangeset for help on using the changeset viewer.