npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@good-i-deer/node-red-contrib-cosine-similarity

v1.0.1

Published

Calculates cosine similarity of two vector values in Node-RED

Downloads

5

Readme

@GOOD-I-DEER/node-red-contrib-cosine-similarity

platform npm version GitHub license

This module provides a node that calculates cosine similarity of two vector values in Node-RED.

This node requires node.js version 18.16.1 and Node-RED version 3.1.0.

Description

This node calculates cosine similarity between two vectors and return it as an array. It can calculate multiple arrays of vectors. The output can be used for detecting if there are cases where the similarity is above a cerain value.

var input_array1 = [
	[ "arrays of vectors 1" ],
	[ "arrays of vectors 2" ],
	[ "arrays of vectors 3" ]
]

var input_array2 = [
	[ "arrays of vectors 4" ],
	[ "arrays of vectors 5" ],
	[ "arrays of vectors 6" ]
]

var outout_array = [
	[ "arrays of cosine similarity between input_array2 and arrays of vectors 1" ],
	[ "arrays of cosine similarity between input_array2 and arrays of vectors 2" ],
	[ "arrays of cosine similarity between input_array2 and arrays of vectors 3" ]
]

Pre-requisites

The node-red-contrib-cosine-similarity requires Node-RED to be installed.

Install

cd ~/.node-red
npm install @good-i-deer/node-red-contrib-cosine-similarity

Restart your Node-RED instance

Input

Array of Vector Arrays

  • The input is an array of vector arrays.

property

cosine-similarity-pic

Name

  • The name of the node displayed on the screen.

File

  • File path of file that contains another array of vector arrays. This file will be compared with the input vector array. Can not be empty.

Output

Array of Cosine Similarity Arrays

  • The output is an array of cosine similarity arrays. Each cosine similarity is similarity between vector of input and vector of file.

Examples

Here are some example flows of cosine similarity. example

JSON

[
    {
        "id": "02168a0656dc6f37",
        "type": "tab",
        "label": "Example Flow",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "0e57c1a384a6551d",
        "type": "calculate-cosine",
        "z": "02168a0656dc6f37",
        "name": "",
        "file": "C:\\Users\\SSAFY\\Desktop\\ssdc\\object\\vectors\\stored.txt",
        "x": 350,
        "y": 80,
        "wires": [
            [
                "71c649b78711fc2a"
            ]
        ]
    },
    {
        "id": "a1704726f1bf888d",
        "type": "function",
        "z": "02168a0656dc6f37",
        "name": "temp function1",
        "func": "msg.payload = msg.payload[0];\nreturn msg",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 120,
        "y": 80,
        "wires": [
            [
                "0e57c1a384a6551d"
            ]
        ]
    },
    {
        "id": "71c649b78711fc2a",
        "type": "debug",
        "z": "02168a0656dc6f37",
        "name": "Similarity Value",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 80,
        "wires": []
    }
]

Discussions and suggestions

Use GitHub Issues to ask questions or to discuss new features.

Authors

GOOD-I-DEER in SSAFY(Samsung Software Academy for Youth) 9th

Copyright and license

Copyright Samsung Automation Studio Team under the Apache 2.0 license

Reference