Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::GeodesicDistanceKernel Class Reference

#include <GeodesicDistanceKernel.h>

Inheritance diagram for PLearn::GeodesicDistanceKernel:

Inheritance graph
[legend]
Collaboration diagram for PLearn::GeodesicDistanceKernel:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GeodesicDistanceKernel ()
 Default constructor.

 GeodesicDistanceKernel (Ker the_distance_kernel, int the_knn=10, string the_geodesic_file="", bool the_pow_distance=false)
 Convenient constructor.

virtual void build ()
 Simply calls inherited::build() then build_().

virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
 Transforms a shallow copy into a deep copy.

 PLEARN_DECLARE_OBJECT (GeodesicDistanceKernel)
int computeNearestGeodesicNeighbour (int i, const Mat &distances_xi_x_sorted, real *dist_i=0) const
 Return the index j of the data point which satisfies: 1.

real computeShortestDistance (int i, const Mat &distances_xi_x_sorted) const
 Return the shortest (geodesic) distance to i from a point x whose (non-geodesic) distance to its knn nearest neighbors in the training set is given by the matrix 'distances_xi_x_sorted', whose first column should contain the sorted distances, and whose second column should contain the corresponding indices.

virtual real evaluate (const Vec &x1, const Vec &x2) const
 Compute K(x1,x2).

virtual real evaluate_i_j (int i, int j) const
 returns evaluate(data(i),data(j))

virtual real evaluate_i_x (int i, const Vec &x, real squared_norm_of_x=-1) const
virtual real evaluate_i_x_again (int i, const Vec &x, real squared_norm_of_x=-1, bool first_time=false) const
 Return evaluate(data(i),x), where x is the same as in the precedent call to this same function (except if 'first_time' is true).

virtual real evaluate_i_x_from_distances (int i, const Mat &distances_xi_x_sorted) const
 Evaluate K(x_i,x) where x is not given explicitly, but only by the (sorted and non-geodesic) distances to all training points.

virtual void setDataForKernelMatrix (VMat the_data)
 Overridden to precompute inter-points geodesic distance.


Public Attributes

Ker distance_kernel
string geodesic_file
int knn
bool pow_distance
string shortest_algo
VMat geo_distances

Static Protected Member Functions

void declareOptions (OptionList &ol)
 Declares this class' options.


Private Types

typedef Kernel inherited

Private Member Functions

void build_ ()
 This does the actual building.


Private Attributes

Mat dist_xi_x_sorted1
 Used to store data and save memory allocation.

Mat dist_xi_x_sorted2
 Used to store data and save memory allocation.

Mat dist_xi_x_sorted
 Used to store data and save memory allocation.


Member Typedef Documentation

typedef Kernel PLearn::GeodesicDistanceKernel::inherited [private]
 

Reimplemented from PLearn::Kernel.

Definition at line 57 of file GeodesicDistanceKernel.h.


Constructor & Destructor Documentation

PLearn::GeodesicDistanceKernel::GeodesicDistanceKernel  ) 
 

Default constructor.

Definition at line 54 of file GeodesicDistanceKernel.cc.

References distance_kernel.

PLearn::GeodesicDistanceKernel::GeodesicDistanceKernel Ker  the_distance_kernel,
int  the_knn = 10,
string  the_geodesic_file = "",
bool  the_pow_distance = false
 

Convenient constructor.

Definition at line 63 of file GeodesicDistanceKernel.cc.

References build(), and distance_kernel.


Member Function Documentation

void PLearn::GeodesicDistanceKernel::build  )  [virtual]
 

Simply calls inherited::build() then build_().

Reimplemented from PLearn::Kernel.

Definition at line 115 of file GeodesicDistanceKernel.cc.

References build_().

Referenced by GeodesicDistanceKernel().

void PLearn::GeodesicDistanceKernel::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::Kernel.

Definition at line 124 of file GeodesicDistanceKernel.cc.

Referenced by build().

int PLearn::GeodesicDistanceKernel::computeNearestGeodesicNeighbour int  i,
const Mat distances_xi_x_sorted,
real dist_i = 0
const
 

Return the index j of the data point which satisfies: 1.

j is among the knn nearest neighbors of the point x from which was computed 'distances_xi_x_sorted' 2. it is such that dist(x,j) + geodesic_dist(j,x_i) is minimum If provided, the 'dist_i' parameter is filled with the geodesic distance from x to x_i.

Definition at line 131 of file GeodesicDistanceKernel.cc.

References PLearn::dist(), geo_distances, knn, PLearn::Mat, and PLearn::min().

Referenced by computeShortestDistance().

real PLearn::GeodesicDistanceKernel::computeShortestDistance int  i,
const Mat distances_xi_x_sorted
const
 

Return the shortest (geodesic) distance to i from a point x whose (non-geodesic) distance to its knn nearest neighbors in the training set is given by the matrix 'distances_xi_x_sorted', whose first column should contain the sorted distances, and whose second column should contain the corresponding indices.

Definition at line 150 of file GeodesicDistanceKernel.cc.

References computeNearestGeodesicNeighbour().

Referenced by evaluate_i_x_again(), and evaluate_i_x_from_distances().

void PLearn::GeodesicDistanceKernel::declareOptions OptionList ol  )  [static, protected]
 

Declares this class' options.

Reimplemented from PLearn::Kernel.

Definition at line 82 of file GeodesicDistanceKernel.cc.

References PLearn::declareOption(), and PLearn::OptionList.

real PLearn::GeodesicDistanceKernel::evaluate const Vec x1,
const Vec x2
const [virtual]
 

Compute K(x1,x2).

Implements PLearn::Kernel.

Definition at line 159 of file GeodesicDistanceKernel.cc.

References PLearn::dist(), dist_xi_x_sorted1, dist_xi_x_sorted2, distance_kernel, geo_distances, k, knn, PLearn::min(), pow_distance, REAL_MAX, PLearn::square(), and PLearn::Vec.

real PLearn::GeodesicDistanceKernel::evaluate_i_j int  i,
int  j
const [virtual]
 

returns evaluate(data(i),data(j))

Reimplemented from PLearn::Kernel.

Definition at line 183 of file GeodesicDistanceKernel.cc.

References geo_distances, pow_distance, and PLearn::square().

real PLearn::GeodesicDistanceKernel::evaluate_i_x int  i,
const Vec x,
real  squared_norm_of_x = -1
const [virtual]
 

returns evaluate(data(i),x) [squared_norm_of_x is just a hint that may allow to speed up computation if it is already known, but it's optional]

Reimplemented from PLearn::Kernel.

Definition at line 194 of file GeodesicDistanceKernel.cc.

References evaluate_i_x_again(), and x.

real PLearn::GeodesicDistanceKernel::evaluate_i_x_again int  i,
const Vec x,
real  squared_norm_of_x = -1,
bool  first_time = false
const [virtual]
 

Return evaluate(data(i),x), where x is the same as in the precedent call to this same function (except if 'first_time' is true).

This can be used to speed up successive computations of K(x_i, x) (default version just calls evaluate_i_x).

Reimplemented from PLearn::Kernel.

Definition at line 212 of file GeodesicDistanceKernel.cc.

References computeShortestDistance(), dist_xi_x_sorted, distance_kernel, knn, pow_distance, PLearn::square(), and x.

Referenced by evaluate_i_x().

real PLearn::GeodesicDistanceKernel::evaluate_i_x_from_distances int  i,
const Mat distances_xi_x_sorted
const [virtual]
 

Evaluate K(x_i,x) where x is not given explicitly, but only by the (sorted and non-geodesic) distances to all training points.

Definition at line 201 of file GeodesicDistanceKernel.cc.

References computeShortestDistance(), pow_distance, and PLearn::square().

void PLearn::GeodesicDistanceKernel::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Transforms a shallow copy into a deep copy.

Definition at line 226 of file GeodesicDistanceKernel.cc.

References PLERROR.

PLearn::GeodesicDistanceKernel::PLEARN_DECLARE_OBJECT GeodesicDistanceKernel   ) 
 

void PLearn::GeodesicDistanceKernel::setDataForKernelMatrix VMat  the_data  )  [virtual]
 

Overridden to precompute inter-points geodesic distance.

Reimplemented from PLearn::Kernel.

Definition at line 243 of file GeodesicDistanceKernel.cc.

References PLearn::TVec< T >::append(), PLearn::dist(), distance_kernel, PLearn::TVec< T >::fill(), PLearn::TMat< T >::fill(), geo_distances, geodesic_file, k, knn, PLearn::TVec< T >::length(), PLearn::VMat::length(), PLearn::min(), PLERROR, REAL_MAX, shortest_algo, PLearn::ProgressBar::update(), and PLearn::VMat::width().


Member Data Documentation

Mat PLearn::GeodesicDistanceKernel::dist_xi_x_sorted [mutable, private]
 

Used to store data and save memory allocation.

Definition at line 60 of file GeodesicDistanceKernel.h.

Referenced by evaluate_i_x_again().

Mat PLearn::GeodesicDistanceKernel::dist_xi_x_sorted1 [mutable, private]
 

Used to store data and save memory allocation.

Definition at line 60 of file GeodesicDistanceKernel.h.

Referenced by evaluate().

Mat PLearn::GeodesicDistanceKernel::dist_xi_x_sorted2 [mutable, private]
 

Used to store data and save memory allocation.

Definition at line 60 of file GeodesicDistanceKernel.h.

Referenced by evaluate().

Ker PLearn::GeodesicDistanceKernel::distance_kernel
 

Definition at line 74 of file GeodesicDistanceKernel.h.

Referenced by evaluate(), evaluate_i_x_again(), GeodesicDistanceKernel(), and setDataForKernelMatrix().

VMat PLearn::GeodesicDistanceKernel::geo_distances
 

Definition at line 79 of file GeodesicDistanceKernel.h.

Referenced by computeNearestGeodesicNeighbour(), evaluate(), evaluate_i_j(), and setDataForKernelMatrix().

string PLearn::GeodesicDistanceKernel::geodesic_file
 

Definition at line 75 of file GeodesicDistanceKernel.h.

Referenced by setDataForKernelMatrix().

int PLearn::GeodesicDistanceKernel::knn
 

Definition at line 76 of file GeodesicDistanceKernel.h.

Referenced by computeNearestGeodesicNeighbour(), evaluate(), evaluate_i_x_again(), and setDataForKernelMatrix().

bool PLearn::GeodesicDistanceKernel::pow_distance
 

Definition at line 77 of file GeodesicDistanceKernel.h.

Referenced by evaluate(), evaluate_i_j(), evaluate_i_x_again(), and evaluate_i_x_from_distances().

string PLearn::GeodesicDistanceKernel::shortest_algo
 

Definition at line 78 of file GeodesicDistanceKernel.h.

Referenced by setDataForKernelMatrix().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:23:27 2004 for PLearn by doxygen 1.3.7