Skip to content

feat: add cosine similarity algorithm#69

Merged
Yanyan-Wang merged 8 commits intoantvis:nextfrom
zqqcee:v5-algo-cosinesim
Sep 12, 2023
Merged

feat: add cosine similarity algorithm#69
Yanyan-Wang merged 8 commits intoantvis:nextfrom
zqqcee:v5-algo-cosinesim

Conversation

@zqqcee
Copy link
Copy Markdown

@zqqcee zqqcee commented Sep 8, 2023

algo: cos-similarity

@zqqcee zqqcee changed the title cosine similarity feat: add cosine similarity algorithm Sep 8, 2023
@Yanyan-Wang
Copy link
Copy Markdown
Contributor

antvis/G6#4923

Comment thread packages/graph/src/cosine-similarity.ts Outdated
@param targetItem - The target element.
@returns The cosine similarity between the item and the targetItem.
*/
const cosineSimilarity = (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nodes-cosine-similarity 也可以一起提~

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

import { clone } from '@antv/util';
import { getAllProperties, oneHot } from './utils';
import { NodeSimilarity } from './types';
import { cosineSimilarity } from '.';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

import { cosineSimilarity } from './cosine-similarity';

这样引入吧。从 index 容易出现循环引用

Comment thread packages/graph/src/types.ts Outdated

export type NodeID = string | number; No newline at end of file
export type NodeID = string | number;
export interface NodeSimilarity extends Node<{ [key: string]: any }> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

好像应该 extends 的是 NodeData。Node 结构是 { id: ID, data: NodeData }。这些属性应该放在 NodeData 里面

@Yanyan-Wang Yanyan-Wang merged commit 9920054 into antvis:next Sep 12, 2023
@Yanyan-Wang
Copy link
Copy Markdown
Contributor

antvis/G6#4923

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.

2 participants