[mlpack-svn] r16192 - mlpack/trunk/src/mlpack/core/kernels
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Jan 28 18:01:49 EST 2014
Author: rcurtin
Date: Tue Jan 28 18:01:49 2014
New Revision: 16192
Log:
Update ToString() for all kernels except the PSpectrumStringKernel.
Modified:
mlpack/trunk/src/mlpack/core/kernels/cosine_distance.hpp
mlpack/trunk/src/mlpack/core/kernels/epanechnikov_kernel.cpp
mlpack/trunk/src/mlpack/core/kernels/example_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/laplacian_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/linear_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/spherical_kernel.hpp
mlpack/trunk/src/mlpack/core/kernels/triangular_kernel.hpp
Modified: mlpack/trunk/src/mlpack/core/kernels/cosine_distance.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/cosine_distance.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/cosine_distance.hpp Tue Jan 28 18:01:49 2014
@@ -34,14 +34,16 @@
*/
template<typename VecType>
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.
Modified: mlpack/trunk/src/mlpack/core/kernels/epanechnikov_kernel.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/epanechnikov_kernel.cpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/epanechnikov_kernel.cpp Tue Jan 28 18:01:49 2014
@@ -31,12 +31,13 @@
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();
}
Modified: mlpack/trunk/src/mlpack/core/kernels/example_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/example_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/example_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -98,18 +98,20 @@
* @param b Second vector.
* @return K(a, b).
*/
- std::string ToString() const{
+ template<typename VecType>
+ 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<typename VecType>
- 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 @@
* @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
Modified: mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -115,10 +115,12 @@
//! 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();
}
Modified: mlpack/trunk/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -65,10 +65,13 @@
//! 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();
}
Modified: mlpack/trunk/src/mlpack/core/kernels/laplacian_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/laplacian_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/laplacian_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -76,11 +76,16 @@
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;
Modified: mlpack/trunk/src/mlpack/core/kernels/linear_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/linear_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/linear_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -48,9 +48,11 @@
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();
}
};
Modified: mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -59,14 +59,17 @@
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;
Modified: mlpack/trunk/src/mlpack/core/kernels/spherical_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/spherical_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/spherical_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -80,10 +80,12 @@
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();
}
Modified: mlpack/trunk/src/mlpack/core/kernels/triangular_kernel.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/kernels/triangular_kernel.hpp (original)
+++ mlpack/trunk/src/mlpack/core/kernels/triangular_kernel.hpp Tue Jan 28 18:01:49 2014
@@ -61,10 +61,12 @@
//! 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();
}
More information about the mlpack-svn
mailing list