# k-means component \[iris\]

**URL:** <https://forum.knime.com/t/k-means-component-iris/10663>\
**Category:** KNIME Analytics Platform\
**Created:** [April 3, 2018, 9:45am UTC](https://forum.knime.com/t/k-means-component-iris/10663 "2018-04-03T09:45:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xavier.diab](https://forum-cdn.knime.com/user_avatar/forum.knime.com/xavier.diab/32/711_2.png) [@xavier.diab](https://forum.knime.com/u/xavier.diab)\
**Post date:** [April 3, 2018, 9:45am UTC](https://forum.knime.com/t/k-means-component-iris/10663/1 "2018-04-03T09:45:09Z")

</div>

Hi

How come the render result of kmeans (iris data set) is so different between knime and rstudio  
The rstudio is by far better, how could I get the same quality in knime?

 ![knime](https://forum-cdn.knime.com/uploads/default/original/1X/6bd672bc176c86ceeb020edb6597c7c8c6c29b3b.png)

and rStudio

 ![Rstudio](https://forum-cdn.knime.com/uploads/default/original/1X/4f8e643ce01183d2efd53c5daf2bce4f31e8d073.png)

---

<div class="post-metadata">

**Author:** ![Iris](https://forum-cdn.knime.com/user_avatar/forum.knime.com/iris/32/14_2.png) [@Iris](https://forum.knime.com/u/Iris)\
**Post date:** [April 3, 2018, 10:30am UTC](https://forum.knime.com/t/k-means-component-iris/10663/2 "2018-04-03T10:30:06Z")

</div>

Hi Xavier,

This seems to be a question for me 🙂

I get the same results with KNIME if I only use sepal length and width for clustering. But if I include all four dimensions I get what you posted. It is also worth checking the Scatter Matrix, than you see all combinations.

k-means is not a deterministic algorithm. As it is greedy i can stop in local optima of the optimization problems. You can check this by shuffling the input data before the k-means node. Because the node will always use the first k rows for initializing the centers.  
 ![image](https://forum-cdn.knime.com/uploads/default/original/1X/4115a67c6b72a57b7b789124806fb779a9eaa81a.png)

Could you post the R code you are using?

Best, Iris

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:29pm UTC](https://forum.knime.com/t/k-means-component-iris/10663/3 "2023-06-23T20:29:07Z")

</div>

Closed on June 23, 2023, 8:29pm UTC


