Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
category-utility
Advanced tools
This library allows to clusterize a dataset of purely categorical data by using as a measure of fitness the Category Utility.
You can read more about this value on wikipedia. In a nutshell, it tries to maximize the similarity between items in the same cluster, and minimize the one between different clusters.
The function clusterize
accepts up to 4 parameters and returns an array of arrays of Point
:
data: Point[]
The array of objects with categorical values to be clusterized. It won't be modified.
clusters: number
The desired number of clusters. They all will start with one item each.
weights: Weights - optional
You can set the weight for each object key, so that while clustering you'll be able to force the function to rely more on some values than others.
filteredValues: string[] - optional
Just like setting the weights for those values to 0, it will not use those object keys while clusterizing.
import { clusterize } from 'category-utility'
const data = [
{ id: '1', size: 'small', color: 'red' },
{ id: '2', size: 'medium', color: 'blue' },
{ id: '3', size: 'large', color: 'red' },
{ id: '4', size: 'medium', color: 'red' },
{ id: '5', size: 'medium', color: 'red' },
{ id: '6', size: 'medium', color: 'blue' },
{ id: '7', size: 'small', color: 'blue' },
]
const weights = { size: 0.5, color: 2 }
const filteredValues = ['id']
const clusters = clusterize(data, 2, weights, filteredValues)
// [ [ { id: '1', size: 'small', color: 'red' },
// { id: '3', size: 'large', color: 'red' },
// { id: '4', size: 'medium', color: 'red' },
// { id: '5', size: 'medium', color: 'red' } ],
// [ { id: '2', size: 'medium', color: 'blue' },
// { id: '6', size: 'medium', color: 'blue' },
// { id: '7', size: 'small', color: 'blue' } ] ]
FAQs
Category Utility clustering for categorical data.
The npm package category-utility receives a total of 5 weekly downloads. As such, category-utility popularity was classified as not popular.
We found that category-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.