Changeset 767


Ignore:
Timestamp:
Feb 22, 2007, 4:14:40 PM (15 years ago)
Author:
Peter
Message:

Fixes #65

Location:
trunk/yat
Files:
51 edited

Legend:

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

    r680 r767  
    3434
    3535  ///
    36   /// Class splitting a set into training set and validation set in a
     36  /// @brief Class splitting a set into training set and validation
     37  /// set in a
    3738  /// crossvalidation manner. This is done in a balanced way, meaning
    3839  /// the proportions between the classes in the trainingset is close
  • trunk/yat/classifier/DataLookup1D.h

    r757 r767  
    2626
    2727#include <iostream>
     28#include <vector>
    2829
    2930namespace theplu {
    3031namespace yat {
     32namespace utility {
     33  class vector;
     34}
    3135namespace classifier { 
    3236
     
    3438
    3539  ///
    36   /// Class for general vector view
     40  /// @brief Class for general vector view.
    3741  ///
    3842
     
    6367    DataLookup1D(const size_t size, const double value=0);
    6468
     69    /**
     70       @brief Create general view from utility::vector
     71   
     72       Constructor creates a proper MatrixLookup that object can view
     73       into. Object is owner of this underlying MatrixLookup. Object fulfills
     74       \f$ x(i) = vec(index(i)) \f$
     75    */
     76    DataLookup1D(const utility::vector& vec, const std::vector<size_t>& index);
     77
    6578    ///
    66     ///
     79    /// @brief Destructor deletes underlying DataLookup2D if object is owner
    6780    ///
    6881    virtual ~DataLookup1D();
  • trunk/yat/classifier/DataLookupWeighted1D.h

    r747 r767  
    3535
    3636  ///
    37   /// Class for general weighted vector view.
     37  /// @brief Class for general weighted vector view.
    3838  ///
    3939  /// @see MatrixLookupWeighted
  • trunk/yat/classifier/EnsembleBuilder.h

    r736 r767  
    4040
    4141  ///
    42   /// Class for ensembles of supervised classifiers
     42  /// @brief Class for ensembles of supervised classifiers
    4343  ///
    4444
  • trunk/yat/classifier/GaussianKernelFunction.h

    r747 r767  
    3636
    3737  ///
    38   /// Class for Gaussian kernel calculations.
     38  /// @brief Class for Gaussian kernel calculations.
    3939  ///
    4040 
  • trunk/yat/classifier/IRRank.h

    r680 r767  
    3333
    3434  ///
    35   /// Functor retrieving minus rank from a InputRanker to
    36   /// build a ConsensusInputRanker.
     35  /// @brief Functor retrieving minus rank from a InputRanker to build
     36  /// a ConsensusInputRanker.
    3737  ///   
    3838  class IRRank : public IRRetrieve
  • trunk/yat/classifier/IRRetrieve.h

    r680 r767  
    3232
    3333  ///
    34   /// Abstract class for retrieving information from a InputRanker to
     34  /// @brief Interface class for retrieving information from a InputRanker to
    3535  /// build a ConsensusInputRanker.
    3636  ///   
  • trunk/yat/classifier/InputRanker.h

    r720 r767  
    4040
    4141  ///
    42   /// Class for ranking rows in a matrix, using a Score and a
     42  /// @brief Class for ranking rows in a matrix, using a Score and a
    4343  /// target vector.
    4444  ///   
  • trunk/yat/classifier/Kernel.h

    r749 r767  
    3939
    4040  ///
    41   ///  @brief Abstract Base Class for Kernels.
     41  ///  @brief Interface Class for Kernels.
    4242  ///
    4343  ///  Class taking care of the \f$ NxN \f$ kernel matrix, where \f$ N \f$
  • trunk/yat/classifier/KernelFunction.h

    r680 r767  
    3232
    3333  ///
    34   ///   Virtual Class calculating kernel matrix.
     34  /// @brief Interface class calculating elements in Kernel.
    3535  ///
    3636  class KernelFunction
  • trunk/yat/classifier/MatrixLookup.h

    r757 r767  
    3939namespace classifier { 
    4040
     41  ///
     42  /// @brief General view into utility::matrix
    4143  ///
    4244  /// MatrixLookups can be used to create lookups/views into matrices
  • trunk/yat/classifier/MatrixLookupWeighted.h

    r757 r767  
    3939namespace classifier { 
    4040
     41  ///
     42  /// @brief Class viewing into data and weight matrix.
    4143  ///
    4244  /// A MatrixLookupWeighted is very similar to a MatrixLookup, but
  • trunk/yat/classifier/NBC.cc

    r722 r767  
    3030#include "yat/utility/matrix.h"
    3131
     32#include <cassert>
    3233#include <vector>
    3334
     
    5152
    5253
    53     const DataLookup2D& NBC::data(void) const
    54     {
     54  const DataLookup2D& NBC::data(void) const
     55  {
    5556    return data_;
    56     }
     57  }
    5758
    5859
     
    8384          const MatrixLookupWeighted& data =
    8485            dynamic_cast<const MatrixLookupWeighted&>(data_);
    85             aver[target_(j)].add(data.data(i,j), data.weight(i,j));
     86          aver[target_(j)].add(data.data(i,j), data.weight(i,j));
    8687        }
    8788        else
     
    9091      for (size_t j=0; target_.nof_classes(); ++j){
    9192        centroids_(i,j) = aver[j].mean();
    92         sigma_(i,j) = aver[j].variance();
     93        sigma2_(i,j) = aver[j].variance();
    9394      }
    9495    }   
     
    103104    std::cerr << "NBC::predict not implemented\n";
    104105    exit(1);
     106    assert(data_.rows()==input.rows());
     107
     108    std::log(sigma_(i,c)) +
     109
     110    prediction = utility::matrix(centroids_.columns(),input.columns());
     111    for (size_t c=0; c<centroid_.columns(); ++c) {
     112      double sum_ln_sigma=0;
     113      for (size_t i=0; i<sigma2_.rows(); ++i)
     114        sum_ln_sigma += log(sigma2_(i,c));
     115      sum_ln_sigma /= 2;
     116
     117      for (size_t s=0; s<input.columns(); ++s) {
     118        // -lnp = sum{ln(sigma_i)} + sum{(x_i-m_i)^2/(2sigma_i)}
     119        prediction(c,s) = sum_ln_sigma;
     120        for (size_t i=0; i<input.columns(); ++i) {
     121          prediction(c,s) += std::pow(input(i,s)-mean_(i,c),2)/sigma2_(i,c);
     122        }
     123      }
     124    }
     125    // exponentiate and normalize
    105126  }
    106127
  • trunk/yat/classifier/NBC.h

    r722 r767  
    3838  class Target;
    3939
    40   ///
    41   /// @brief Naive Bayesian Classification.
    42   ///
     40  /**
     41     @brief Naive Bayesian Classification.
     42 
     43     Each class is modelled as a multinormal distribution with
     44     features being independent: \f$ p(x|c) = \prod
     45     \frac{1}{\sqrt{2\pi\sigma_i^2}} \exp \left(
     46     \frac{(x_i-m_i)^2}{2\sigma_i^2)} \right)\f$
     47  */
    4348  class NBC : public SupervisedClassifier
    4449  {
     
    6974    /// Train the classifier using the training data.
    7075    ///
     76    /// For each class mean and variance are estimated for each
     77    /// feature (see Averager and AveragerWeighted for details).
     78    ///
    7179    /// @return true if training succedeed.
    7280    ///
     
    7886    /// to the corresponding class.
    7987    ///
    80     void predict(const DataLookup2D&, utility::matrix&) const;
     88    void predict(const DataLookup2D& data, utility::matrix& res) const;
    8189
    8290
    8391  private:
     92    double gaussian(double x, double m, double sigma) const;
     93
    8494    utility::matrix centroids_;
    8595    utility::matrix sigma_;
  • trunk/yat/classifier/NCC.h

    r722 r767  
    5050
    5151  ///
    52   /// Class for Nearest Centroid Classification.
     52  /// @brief Class for Nearest Centroid Classification.
    5353  ///
    5454
  • trunk/yat/classifier/PolynomialKernelFunction.h

    r747 r767  
    3636
    3737  ///
    38   /// Class for polynomial kernel calculations
     38  /// @brief Class for polynomial kernel calculations
    3939  ///
    4040
  • trunk/yat/classifier/Sampler.h

    r720 r767  
    3434
    3535  ///
    36   /// Interface for dividing samples into training and validation.
     36  /// @brief Interface class for dividing samples into training and
     37  /// validation.
    3738  ///   
    3839
  • trunk/yat/classifier/SubsetGenerator.h

    r720 r767  
    3838
    3939  ///
    40   /// Class splitting a set into training set and validation set using
    41   /// a Sampler method.
    42   ///   
     40  /// @brief Class splitting a set into training set and validation set.
     41  ///
    4342  class SubsetGenerator
    4443  {
  • trunk/yat/classifier/SupervisedClassifier.h

    r722 r767  
    4040
    4141  ///
    42   /// Interface class for supervised classifiers
     42  /// @brief Interface class for supervised classifiers
    4343  ///
    4444
  • trunk/yat/classifier/Target.h

    r757 r767  
    3838
    3939  ///
    40   /// Class for targets
     40  /// @brief Class for containing sample labels.
    4141  ///
    4242
  • trunk/yat/random/random.h

    r752 r767  
    433433
    434434  ///
    435   /// Class to generate numbers from a histogram in a continuous manner.
     435  /// @brief Generates numbers from a histogram in a continuous manner.
    436436  ///
    437437  class ContinuousGeneral : public Continuous
  • trunk/yat/regression/Kernel.h

    r682 r767  
    3030
    3131  ///
    32   /// Abstract Base Class for calculating the weights in a more
     32  /// @brief Interface Class for calculating the weights in a more
    3333  /// general way than classical rectangular windows.
    3434  ///
     
    4545
    4646    ///
    47     /// Function calculating the weight
     47    /// Operator calculating calculating kernel value.
    4848    ///
    49     virtual double weight(const double) const=0;
     49    virtual double operator()(const double) const=0;
    5050  };
    5151
  • trunk/yat/regression/KernelBox.cc

    r682 r767  
    3333  }
    3434
    35   double KernelBox::weight(const double u) const
     35  double KernelBox::operator()(const double u) const
    3636  {
    3737    if (u>1 || u<-1)
  • trunk/yat/regression/KernelBox.h

    r682 r767  
    3232
    3333  ///
    34   /// Class for KernelBox a.k.a. rectangular window.
     34  /// @brief Class for KernelBox a.k.a. rectangular window.
    3535  ///
    3636  class KernelBox : public Kernel
     
    4444
    4545    ///
    46     /// Function calculating the weight as \f$ w(x)=1\f$ if \f$|x|\le 1
     46    /// Function calculating kernel value as \f$ w(x)=1\f$ if \f$|x|\le 1
    4747    /// \f$, \f$ w(x)=0 \f$ otherwise.
    4848    ///
    49     double weight(const double) const;
     49    double operator()(const double) const;
    5050 
    5151  private:
  • trunk/yat/regression/KernelTriCube.cc

    r682 r767  
    3636  }
    3737
    38   double KernelTriCube::weight(const double x) const
     38  double KernelTriCube::operator()(const double x) const
    3939  {
    4040    if (x>1 || x<-1)
  • trunk/yat/regression/KernelTriCube.h

    r682 r767  
    3232
    3333  ///
    34   /// Class for TriCubal kernel.
     34  /// @brief Class for TriCubal kernel.
    3535  ///
    3636  class KernelTriCube : public Kernel
     
    4444
    4545    ///
    46     /// Function calculating the weight as \f$ w(x)=(1-|x|^3)^3\f$ if
     46    /// Operator calculating kernel value as \f$ w(x)=(1-|x|^3)^3\f$ if
    4747    /// \f$|x|\le 1 \f$, \f$ w(x)=0 \f$ otherwise.
    4848    ///
    49     double weight(const double) const;
     49    double operator()(const double) const;
    5050 
    5151  private:
  • trunk/yat/regression/Local.cc

    r759 r767  
    107107      utility::vector w(max_index-min_index+1);
    108108      for (size_t j=0; j<w.size(); j++)
    109         w(j) = kernel_->weight( (x_local(j)- x_mid)/width );
     109        w(j) = (*kernel_)( (x_local(j)- x_mid)/width );
    110110     
    111111      // fitting the regressor locally
  • trunk/yat/regression/Local.h

    r747 r767  
    3737
    3838  ///
    39   /// Class for Locally weighted regression.
     39  /// @brief Class for Locally weighted regression.
    4040  ///
    4141  /// Locally weighted regression is an algorithm for learning
  • trunk/yat/regression/OneDimensional.h

    r729 r767  
    3737
    3838  ///
    39   /// Abstract Base Class for One Dimensional fitting.   
     39  /// @brief Interface Class for One Dimensional fitting.   
    4040  ///
    4141  /// @see OneDimensionalWeighted.
  • trunk/yat/regression/OneDimensionalWeighted.h

    r729 r767  
    3737 
    3838  ///
    39   /// Abstract Base Class for One Dimensional fitting in a weighted
     39  /// @brief Interface Class for One Dimensional fitting in a weighted
    4040  /// fashion.
    4141  ///
  • trunk/yat/regression/PolynomialWeighted.h

    r757 r767  
    3434
    3535  ///
    36   /// @todo document
     36  /// @brief Polynomial Regression in weighted fashion.
    3737  ///
    3838  class PolynomialWeighted : public OneDimensionalWeighted
  • trunk/yat/statistics/Averager.h

    r718 r767  
    3535
    3636  ///
    37   /// Class to calculate simple (first and second moments) averages.
     37  /// @brief Class to calculate simple (first and second moments) averages.
    3838  ///
    3939  /// @see AveragerWeighted AveragerPair AveragerPairWeighted
  • trunk/yat/statistics/AveragerPair.h

    r757 r767  
    3535
    3636  ///
    37   /// Class for taking care of mean and covariance of two variables.
     37  /// @brief Class for taking care of mean and covariance of two variables.
    3838  ///
    3939  /// @see Averager AveragerWeighted AveragerPairWeighted
  • trunk/yat/statistics/AveragerPairWeighted.h

    r718 r767  
    3737namespace statistics{
    3838  ///
    39   /// Class for taking care of mean and covariance of two variables in
     39  /// @brief Class for taking care of mean and covariance of two variables in
    4040  /// a weighted manner.
    4141  ///
  • trunk/yat/statistics/Distance.h

    r703 r767  
    3838
    3939  ///
    40   /// Interface class for calculating distances between arrays.
     40  /// @brief Interface class for calculating distances between arrays.
    4141  ///
    4242  class Distance
  • trunk/yat/statistics/FoldChange.h

    r683 r767  
    3535
    3636  ///
    37   /// @brief FoldChange
    38   ///
    39   /// This score is simply given by the difference by the group means.
     37  /// @brief Score given by the difference by the group means.
    4038  ///
    4139  class FoldChange : public Score
  • trunk/yat/statistics/Histogram.h

    r718 r767  
    3535
    3636  ///
    37   /// Histograms provide a convenient way of presenting the
    38   /// distribution of a set of data. A histogram consists of a set of
     37  /// @brief Histograms provide a convenient way of presenting the
     38  /// distribution of a set of data.
     39  ///
     40  /// A histogram consists of a set of
    3941  /// bins which count the number of events falling into these
    4042  /// bins. Currently only one dimensional histograms with uniformly
  • trunk/yat/statistics/Pearson.h

    r703 r767  
    3838
    3939  ///
    40   /// Class for calculating Pearson correlation.
     40  /// @brief Class for calculating Pearson correlation.
    4141  ///   
    4242 
  • trunk/yat/statistics/PearsonDistance.h

    r703 r767  
    4040namespace statistics{
    4141  ///
    42   /// Class for calculating distances using Pearson correlation.
     42  /// @brief Class for calculating distances using Pearson correlation.
    4343  /// d=1-C.
    4444  ///
  • trunk/yat/statistics/ROC.h

    r747 r767  
    4141
    4242  ///
    43   /// Class for ROC (Reciever Operating Characteristic).
     43  /// @brief Class for Reciever Operating Characteristic.
    4444  ///   
    4545  /// As the area under an ROC curve is equivalent to Mann-Whitney U
  • trunk/yat/statistics/Score.h

    r757 r767  
    3838
    3939  ///
    40   /// Abstract Base Class defining the interface for the score classes.
     40  /// @brief Interface Class for score classes.
    4141  ///
    4242  class Score
  • trunk/yat/statistics/tScore.h

    r703 r767  
    3737
    3838  ///
    39   /// Class for Fisher's t-test.
     39  /// @brief Class for Fisher's t-test.
    4040  ///   
    4141  /// See <a href="http://en.wikipedia.org/wiki/Student's_t-test">
  • trunk/yat/utility/FileUtil.h

    r711 r767  
    3838
    3939  ///
    40   /// FileUtil is a utility class for checking file/directory
    41   /// existence and access permissions. FileUtil is a wrapper to
    42   /// access(2) and stat(2).
     40  ///
     41  /// @brief Checking file/directory existence and access permissions.
     42  ///
     43  /// FileUtil is a wrapper to access(2) and stat(2).
    4344  ///
    4445  class FileUtil {
  • trunk/yat/utility/NNI.h

    r718 r767  
    3838
    3939  ///
    40   /// NNI is an abstract base class defining the interface for nearest
     40  /// @brief Interface class for nearest
    4141  /// neighbour imputation (NNI) algorithms.
    4242  ///
  • trunk/yat/utility/PCA.h

    r715 r767  
    3333
    3434  /**
     35     @brief Principal Component Analysis
     36
    3537     Class performing PCA using SVD. This class assumes that
    3638     the columns corresponds to the dimenension of the problem.
  • trunk/yat/utility/SVD.h

    r751 r767  
    3535
    3636  /**
    37      Class encapsulating GSL methods for singular value decomposition,
    38      SVD.
     37     @brief Singular Value Decomposition
     38
     39     Class encapsulating GSL methods for singular value
     40     decomposition, SVD.
    3941
    4042     A = U S V' = (MxN)(NxN)(NxN) = (MxN)\n   
  • trunk/yat/utility/WeNNI.h

    r703 r767  
    3636namespace utility {
    3737
     38  ///
     39  /// @brief Weighted Nearest Neighbour Imputation
    3840  ///
    3941  /// WeNNI is a continuous weights generalization of the (binary
  • trunk/yat/utility/kNNI.h

    r687 r767  
    3737
    3838  ///
     39  /// @brief kNNimpute
     40  ///
    3941  /// kNNI is the binary weight implementation of NNI. This follows
    4042  /// the work done by Troyanskaya et al. cited in the NNI document
  • trunk/yat/utility/matrix.h

    r762 r767  
    4343
    4444  ///
    45   /// This is the yat interface to GSL matrix. 'double' is the
    46   /// only type supported, maybe we should add a 'complex' type as
    47   /// well in the future.
     45  /// @brief Interface to GSL matrix.
     46  ///
     47  /// For the time being 'double' is the only type supported.
    4848  ///
    4949  /// \par[File streams] Reading and writing vectors to file streams
  • trunk/yat/utility/stl_utility.h

    r725 r767  
    5858
    5959  ///
     60  /// @brief Functor comparing pairs using second.
     61  ///
    6062  /// STL provides operator< for the pair.first element, but none for
    6163  /// pair.second. This template provides this and can be used as the
  • trunk/yat/utility/vector.h

    r759 r767  
    4444
    4545  /**
    46      This is the yat interface to GSL vector. 'double' is the only
    47      type supported, maybe we should add a 'complex' type as well in
    48      the future.
     46     @brief This is the yat interface to GSL vector.
     47
     48     For time being 'double' is the only type supported.
    4949
    5050     \par File streams:
Note: See TracChangeset for help on using the changeset viewer.