Skip to content

Conversation

@zqqcee
Copy link

@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
Contributor

antvis/G6#4923

@param targetItem - The target element.
@returns The cosine similarity between the item and the targetItem.
*/
const cosineSimilarity = (
Copy link
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
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
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 容易出现循环引用


export type NodeID = string | number;
export type NodeID = string | number;
export interface NodeSimilarity extends Node<{ [key: string]: any }> {
Copy link
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
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