Commit dbff9983 authored by Davis King's avatar Davis King

renamed the one_class object to kcentroid

--HG--
rename : dlib/svm/one_class.h => dlib/svm/kcentroid.h
rename : dlib/svm/one_class_abstract.h => dlib/svm/kcentroid_abstract.h
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402252
parent 43946fcc
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "svm/svm.h" #include "svm/svm.h"
#include "svm/krls.h" #include "svm/krls.h"
#include "svm/one_class.h" #include "svm/kcentroid.h"
#endif // DLIB_SVm_HEADER #endif // DLIB_SVm_HEADER
......
// Copyright (C) 2008 Davis E. King (davisking@users.sourceforge.net) // Copyright (C) 2008 Davis E. King (davisking@users.sourceforge.net)
// License: Boost Software License See LICENSE.txt for the full license. // License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ONE_CLASs_ #ifndef DLIB_KCENTROId_
#define DLIB_ONE_CLASs_ #define DLIB_KCENTROId_
#include <vector> #include <vector>
#include "one_class_abstract.h" #include "kcentroid_abstract.h"
#include "../matrix.h" #include "../matrix.h"
#include "function.h" #include "function.h"
#include "../std_allocator.h" #include "../std_allocator.h"
...@@ -16,11 +16,11 @@ namespace dlib ...@@ -16,11 +16,11 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template <typename kernel_type> template <typename kernel_type>
class one_class class kcentroid
{ {
/*! /*!
This is an implementation of an online algorithm for recursively estimating the This is an implementation of an online algorithm for recursively estimating the
center of mass of a sequence of training points. It uses the sparsification technique centroid of a sequence of training points. It uses the sparsification technique
described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel. described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel.
To understand the code it would also be useful to consult page 114 of the book Kernel To understand the code it would also be useful to consult page 114 of the book Kernel
...@@ -34,7 +34,7 @@ namespace dlib ...@@ -34,7 +34,7 @@ namespace dlib
typedef typename kernel_type::mem_manager_type mem_manager_type; typedef typename kernel_type::mem_manager_type mem_manager_type;
explicit one_class ( explicit kcentroid (
const kernel_type& kernel_, const kernel_type& kernel_,
scalar_type tolerance_ = 0.001 scalar_type tolerance_ = 0.001
) : ) :
...@@ -49,7 +49,7 @@ namespace dlib ...@@ -49,7 +49,7 @@ namespace dlib
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(tolerance_ >= 0, DLIB_ASSERT(tolerance_ >= 0,
"\tvoid one_class::set_tolerance" "\tvoid kcentroid::set_tolerance"
<< "\n\tinvalid tolerance value" << "\n\tinvalid tolerance value"
<< "\n\ttolerance: " << tolerance_ << "\n\ttolerance: " << tolerance_
<< "\n\tthis: " << this << "\n\tthis: " << this
...@@ -68,7 +68,7 @@ namespace dlib ...@@ -68,7 +68,7 @@ namespace dlib
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(value >= 0, DLIB_ASSERT(value >= 0,
"\tvoid one_class::set_max_discount" "\tvoid kcentroid::set_max_discount"
<< "\n\tinvalid discount value" << "\n\tinvalid discount value"
<< "\n\tvalue: " << value << "\n\tvalue: " << value
<< "\n\tthis: " << this << "\n\tthis: " << this
...@@ -120,7 +120,7 @@ namespace dlib ...@@ -120,7 +120,7 @@ namespace dlib
} }
void swap ( void swap (
one_class& item kcentroid& item
) )
{ {
exchange(kernel, item.kernel); exchange(kernel, item.kernel);
...@@ -139,7 +139,7 @@ namespace dlib ...@@ -139,7 +139,7 @@ namespace dlib
unsigned long dictionary_size ( unsigned long dictionary_size (
) const { return dictionary.size(); } ) const { return dictionary.size(); }
friend void serialize(const one_class& item, std::ostream& out) friend void serialize(const kcentroid& item, std::ostream& out)
{ {
serialize(item.kernel, out); serialize(item.kernel, out);
serialize(item.dictionary, out); serialize(item.dictionary, out);
...@@ -152,7 +152,7 @@ namespace dlib ...@@ -152,7 +152,7 @@ namespace dlib
serialize(item.max_dis, out); serialize(item.max_dis, out);
} }
friend void deserialize(one_class& item, std::istream& in) friend void deserialize(kcentroid& item, std::istream& in)
{ {
deserialize(item.kernel, in); deserialize(item.kernel, in);
deserialize(item.dictionary, in); deserialize(item.dictionary, in);
...@@ -317,12 +317,12 @@ namespace dlib ...@@ -317,12 +317,12 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template <typename kernel_type> template <typename kernel_type>
void swap(one_class<kernel_type>& a, one_class<kernel_type>& b) void swap(kcentroid<kernel_type>& a, kcentroid<kernel_type>& b)
{ a.swap(b); } { a.swap(b); }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
} }
#endif // DLIB_ONE_CLASs_ #endif // DLIB_KCENTROId_
// Copyright (C) 2008 Davis E. King (davisking@users.sourceforge.net) // Copyright (C) 2008 Davis E. King (davisking@users.sourceforge.net)
// License: Boost Software License See LICENSE.txt for the full license. // License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_ONE_CLASs_ABSTRACT_ #undef DLIB_KCENTROId_ABSTRACT_
#ifdef DLIB_ONE_CLASs_ABSTRACT_ #ifdef DLIB_KCENTROId_ABSTRACT_
#include <cmath> #include <cmath>
#include "../matrix/matrix_abstract.h" #include "../matrix/matrix_abstract.h"
...@@ -15,7 +15,7 @@ namespace dlib ...@@ -15,7 +15,7 @@ namespace dlib
template < template <
typename kernel_type typename kernel_type
> >
class one_class class kcentroid
{ {
/*! /*!
REQUIREMENTS ON kernel_type REQUIREMENTS ON kernel_type
...@@ -27,10 +27,10 @@ namespace dlib ...@@ -27,10 +27,10 @@ namespace dlib
WHAT THIS OBJECT REPRESENTS WHAT THIS OBJECT REPRESENTS
This is an implementation of an online algorithm for recursively estimating the This is an implementation of an online algorithm for recursively estimating the
center of mass of a sequence of training points. It uses the sparsification technique centroid of a sequence of training points. It uses the sparsification technique
described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel. described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel.
This object then allows you to compute the distance between the center of mass This object then allows you to compute the distance between the centroid
and any test points. So you can use this object to predict how similar a test and any test points. So you can use this object to predict how similar a test
point is to the data this object has been trained on (larger distances from the point is to the data this object has been trained on (larger distances from the
centroid indicate dissimilarity/anomalous points). centroid indicate dissimilarity/anomalous points).
...@@ -42,7 +42,7 @@ namespace dlib ...@@ -42,7 +42,7 @@ namespace dlib
typedef typename kernel_type::mem_manager_type mem_manager_type; typedef typename kernel_type::mem_manager_type mem_manager_type;
explicit one_class ( explicit kcentroid (
const kernel_type& kernel_, const kernel_type& kernel_,
scalar_type tolerance_ = 0.001 scalar_type tolerance_ = 0.001
); );
...@@ -146,7 +146,7 @@ namespace dlib ...@@ -146,7 +146,7 @@ namespace dlib
!*/ !*/
void swap ( void swap (
one_class& item kcentroid& item
); );
/*! /*!
ensures ensures
...@@ -168,8 +168,8 @@ namespace dlib ...@@ -168,8 +168,8 @@ namespace dlib
typename kernel_type typename kernel_type
> >
void swap( void swap(
one_class<kernel_type>& a, kcentroid<kernel_type>& a,
one_class<kernel_type>& b kcentroid<kernel_type>& b
) { a.swap(b); } ) { a.swap(b); }
/*! /*!
provides a global swap function provides a global swap function
...@@ -179,27 +179,27 @@ namespace dlib ...@@ -179,27 +179,27 @@ namespace dlib
typename kernel_type typename kernel_type
> >
void serialize ( void serialize (
const one_class<kernel_type>& item, const kcentroid<kernel_type>& item,
std::ostream& out std::ostream& out
); );
/*! /*!
provides serialization support for one_class objects provides serialization support for kcentroid objects
!*/ !*/
template < template <
typename kernel_type typename kernel_type
> >
void deserialize ( void deserialize (
one_class<kernel_type>& item, kcentroid<kernel_type>& item,
std::istream& in std::istream& in
); );
/*! /*!
provides serialization support for one_class objects provides serialization support for kcentroid objects
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
} }
#endif // DLIB_ONE_CLASs_ABSTRACT_ #endif // DLIB_KCENTROId_ABSTRACT_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment