K-Means initialization¶
The K-Means initialization algorithm receives \(n\) feature vectors as input and chooses \(k\) initial centroids. After initialization, K-Means algorithm uses the initialization result to partition input data into \(k\) clusters.
Operation |
Computational methods |
Programming Interface |
||
Mathematical formulation¶
Refer to Developer Guide: K-Means Initialization.
Programming Interface¶
All types and functions in this section are declared in the
oneapi::dal::kmeans_init
namespace and be available via inclusion of the
oneapi/dal/algo/kmeans_init.hpp
header file.
Descriptor¶
-
template<typename
Float
= float, typenameMethod
= method::by_default, typenameTask
= task::by_default>
classdescriptor
¶ - Template Parameters
Float – The floating-point type that the algorithm uses for intermediate computations. Can be
float
ordouble
.Method – Tag-type that specifies an implementation of K-Means Initialization algorithm.
Task – Tag-type that specifies the type of the problem to solve. Can be
task::init
.
Constructors
-
descriptor
(std::int64_t cluster_count = 2)¶ Creates a new instance of the class with the given
cluster_count
.
Properties
-
std::int64_t
cluster_count
¶ The number of clusters k. Default value: 2.
- Getter & Setter
std::int64_t get_cluster_count() const
auto & set_cluster_count(int64_t value)
- Invariants
cluster_count > 0
Computing compute(...)
¶
Input¶
-
template<typename
Task
= task::by_default>
classcompute_input
¶ - Template Parameters
Task – Tag-type that specifies type of the problem to solve. Can be
task::init
.
Constructors
Properties
Result¶
-
template<typename
Task
= task::by_default>
classcompute_result
¶ - Template Parameters
Task – Tag-type that specifies type of the problem to solve. Can be
oneapi::dal::kmeans::task::clustering
.
Constructors
-
compute_result
()¶ Creates a new instance of the class with the default property values.
Properties
Operation¶
-
template<typename
Descriptor
>
kmeans_init::compute_resultcompute
(const Descriptor &desc, const kmeans_init::compute_input &input)¶ - Parameters
desc – K-Means algorithm descriptor
kmeans_init::descriptor
input – Input data for the computing operation
- Preconditions
- Postconditions
Examples¶
Batch Processing:
Batch Processing: