Skip to content

Conversation

@zqqcee
Copy link

@zqqcee zqqcee commented Oct 7, 2023

Description

  • propertiesKey is a param to detect whether the relevant property used in k-means is in nodes.
  • Due to the data property collects all of the properties of nodes, propertiesKey param have been removed in v5 algorithm.

@zqqcee
Copy link
Author

zqqcee commented Oct 7, 2023

let distance = 0;
switch (distanceType) {
case DistanceType.EuclideanDistance:
distance = new Vector(item).euclideanDistance(new Vector(otherItem));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉 new 两个 vector 有点浪费性能,还不如直接数值计算一下

// When the number of nodes or the length of the attribute set is less than k, k will be adjusted to the smallest of them
const finalK = Math.min(k, nodes.length, allPropertiesWeightUniq.length);
for (let i = 0; i < nodes.length; i++) {
nodes[i].data.originIndex = i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在做了数据隔离,这种写到数据里面的方式不太好了,是不是可以另外存到一个 map 里面

id: `${i}`,
nodes: [nodes[maxDistanceNodeIndex]]
};
nodes[maxDistanceNodeIndex].data.clusterId = String(i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,可以用一个 Map<ID, string> 存储这些信息,key 是节点 id, value 是聚类 id

@Yanyan-Wang
Copy link
Contributor

感谢 PR ~

@Yanyan-Wang Yanyan-Wang merged commit db6c435 into antvis:next Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants