# 2.13.3.2 kmeans(Pro)

Statistics: Multivariate Analysis: K-Means Cluster Analysis

## Brief Information

Perform K-Means clustering.

This feature is for OriginPro only.

Minimum Origin Version Required: 8.6

## Command Line Usage

 

1. kmeans ir:=1:end num:=3; 

2. kmeans ir:=1:end num:=3 plot:=1 iy:=(1,3); 

3. kmeans ir:=1:4 specify:=1 iinitial:=[book2]1!1:4; 

## Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Variables ir

Input

Range

<active>
Observations to cluster. Note that beginning with Origin 2020b, there is a shortened syntax that follows the form [Book]Sheet!(N1:N2), N1 = the beginning column index and N2 being the ending column index in a contiguous range of columns. More complex strings from non-contiguous data of the form [Book]Sheet!([Book]Sheet!N1:N2,[Book]Sheet!N3:N4) are also possible.
Number of Clusters num

Input

int

2
Number of clusters for observation classification. This option is not available when using Specify Initial Cluster Centers.
Specify Initial Cluster Centers specify

Input

int

0
Specify Initial Cluster Centers (1), or use Number of Clusters (0)
Initial Cluster Centers iinitial

Input

Range

Initial cluster centers specified by users
Maximum Number of Iterations iter

Input

int

10
Specify the maximum number of iterations allowed in the analysis.
Initial Cluster Centers oinitial

Input

int

1
Specify whether (1) or not (0) to report initial cluster centers.
ANOVA anova

Input

int

0
Specify whether (1) or not (0) to report ANOVA.
Cluster Membership member

Input

int

1
Specify whether (1) or not (0) to output cluster membership.
Distance from Cluster distance

Input

int

0
Specify whether (1) or not (0) to calculate the distance between each observation and its corresponding cluster center.
Group Graph plot

Input

int

0
Specify whether (1) or not (0) to create group graph.
Select Variables for Plot iy

Input

Range

Range contains the data to be grouped for group graph, which is only available when plot is 1.
• X Range
Select the range as x axis for the group graph.
• Y Range
Select the range as y axis for the group graph.
K-Means Report rt

Output

ReportTree

[<input>]<new>
Specify the location of output report tree.
Cluster Membership rd

Output

ReportData

<new>
Specify the location for the cluster membership and distance from cluster.
Plot Data rdplot

Output

ReportData

<new>
Specify the sheet for plot data. This variable is hidden in the dialog.

## Description

This function performs the K-Means Cluster Analysis on range data. For more information, see the Cluster Analysis.

## Examples

1. Import the data file \Samples\Statistics\Fisher's Iris Data.dat .
2. Run the script.
kmeans ir:=1:4 num:=3 -r 2;