Developer Guide and Reference

  • 2021.1
  • 12/04/2020
  • Public Content
Contents

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

Computing
Given the training set LaTex Math image. of
p
-dimensional feature vectors and a positive integer
k
, the problem is to find a set LaTex Math image. of
p
-dimensional initial centroids.
Computing method:
dense
The method chooses first
k
feature vectors from the training set
X
.

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
= detail::descriptor_base<>::float_t, typename
Method
= detail::descriptor_base<>::method_t, typename
Task
= detail::descriptor_base<>::task_t>
class
descriptor
Template Parameters
  • Float
    – The floating-point type that the algorithm uses for intermediate computations. Can be
    float
    or
    double
    .
  • 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
.
Public Methods
auto &
set_cluster_count
(int64_t
value
)
Method tags
struct
dense
Tag-type that denotes dense.
struct
parallel_plus_dense
struct
plus_plus_dense
struct
random_dense
using
by_default
= dense
Task tags
struct
init
Tag-type that parameterizes entities used for obtaining the initial K-Means centroids.
using
by_default
= init
Alias tag-type for the initialization task.
Computing
compute(...)
Input
template<typename
Task
= task::by_default>
class
compute_input
Template Parameters
Task
– Tag-type that specifies type of the problem to solve. Can be
task::init
.
Constructors
compute_input
(
const
table &
data
)
Creates a new instance of the class with the given
data
.
Properties
const
table &
data
= table{}
An LaTex Math image. table with the data to be clustered, where each row stores one feature vector.
Getter & Setter


const table & get_data() const
auto & set_data(const table &data)

Result
template<typename
Task
= task::by_default>
class
compute_result
Template Parameters
Task
– Tag-type that specifies type of the problem to solve. Can be
task::clustering
.
Constructors
compute_result
()
Creates a new instance of the class with the default property values.
Properties
const
table &
centroids
= table{}
A LaTex Math image. table with the initial centroids. Each row of the table stores one centroid.
Getter & Setter


const table & get_centroids() const
auto & set_centroids(const table &value)

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.