diff --git a/src/mlpack/core/kernels/cosine_distance.hpp b/src/mlpack/core/kernels/cosine_distance.hpp index 5fc466c78d..d2a6feaeb9 100644 --- a/src/mlpack/core/kernels/cosine_distance.hpp +++ b/src/mlpack/core/kernels/cosine_distance.hpp @@ -34,14 +34,16 @@ class CosineDistance */ template static double Evaluate(const VecType& a, const VecType& b); + /** * Returns a string representation of this object. */ - std::string ToString() const{ + std::string ToString() const + { std::ostringstream convert; convert << "CosineDistance [" << this << "]" << std::endl; return convert.str(); -} + } }; //! Kernel traits for the cosine distance. diff --git a/src/mlpack/core/kernels/epanechnikov_kernel.cpp b/src/mlpack/core/kernels/epanechnikov_kernel.cpp index 7fb5ee98f7..83049f3a42 100644 --- a/src/mlpack/core/kernels/epanechnikov_kernel.cpp +++ b/src/mlpack/core/kernels/epanechnikov_kernel.cpp @@ -31,12 +31,13 @@ double EpanechnikovKernel::Evaluate(const double distance) const return std::max(0.0, 1 - std::pow(distance, 2.0) * inverseBandwidthSquared); } -// Return String of Object -std::string EpanechnikovKernel::ToString() const{ +// Return string of object. +std::string EpanechnikovKernel::ToString() const +{ std::ostringstream convert; convert << "EpanechnikovKernel [" << this << "]" << std::endl; - convert << "Bandwidth: " << bandwidth << std::endl; - convert << "Inverse Bandwidth Squared: "; + convert << " Bandwidth: " << bandwidth << std::endl; + convert << " Inverse squared bandwidth: "; convert << inverseBandwidthSquared << std::endl; return convert.str(); } diff --git a/src/mlpack/core/kernels/example_kernel.hpp b/src/mlpack/core/kernels/example_kernel.hpp index 5874feafcc..8d0a6d618d 100644 --- a/src/mlpack/core/kernels/example_kernel.hpp +++ b/src/mlpack/core/kernels/example_kernel.hpp @@ -98,18 +98,20 @@ class ExampleKernel * @param b Second vector. * @return K(a, b). */ - std::string ToString() const{ + template + static double Evaluate(const VecType& a, const VecType& b) { return 0; } + + /** + * Returns a string for the kernel object; in this case, with only the memory + * address for the kernel. If your kernel has any members, your ToString() + * method should include those as neccessary as well. + **/ + std::string ToString() const + { std::ostringstream convert; convert << "ExampleKernel [" << this << "]" << std::endl; return convert.str(); } - /** - * Returns a String for the Kernel Object; in this case, with only the memory - * address for the Kernel. If your kernel has any members, your ToString - * method should include those as neccessary as well. - **/ - template - static double Evaluate(const VecType& a, const VecType& b) { return 0; } /** * Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx] @@ -138,10 +140,10 @@ class ExampleKernel * @return the normalization constant. */ static double Normalizer() { return 0; } - - // Modified to remove unused variable "dimension" + + // Modified to remove unused variable "dimension" //static double Normalizer(size_t dimension=1) { return 0; } - + }; }; // namespace kernel diff --git a/src/mlpack/core/kernels/gaussian_kernel.hpp b/src/mlpack/core/kernels/gaussian_kernel.hpp index 2afe3362b9..606f4cb15a 100644 --- a/src/mlpack/core/kernels/gaussian_kernel.hpp +++ b/src/mlpack/core/kernels/gaussian_kernel.hpp @@ -115,10 +115,12 @@ class GaussianKernel //! Get the precalculated constant. double Gamma() const { return gamma; } - // convert object to string - std::string ToString() const{ + //! Convert object to string. + std::string ToString() const + { std::ostringstream convert; convert << "GaussianKernel [" << this << "]" << std::endl; + convert << " Bandwidth: " << bandwidth << std::endl; return convert.str(); } diff --git a/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp b/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp index 7b5110b847..77fb4e7a0d 100644 --- a/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp +++ b/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp @@ -65,10 +65,13 @@ class HyperbolicTangentKernel //! Modify offset for the kernel. double& Offset() { return offset; } - // Convert Object to String - std::string ToString() const{ + //! Convert object to string. + std::string ToString() const + { std::ostringstream convert; convert << "HyperbolicTangentKernel [" << this << "]" << std::endl; + convert << " Scale: " << scale << std::endl; + convert << " Offset: " << offset << std::endl; return convert.str(); } diff --git a/src/mlpack/core/kernels/laplacian_kernel.hpp b/src/mlpack/core/kernels/laplacian_kernel.hpp index c3e2e54d3c..65f99a39f6 100644 --- a/src/mlpack/core/kernels/laplacian_kernel.hpp +++ b/src/mlpack/core/kernels/laplacian_kernel.hpp @@ -76,11 +76,16 @@ class LaplacianKernel double Bandwidth() const { return bandwidth; } //! Modify the bandwidth. double& Bandwidth() { return bandwidth; } - std::string ToString() const{ + + //! Return a string representation of the kernel. + std::string ToString() const + { std::ostringstream convert; convert << "LaplacianKernel [" << this << "]" << std::endl; + convert << " Bandwidth: " << bandwidth << std::endl; return convert.str(); } + private: //! Kernel bandwidth. double bandwidth; diff --git a/src/mlpack/core/kernels/linear_kernel.hpp b/src/mlpack/core/kernels/linear_kernel.hpp index c2ef69d5eb..6dfbfba49d 100644 --- a/src/mlpack/core/kernels/linear_kernel.hpp +++ b/src/mlpack/core/kernels/linear_kernel.hpp @@ -48,9 +48,11 @@ class LinearKernel return arma::dot(a, b); } - std::string ToString() const{ + //! Return a string representation of the kernel. + std::string ToString() const + { std::ostringstream convert; - convert << "Linear Kernel [" << this << "]" << std::endl; + convert << "LinearKernel [" << this << "]" << std::endl; return convert.str(); } }; diff --git a/src/mlpack/core/kernels/polynomial_kernel.hpp b/src/mlpack/core/kernels/polynomial_kernel.hpp index f122dd7cd1..ca0eff6356 100644 --- a/src/mlpack/core/kernels/polynomial_kernel.hpp +++ b/src/mlpack/core/kernels/polynomial_kernel.hpp @@ -59,14 +59,17 @@ class PolynomialKernel const double& Offset() const { return offset; } //! Modify the offset of the dot product of the arguments. double& Offset() { return offset; } - - // Return String of Object - std::string ToString() const{ + + //! Return a string representation of the kernel. + std::string ToString() const + { std::ostringstream convert; convert << "PolynomialKernel [" << this << "]" << std::endl; + convert << " Degree: " << degree << std::endl; + convert << " Offset: " << offset << std::endl; return convert.str(); } - + private: //! The degree of the polynomial. double degree; diff --git a/src/mlpack/core/kernels/spherical_kernel.hpp b/src/mlpack/core/kernels/spherical_kernel.hpp index 0788eec1a1..faf355c28a 100644 --- a/src/mlpack/core/kernels/spherical_kernel.hpp +++ b/src/mlpack/core/kernels/spherical_kernel.hpp @@ -80,10 +80,12 @@ class SphericalKernel return (t <= bandwidth) ? 1.0 : 0.0; } - // convert object to string - std::string ToString() const{ + //! Return a string representation of the kernel. + std::string ToString() const + { std::ostringstream convert; convert << "SphericalKernel [" << this << "]" << std::endl; + convert << " Bandwidth: " << bandwidth << std::endl; return convert.str(); } diff --git a/src/mlpack/core/kernels/triangular_kernel.hpp b/src/mlpack/core/kernels/triangular_kernel.hpp index 1cd96cc3e3..e724c76d43 100644 --- a/src/mlpack/core/kernels/triangular_kernel.hpp +++ b/src/mlpack/core/kernels/triangular_kernel.hpp @@ -61,10 +61,12 @@ class TriangularKernel //! Modify the bandwidth of the kernel. double& Bandwidth() { return bandwidth; } - // convert object to string - std::string ToString() const{ + //! Return a string representation of the kernel. + std::string ToString() const + { std::ostringstream convert; convert << "TriangularKernel [" << this << "]" << std::endl; + convert << " Bandwidth: " << bandwidth << std::endl; return convert.str(); }