-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add cosine similarity algorithm #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @param targetItem - The target element. | ||
| @returns The cosine similarity between the item and the targetItem. | ||
| */ | ||
| const cosineSimilarity = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodes-cosine-similarity 也可以一起提~
There was a problem hiding this comment.
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 '.'; |
There was a problem hiding this comment.
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 容易出现循环引用
packages/graph/src/types.ts
Outdated
|
|
||
| export type NodeID = string | number; | ||
| export type NodeID = string | number; | ||
| export interface NodeSimilarity extends Node<{ [key: string]: any }> { |
There was a problem hiding this comment.
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 里面
algo: cos-similarity