Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
5694fada
Commit
5694fada
authored
Feb 11, 2015
by
Davis King
Browse files
Added spectral_cluster() example
parent
f99e940b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
examples/kkmeans_ex.cpp
examples/kkmeans_ex.cpp
+10
-2
No files found.
examples/kkmeans_ex.cpp
View file @
5694fada
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*
This is an example illustrating the use of the kkmeans object
from the dlib C++ Library.
and spectral_cluster() routine
from the dlib C++ Library.
The kkmeans object is an implementation of a kernelized k-means clustering
algorithm. It is implemented by using the kcentroid object to represent
...
...
@@ -11,7 +11,8 @@
a svm classifier finds non-linear decision surfaces.
This example will make points from 3 classes and perform kernelized k-means
clustering on those points.
clustering on those points. It will also do the same thing using spectral
clustering.
The classes are as follows:
- points very close to the origin
...
...
@@ -141,6 +142,13 @@ int main()
cout
<<
"num dictionary vectors for center 1: "
<<
test
.
get_kcentroid
(
1
).
dictionary_size
()
<<
endl
;
cout
<<
"num dictionary vectors for center 2: "
<<
test
.
get_kcentroid
(
2
).
dictionary_size
()
<<
endl
;
// Finally, we can also solve the same kind of non-linear clustering problem with
// spectral_cluster(). The output is a vector that indicates which cluster each sample
// belongs to. Just like with kkmeans, it assigns each point to the correct cluster.
std
::
vector
<
unsigned
long
>
assignments
=
spectral_cluster
(
kernel_type
(
0.1
),
samples
,
3
);
cout
<<
mat
(
assignments
)
<<
endl
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment