Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
linear-sum-assignment
Advanced tools
it performs a linear sum assignment even if the cost matrix is rectangular.
Package to perform a linear sum assignment even if the cost matrix is rectangular.
This package is the implementation of Jonker-Volgenant shortest augmenting path algorithm based on the publication On implementing 2D rectangular assignment algorithms
If the number of rows is <= the number of columns, then every row is assigned to one column; otherwise every column is assigned to one row. The assignment minimizes the sum of the assigned elements.
$ npm i linear-sum-assignment
import linearSumAssignment from 'linear-sum-assignment';
import { xCostMatrix } from 'ml-spectra-processing';
/**
* there is one more value in the experimental values, so one of
* them will be not assigned.
**/
const experimental = [1, 2, 3, 4, 5, 7];
const predicted = [3.1, 1.1, 1.9, 3.99, 5.2];
/**
* We will compute a cost matrix where experimental are
* rows and predicted in columns.
* In this case we will look for the closest peak for each experimental peak value.
**/
const diff = xCostMatrix(experimental, predicted, {
fct: (a, b) => Math.abs(a - b),
});
const result = linearSumAssignment(diff, { maximaze: false });
console.log(result);
/**
{
rowAssignments: Float64Array(6) [ 1, 2, 0, 3, 4, -1 ],
columnAssignments: Float64Array(5) [ 2, 0, 1, 3, 4 ],
gain: 0.5100000000000002,
dualVariableForColumns: Float64Array(5) [
0.0900000000000003,
0.0900000000000003,
0.0900000000000003,
0,
0.1900000000000004
],
dualVariableForRows: Float64Array(6) [ 0, 0, 0, 0, 0, 0 ]
}
*/
rowAssignments
contains the index of the column assigned to each element in the rows (experimental).
columnAssignments
contains the index of the row assigned to each element in the columns. So the first element in predicted is assigned to third element in experimental.
dualVariableForColumns
and dualVariableForRows
are the Lagrange multipliers or dual variables.
gain
the sum of the elements in the cost matrix.
FAQs
it performs a linear sum assignment even if the cost matrix is rectangular.
The npm package linear-sum-assignment receives a total of 19,303 weekly downloads. As such, linear-sum-assignment popularity was classified as popular.
We found that linear-sum-assignment demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.