New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lda

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lda - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

test2.js

23

lib/lda.js

@@ -7,3 +7,3 @@ var stem = require('stem-porter');

//
var process = function(sentences, numberOfTopics, numberOfTermsPerTopic, languages, alphaValue, betaValue) {
var process = function(sentences, numberOfTopics, numberOfTermsPerTopic, languages, alphaValue, betaValue, randomSeed) {
// The result will consist of topics and their included terms [[{"term":"word1", "probability":0.065}, {"term":"word2", "probability":0.047}, ... ], [{"term":"word1", "probability":0.085}, {"term":"word2", "probability":0.024}, ... ]].

@@ -60,3 +60,3 @@ var result = [];

lda.configure(documents,V,10000, 2000, 100, 10);
lda.configure(documents,V,10000, 2000, 100, 10, randomSeed);
lda.gibbs(K, alpha, beta);

@@ -126,5 +126,6 @@

var SAMPLE_LAG;
var RANDOM_SEED;
var dispcol = 0;
var numstats=0;
this.configure = function (docs,v,iterations,burnIn,thinInterval,sampleLag) {
this.configure = function (docs,v,iterations,burnIn,thinInterval,sampleLag,randomSeed) {
this.ITERATIONS = iterations;

@@ -134,2 +135,3 @@ this.BURN_IN = burnIn;

this.SAMPLE_LAG = sampleLag;
this.RANDOM_SEED = randomSeed;
this.documents = docs;

@@ -152,3 +154,3 @@ this.V = v;

for (var n = 0; n < N; n++) {
var topic = parseInt(""+(Math.random() * K));
var topic = parseInt(""+(this.getRandom() * K));
this.z[m][n] = topic;

@@ -219,3 +221,3 @@ this.nw[this.documents[m][n]][topic]++;

}
var u = Math.random() * p[this.K - 1];
var u = this.getRandom() * p[this.K - 1];
for (topic = 0; topic < p.length; topic++) {

@@ -281,4 +283,15 @@ if (u < p[topic])

}
this.getRandom = function() {
if (this.RANDOM_SEED) {
// generate a pseudo-random number using a seed to ensure reproducable results.
var x = Math.sin(this.RANDOM_SEED++) * 1000000;
return x - Math.floor(x);
} else {
// use standard random algorithm.
return Math.random();
}
}
}
module.exports = process;
{
"name": "lda",
"version": "0.1.7",
"version": "0.1.8",
"description": "LDA topic modeling for node.js.",

@@ -45,4 +45,4 @@ "author": {

],
"_id": "lda@0.1.7",
"_id": "lda@0.1.8",
"_from": "lda"
}

@@ -109,2 +109,11 @@ LDA

## Setting a Random Seed
A specific random seed can be used to compute the same terms and probabilities during subsequent runs. You can specify the random seed, as follows:
```javascript
// Use the random seed 123.
result = lda(documents, 2, 5, null, null, null, 123);
```
## Author

@@ -111,0 +120,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc