generative-bayesian-network 0.1.0-beta.3 → 2.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE → LICENSE.md} +2 -2
- package/README.md +2 -154
- package/bayesian-network.d.ts +44 -0
- package/bayesian-network.d.ts.map +1 -0
- package/bayesian-network.js +111 -0
- package/bayesian-network.js.map +1 -0
- package/bayesian-node.d.ts +76 -0
- package/bayesian-node.d.ts.map +1 -0
- package/{src/bayesian-node.js → bayesian-node.js} +50 -75
- package/bayesian-node.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/index.mjs +4 -0
- package/package.json +35 -39
- package/tsconfig.build.tsbuildinfo +1 -0
- package/src/bayesian-network.js +0 -112
- package/src/main.js +0 -3
package/{LICENSE → LICENSE.md}
RENAMED
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
APPENDIX: How to apply the Apache License to your work.
|
|
179
179
|
|
|
180
180
|
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
182
|
replaced with your own identifying information. (Don't include
|
|
183
183
|
the brackets!) The text should be enclosed in the appropriate
|
|
184
184
|
comment syntax for the file format. We also recommend that a
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2018 Apify Technologies s.r.o.
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,155 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
NodeJs package containing a bayesian network capable of randomly sampling from a distribution defined by a json object.
|
|
3
|
-
|
|
4
|
-
<!-- toc -->
|
|
5
|
-
|
|
6
|
-
- [Installation](#installation)
|
|
7
|
-
- [Usage](#usage)
|
|
8
|
-
- [API Reference](#api-reference)
|
|
9
|
-
|
|
10
|
-
<!-- tocstop -->
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
Run the `npm i generative-bayesian-network` command. No further setup is needed afterwards.
|
|
14
|
-
## Usage
|
|
15
|
-
To use the network, you need to create an instance of the `BayesianNetwork` class which is exported from this package. Constructor of this class accepts a JSON object containing the network definition. This definition can either include the probability distributions for the nodes, or these can be calculated later using data. An example of such a definition saved in a JSON file could look like:
|
|
16
|
-
```json
|
|
17
|
-
{
|
|
18
|
-
"nodes": [
|
|
19
|
-
{
|
|
20
|
-
"name": "ParentNode",
|
|
21
|
-
"values": ["A", "B", "C"],
|
|
22
|
-
"parentNames": [],
|
|
23
|
-
"conditionalProbabilities": {
|
|
24
|
-
"A": 0.1,
|
|
25
|
-
"B": 0.8,
|
|
26
|
-
"C": 0.1
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"name": "ChildNode",
|
|
31
|
-
"values": [".", ",", "!", "?"],
|
|
32
|
-
"parentNames": ["ParentNode"],
|
|
33
|
-
"conditionalProbabilities": {
|
|
34
|
-
"A": {
|
|
35
|
-
".": 0.7,
|
|
36
|
-
"!": 0.3
|
|
37
|
-
},
|
|
38
|
-
"B": {
|
|
39
|
-
",": 0.3,
|
|
40
|
-
"?": 0.7
|
|
41
|
-
},
|
|
42
|
-
"C": {
|
|
43
|
-
".": 0.5,
|
|
44
|
-
"?": 0.5
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
Once you have the network definition ready, you can create an instance simply by executing:
|
|
52
|
-
```js
|
|
53
|
-
let generatorNetwork = new BayesianNetwork(networkDefinition);
|
|
54
|
-
```
|
|
55
|
-
If the network definition didn't include the probabilities, you also need to call the `setProbabilitiesAccordingToData` method and provide it with a [Danfo.js dataframe](https://danfo.jsdata.org/api-reference/dataframe) containing the dataset you want to be used to calculate the probabilities:
|
|
56
|
-
```js
|
|
57
|
-
generatorNetwork.setProbabilitiesAccordingToData(dataframe);
|
|
58
|
-
```
|
|
59
|
-
After the setup, you can save the current network's definition by doing:
|
|
60
|
-
```js
|
|
61
|
-
generatorNetwork.saveNetworkDefinition(networkDefinitionFilePath);
|
|
62
|
-
```
|
|
63
|
-
Once you have the network all set up, you can use two methods to actually generate the samples - `generateSample` and `generateConsistentSampleWhenPossible`. The first one generates a sample of all node values given (optionally) the values we already know in the form of an object. The second does much the same thing, but instead of just getting the known values of some of the attributes, the object you can give it as an argument can contain multiple possible values for each node, not just one. You could run them for example like this:
|
|
64
|
-
```js
|
|
65
|
-
let sample = generatorNetwork.generateSample({ "ParentNode": "A" });
|
|
66
|
-
let consistentSample = generatorNetwork.generateSample({
|
|
67
|
-
"ParentNode": ["A","B"], "ChildNode": [",","!"]
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## API Reference
|
|
72
|
-
All public classes, methods and their parameters can be inspected in this API reference.
|
|
73
|
-
|
|
74
|
-
<a name="BayesianNetwork"></a>
|
|
75
|
-
|
|
76
|
-
### BayesianNetwork
|
|
77
|
-
BayesianNetwork is an implementation of a bayesian network capable of randomly sampling from the distribution
|
|
78
|
-
represented by the network.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* [BayesianNetwork](#BayesianNetwork)
|
|
82
|
-
* [`new BayesianNetwork(networkDefinition)`](#new_BayesianNetwork_new)
|
|
83
|
-
* [`.generateSample(inputValues)`](#BayesianNetwork+generateSample)
|
|
84
|
-
* [`.generateConsistentSampleWhenPossible(valuePossibilities)`](#BayesianNetwork+generateConsistentSampleWhenPossible)
|
|
85
|
-
* [`.setProbabilitiesAccordingToData(dataframe)`](#BayesianNetwork+setProbabilitiesAccordingToData)
|
|
86
|
-
* [`.saveNetworkDefinition(networkDefinitionFilePath)`](#BayesianNetwork+saveNetworkDefinition)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
* * *
|
|
90
|
-
|
|
91
|
-
<a name="new_BayesianNetwork_new"></a>
|
|
92
|
-
|
|
93
|
-
#### `new BayesianNetwork(networkDefinition)`
|
|
94
|
-
|
|
95
|
-
| Param | Type | Description |
|
|
96
|
-
| --- | --- | --- |
|
|
97
|
-
| networkDefinition | <code>object</code> | object defining the network structure and distributions |
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* * *
|
|
101
|
-
|
|
102
|
-
<a name="BayesianNetwork+generateSample"></a>
|
|
103
|
-
|
|
104
|
-
#### `bayesianNetwork.generateSample(inputValues)`
|
|
105
|
-
Randomly samples from the distribution represented by the bayesian network.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
| Param | Type | Description |
|
|
109
|
-
| --- | --- | --- |
|
|
110
|
-
| inputValues | <code>object</code> | node values that are known already |
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* * *
|
|
114
|
-
|
|
115
|
-
<a name="BayesianNetwork+generateConsistentSampleWhenPossible"></a>
|
|
116
|
-
|
|
117
|
-
#### `bayesianNetwork.generateConsistentSampleWhenPossible(valuePossibilities)`
|
|
118
|
-
Randomly samples from the distribution represented by the bayesian network,
|
|
119
|
-
making sure the sample is consistent with the provided restrictions on value possibilities.
|
|
120
|
-
Returns false if no such sample can be generated.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
| Param | Type | Description |
|
|
124
|
-
| --- | --- | --- |
|
|
125
|
-
| valuePossibilities | <code>object</code> | a dictionary of lists of possible values for nodes (if a node isn't present in the dictionary, all values are possible) |
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
* * *
|
|
129
|
-
|
|
130
|
-
<a name="BayesianNetwork+setProbabilitiesAccordingToData"></a>
|
|
131
|
-
|
|
132
|
-
#### `bayesianNetwork.setProbabilitiesAccordingToData(dataframe)`
|
|
133
|
-
Sets the conditional probability distributions of this network's nodes to match the given data.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
| Param | Type | Description |
|
|
137
|
-
| --- | --- | --- |
|
|
138
|
-
| dataframe | <code>object</code> | a Danfo.js dataframe containing the data |
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* * *
|
|
142
|
-
|
|
143
|
-
<a name="BayesianNetwork+saveNetworkDefinition"></a>
|
|
144
|
-
|
|
145
|
-
#### `bayesianNetwork.saveNetworkDefinition(networkDefinitionFilePath)`
|
|
146
|
-
Saves the network definition to the specified file path to be used later.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
| Param | Type | Description |
|
|
150
|
-
| --- | --- | --- |
|
|
151
|
-
| networkDefinitionFilePath | <code>string</code> | a file path where the network definition should be saved |
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* * *
|
|
1
|
+
# Fingerprint suite
|
|
155
2
|
|
|
3
|
+
This repository contains a set of fingerprinting tools developed by Apify.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DataFrame } from 'danfojs-node';
|
|
2
|
+
/**
|
|
3
|
+
* BayesianNetwork is an implementation of a bayesian network capable of randomly sampling from the distribution
|
|
4
|
+
* represented by the network.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BayesianNetwork {
|
|
7
|
+
private nodesInSamplingOrder;
|
|
8
|
+
private nodesByName;
|
|
9
|
+
constructor({ path }: {
|
|
10
|
+
path: string;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Randomly samples from the distribution represented by the bayesian network.
|
|
14
|
+
* @param inputValues Already known node values.
|
|
15
|
+
*/
|
|
16
|
+
generateSample(inputValues?: Record<string, string>): Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Randomly samples values from the distribution represented by the bayesian network,
|
|
19
|
+
* making sure the sample is consistent with the provided restrictions on value possibilities.
|
|
20
|
+
* Returns false if no such sample can be generated.
|
|
21
|
+
* @param valuePossibilities A dictionary of lists of possible values for nodes (if a node isn't present in the dictionary, all values are possible).
|
|
22
|
+
*/
|
|
23
|
+
generateConsistentSampleWhenPossible(valuePossibilities: Record<string, string[]>): Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Recursively generates a random sample consistent with the given restrictions on possible values.
|
|
26
|
+
* @param sampleSoFar Already known node values.
|
|
27
|
+
* @param valuePossibilities A dictionary of lists of possible values for nodes (if a node isn't present in the dictionary, all values are possible).
|
|
28
|
+
* @param depth Current recursion depth.
|
|
29
|
+
*/
|
|
30
|
+
private recursivelyGenerateConsistentSampleWhenPossible;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the conditional probability distributions of this network's nodes to match the given data.
|
|
33
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
34
|
+
*/
|
|
35
|
+
setProbabilitiesAccordingToData(dataframe: DataFrame): void;
|
|
36
|
+
/**
|
|
37
|
+
* Saves the network definition to the specified file path to be used later.
|
|
38
|
+
* @param networkDefinitionFilePath File path where the network definition should be saved.
|
|
39
|
+
*/
|
|
40
|
+
saveNetworkDefinition({ path }: {
|
|
41
|
+
path: string;
|
|
42
|
+
}): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=bayesian-network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bayesian-network.d.ts","sourceRoot":"","sources":["../src/bayesian-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C;;;GAGG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,WAAW,CAAqC;gBAE5C,EAAE,IAAI,EAAE,EAAE;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC;IAapC;;;OAGG;IACH,cAAc,CAAC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAUvD;;;;;OAKG;IACH,oCAAoC,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAIjF;;;;;OAKG;IACH,OAAO,CAAC,+CAA+C;IA4BvD;;;OAGG;IACH,+BAA+B,CAAC,SAAS,EAAE,SAAS;IAUpD;;;OAGG;IACH,qBAAqB,CAAC,EAAE,IAAI,EAAE,EAAG;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC;CAWlD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BayesianNetwork = void 0;
|
|
4
|
+
const AdmZip = require("adm-zip");
|
|
5
|
+
const bayesian_node_1 = require("./bayesian-node");
|
|
6
|
+
/**
|
|
7
|
+
* BayesianNetwork is an implementation of a bayesian network capable of randomly sampling from the distribution
|
|
8
|
+
* represented by the network.
|
|
9
|
+
*/
|
|
10
|
+
class BayesianNetwork {
|
|
11
|
+
constructor({ path }) {
|
|
12
|
+
Object.defineProperty(this, "nodesInSamplingOrder", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: []
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "nodesByName", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: {}
|
|
23
|
+
});
|
|
24
|
+
const zip = new AdmZip(path);
|
|
25
|
+
const zipEntries = zip.getEntries();
|
|
26
|
+
const networkDefinition = JSON.parse(zipEntries[0].getData().toString('utf8'));
|
|
27
|
+
this.nodesInSamplingOrder = networkDefinition.nodes.map((nodeDefinition) => new bayesian_node_1.BayesianNode(nodeDefinition));
|
|
28
|
+
this.nodesByName = this.nodesInSamplingOrder.reduce((p, node) => ({
|
|
29
|
+
...p,
|
|
30
|
+
[node.name]: node,
|
|
31
|
+
}), {});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Randomly samples from the distribution represented by the bayesian network.
|
|
35
|
+
* @param inputValues Already known node values.
|
|
36
|
+
*/
|
|
37
|
+
generateSample(inputValues = {}) {
|
|
38
|
+
const sample = inputValues;
|
|
39
|
+
for (const node of this.nodesInSamplingOrder) {
|
|
40
|
+
if (!(node.name in sample)) {
|
|
41
|
+
sample[node.name] = node.sample(sample);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return sample;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Randomly samples values from the distribution represented by the bayesian network,
|
|
48
|
+
* making sure the sample is consistent with the provided restrictions on value possibilities.
|
|
49
|
+
* Returns false if no such sample can be generated.
|
|
50
|
+
* @param valuePossibilities A dictionary of lists of possible values for nodes (if a node isn't present in the dictionary, all values are possible).
|
|
51
|
+
*/
|
|
52
|
+
generateConsistentSampleWhenPossible(valuePossibilities) {
|
|
53
|
+
return this.recursivelyGenerateConsistentSampleWhenPossible({}, valuePossibilities, 0);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Recursively generates a random sample consistent with the given restrictions on possible values.
|
|
57
|
+
* @param sampleSoFar Already known node values.
|
|
58
|
+
* @param valuePossibilities A dictionary of lists of possible values for nodes (if a node isn't present in the dictionary, all values are possible).
|
|
59
|
+
* @param depth Current recursion depth.
|
|
60
|
+
*/
|
|
61
|
+
recursivelyGenerateConsistentSampleWhenPossible(sampleSoFar, valuePossibilities, depth) {
|
|
62
|
+
const bannedValues = [];
|
|
63
|
+
const node = this.nodesInSamplingOrder[depth];
|
|
64
|
+
let sampleValue;
|
|
65
|
+
do {
|
|
66
|
+
sampleValue = node.sampleAccordingToRestrictions(sampleSoFar, valuePossibilities[node.name], bannedValues);
|
|
67
|
+
if (!sampleValue)
|
|
68
|
+
break;
|
|
69
|
+
sampleSoFar[node.name] = sampleValue;
|
|
70
|
+
if (depth + 1 < this.nodesInSamplingOrder.length) {
|
|
71
|
+
const sample = this.recursivelyGenerateConsistentSampleWhenPossible(sampleSoFar, valuePossibilities, depth + 1);
|
|
72
|
+
if (Object.keys(sample).length !== 0) {
|
|
73
|
+
return sample;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return sampleSoFar;
|
|
78
|
+
}
|
|
79
|
+
bannedValues.push(sampleValue);
|
|
80
|
+
} while (sampleValue);
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sets the conditional probability distributions of this network's nodes to match the given data.
|
|
85
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
86
|
+
*/
|
|
87
|
+
setProbabilitiesAccordingToData(dataframe) {
|
|
88
|
+
this.nodesInSamplingOrder.forEach((node) => {
|
|
89
|
+
const possibleParentValues = {};
|
|
90
|
+
for (const parentName of node.parentNames) {
|
|
91
|
+
possibleParentValues[parentName] = this.nodesByName[parentName].possibleValues;
|
|
92
|
+
}
|
|
93
|
+
node.setProbabilitiesAccordingToData(dataframe, possibleParentValues);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Saves the network definition to the specified file path to be used later.
|
|
98
|
+
* @param networkDefinitionFilePath File path where the network definition should be saved.
|
|
99
|
+
*/
|
|
100
|
+
saveNetworkDefinition({ path }) {
|
|
101
|
+
const network = {
|
|
102
|
+
nodes: this.nodesInSamplingOrder,
|
|
103
|
+
};
|
|
104
|
+
// creating archives
|
|
105
|
+
const zip = new AdmZip();
|
|
106
|
+
zip.addFile('network.json', Buffer.from(JSON.stringify(network), 'utf8'));
|
|
107
|
+
zip.writeZip(path);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.BayesianNetwork = BayesianNetwork;
|
|
111
|
+
//# sourceMappingURL=bayesian-network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bayesian-network.js","sourceRoot":"","sources":["../src/bayesian-network.ts"],"names":[],"mappings":";;;AACA,kCAAmC;AACnC,mDAA+C;AAE/C;;;GAGG;AACH,MAAa,eAAe;IAIxB,YAAY,EAAE,IAAI,EAAkB;QAHpC;;;;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ACH,qBAAqB,CAAC,EAAE,IAAI,EAAmB;QAC3C,MAAM,OAAO,GAAG;YACZ,KAAK,EAAE,IAAI,CAAC,oBAAoB;SACnC,CAAC;QAEF,oBAAoB;QACpB,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;QAEzB,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1E,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;CACJ;AAxGD,0CAwGC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { DataFrame } from 'danfojs-node';
|
|
2
|
+
/**
|
|
3
|
+
* Bayesian network node definition.
|
|
4
|
+
*/
|
|
5
|
+
interface NodeDefinition {
|
|
6
|
+
/**
|
|
7
|
+
* Name of this node.
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Name of the current node's parent nodes.
|
|
12
|
+
*/
|
|
13
|
+
parentNames: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Array of possible values for this node.
|
|
16
|
+
*/
|
|
17
|
+
possibleValues: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Conditional probabilities for the `possibleValues`, given specified ancestor values.
|
|
20
|
+
*/
|
|
21
|
+
conditionalProbabilities: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* BayesianNode is an implementation of a single node in a bayesian network allowing sampling from its conditional distribution.
|
|
25
|
+
*/
|
|
26
|
+
export declare class BayesianNode {
|
|
27
|
+
private nodeDefinition;
|
|
28
|
+
/**
|
|
29
|
+
* @param nodeDefinition Node structure and distributions definition taken from the network definition file.
|
|
30
|
+
*/
|
|
31
|
+
constructor(nodeDefinition: NodeDefinition);
|
|
32
|
+
toJSON(): NodeDefinition;
|
|
33
|
+
/**
|
|
34
|
+
* Extracts unconditional probabilities of node values given the values of the parent nodes
|
|
35
|
+
* @param parentValues Parent nodes values.
|
|
36
|
+
*/
|
|
37
|
+
private getProbabilitiesGivenKnownValues;
|
|
38
|
+
/**
|
|
39
|
+
* Randomly samples from the given values using the given probabilities
|
|
40
|
+
* @param possibleValues A list of values to sample from.
|
|
41
|
+
* @param totalProbabilityOfPossibleValues Sum of probabilities of possibleValues in the conditional distribution.
|
|
42
|
+
* @param probabilities A dictionary of probabilities from the conditional distribution, indexed by the values.
|
|
43
|
+
*/
|
|
44
|
+
private sampleRandomValueFromPossibilities;
|
|
45
|
+
/**
|
|
46
|
+
* Randomly samples from the conditional distribution of this node given values of parents
|
|
47
|
+
* @param parentValues Values of the parent nodes.
|
|
48
|
+
*/
|
|
49
|
+
sample(parentValues?: {}): string;
|
|
50
|
+
/**
|
|
51
|
+
* Randomly samples from the conditional distribution of this node given restrictions on the possible
|
|
52
|
+
* values and the values of the parents.
|
|
53
|
+
* @param parentValues Values of the parent nodes.
|
|
54
|
+
* @param valuePossibilities List of possible values for this node.
|
|
55
|
+
* @param bannedValues What values of this node are banned.
|
|
56
|
+
*/
|
|
57
|
+
sampleAccordingToRestrictions(parentValues: Record<string, string>, valuePossibilities: string[], bannedValues: string[]): string | false;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the conditional probability distribution for this node to match the given data.
|
|
60
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
61
|
+
* @param possibleParentValues A dictionary of lists of possible values for parent nodes.
|
|
62
|
+
*/
|
|
63
|
+
setProbabilitiesAccordingToData(dataframe: DataFrame, possibleParentValues?: Record<string, string[]>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Recursively calculates the conditional probability distribution for this node from the data.
|
|
66
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
67
|
+
* @param possibleParentValues A dictionary of lists of possible values for parent nodes.
|
|
68
|
+
* @param depth Depth of the current recursive call.
|
|
69
|
+
*/
|
|
70
|
+
private recursivelyCalculateConditionalProbabilitiesAccordingToData;
|
|
71
|
+
get name(): string;
|
|
72
|
+
get parentNames(): string[];
|
|
73
|
+
get possibleValues(): string[];
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=bayesian-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bayesian-node.d.ts","sourceRoot":"","sources":["../src/bayesian-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAU,MAAM,cAAc,CAAC;AAmBtD;;GAEG;AACH,UAAU,cAAc;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB;;OAEG;IACH,wBAAwB,EAAE,GAAG,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,cAAc,CAAiB;IAEvC;;OAEG;gBACS,cAAc,EAAE,cAAc;IAI1C,MAAM;IAIN;;;OAGG;IACH,OAAO,CAAC,gCAAgC;IAcxC;;;;;OAKG;IACH,OAAO,CAAC,kCAAkC;IAe1C;;;OAGG;IACH,MAAM,CAAC,YAAY,KAAK;IAOxB;;;;;;OAMG;IACH,6BAA6B,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,KAAK;IAiB1I;;;;OAIG;IACH,+BAA+B,CAAC,SAAS,EAAE,SAAS,EAAE,oBAAoB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IASzG;;;;;OAKG;IACH,OAAO,CAAC,2DAA2D;IAgCnE,IAAI,IAAI,IAAK,MAAM,CAElB;IAED,IAAI,WAAW,IAAK,MAAM,EAAE,CAE3B;IAED,IAAI,cAAc,IAAK,MAAM,EAAE,CAE9B;CACJ"}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BayesianNode = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Calculates relative frequencies of values of specific attribute from the given data
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @private
|
|
6
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
7
|
+
* @param attributeName Attribute name.
|
|
6
8
|
*/
|
|
7
9
|
function getRelativeFrequencies(dataframe, attributeName) {
|
|
8
10
|
const frequencies = {};
|
|
9
11
|
const totalCount = dataframe.shape[0];
|
|
10
|
-
const valueCounts = dataframe[attributeName].
|
|
11
|
-
|
|
12
|
+
const valueCounts = dataframe[attributeName].valueCounts();
|
|
12
13
|
for (let index = 0; index < valueCounts.index.length; index++) {
|
|
13
14
|
frequencies[valueCounts.index[index]] = valueCounts.values[index] / totalCount;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
16
|
return frequencies;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
/**
|
|
20
|
-
* BayesianNode is an implementation of a single node in a bayesian network allowing
|
|
21
|
-
* sampling from its conditional distribution.
|
|
19
|
+
* BayesianNode is an implementation of a single node in a bayesian network allowing sampling from its conditional distribution.
|
|
22
20
|
*/
|
|
23
21
|
class BayesianNode {
|
|
24
22
|
/**
|
|
25
|
-
* @param
|
|
26
|
-
* taken from the network definition file
|
|
23
|
+
* @param nodeDefinition Node structure and distributions definition taken from the network definition file.
|
|
27
24
|
*/
|
|
28
25
|
constructor(nodeDefinition) {
|
|
26
|
+
Object.defineProperty(this, "nodeDefinition", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
29
32
|
this.nodeDefinition = nodeDefinition;
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
toJSON() {
|
|
35
|
+
return this.nodeDefinition;
|
|
36
|
+
}
|
|
32
37
|
/**
|
|
33
38
|
* Extracts unconditional probabilities of node values given the values of the parent nodes
|
|
34
|
-
* @param
|
|
35
|
-
* @private
|
|
39
|
+
* @param parentValues Parent nodes values.
|
|
36
40
|
*/
|
|
37
|
-
|
|
41
|
+
getProbabilitiesGivenKnownValues(parentValues = {}) {
|
|
38
42
|
let probabilities = this.nodeDefinition.conditionalProbabilities;
|
|
39
|
-
|
|
40
43
|
for (const parentName of this.parentNames) {
|
|
41
44
|
const parentValue = parentValues[parentName];
|
|
42
45
|
if (parentValue in probabilities.deeper) {
|
|
43
46
|
probabilities = probabilities.deeper[parentValue];
|
|
44
|
-
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
45
49
|
probabilities = probabilities.skip;
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
return probabilities;
|
|
49
53
|
}
|
|
50
|
-
|
|
51
54
|
/**
|
|
52
55
|
* Randomly samples from the given values using the given probabilities
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
*
|
|
56
|
-
* @param {object} probabilities - a dictionary of probabilities from the conditional distribution
|
|
57
|
-
* indexed by the values
|
|
58
|
-
* @private
|
|
56
|
+
* @param possibleValues A list of values to sample from.
|
|
57
|
+
* @param totalProbabilityOfPossibleValues Sum of probabilities of possibleValues in the conditional distribution.
|
|
58
|
+
* @param probabilities A dictionary of probabilities from the conditional distribution, indexed by the values.
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
sampleRandomValueFromPossibilities(possibleValues, totalProbabilityOfPossibleValues, probabilities) {
|
|
61
61
|
let chosenValue = possibleValues[0];
|
|
62
62
|
const anchor = Math.random() * totalProbabilityOfPossibleValues;
|
|
63
63
|
let cumulativeProbability = 0;
|
|
@@ -68,30 +68,26 @@ class BayesianNode {
|
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
|
|
72
71
|
return chosenValue;
|
|
73
72
|
}
|
|
74
|
-
|
|
75
73
|
/**
|
|
76
74
|
* Randomly samples from the conditional distribution of this node given values of parents
|
|
77
|
-
* @param
|
|
75
|
+
* @param parentValues Values of the parent nodes.
|
|
78
76
|
*/
|
|
79
77
|
sample(parentValues = {}) {
|
|
80
|
-
const probabilities = this.
|
|
78
|
+
const probabilities = this.getProbabilitiesGivenKnownValues(parentValues);
|
|
81
79
|
const possibleValues = Object.keys(probabilities);
|
|
82
|
-
|
|
83
|
-
return this._sampleRandomValueFromPossibilities(possibleValues, 1.0, probabilities);
|
|
80
|
+
return this.sampleRandomValueFromPossibilities(possibleValues, 1.0, probabilities);
|
|
84
81
|
}
|
|
85
|
-
|
|
86
82
|
/**
|
|
87
83
|
* Randomly samples from the conditional distribution of this node given restrictions on the possible
|
|
88
84
|
* values and the values of the parents.
|
|
89
|
-
* @param
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
85
|
+
* @param parentValues Values of the parent nodes.
|
|
86
|
+
* @param valuePossibilities List of possible values for this node.
|
|
87
|
+
* @param bannedValues What values of this node are banned.
|
|
92
88
|
*/
|
|
93
89
|
sampleAccordingToRestrictions(parentValues, valuePossibilities, bannedValues) {
|
|
94
|
-
const probabilities = this.
|
|
90
|
+
const probabilities = this.getProbabilitiesGivenKnownValues(parentValues);
|
|
95
91
|
let totalProbability = 0.0;
|
|
96
92
|
const validValues = [];
|
|
97
93
|
const valuesInDistribution = Object.keys(probabilities);
|
|
@@ -102,81 +98,60 @@ class BayesianNode {
|
|
|
102
98
|
totalProbability += probabilities[value];
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return this.
|
|
101
|
+
if (validValues.length === 0)
|
|
102
|
+
return false;
|
|
103
|
+
return this.sampleRandomValueFromPossibilities(validValues, totalProbability, probabilities);
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
/**
|
|
111
106
|
* Sets the conditional probability distribution for this node to match the given data.
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
107
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
108
|
+
* @param possibleParentValues A dictionary of lists of possible values for parent nodes.
|
|
114
109
|
*/
|
|
115
110
|
setProbabilitiesAccordingToData(dataframe, possibleParentValues = {}) {
|
|
116
111
|
this.nodeDefinition.possibleValues = dataframe[this.name].unique().values;
|
|
117
|
-
this.nodeDefinition.conditionalProbabilities = this.
|
|
118
|
-
dataframe,
|
|
119
|
-
possibleParentValues,
|
|
120
|
-
0,
|
|
121
|
-
);
|
|
112
|
+
this.nodeDefinition.conditionalProbabilities = this.recursivelyCalculateConditionalProbabilitiesAccordingToData(dataframe, possibleParentValues, 0);
|
|
122
113
|
}
|
|
123
|
-
|
|
124
114
|
/**
|
|
125
115
|
* Recursively calculates the conditional probability distribution for this node from the data.
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @private
|
|
116
|
+
* @param dataframe A Danfo.js dataframe containing the data.
|
|
117
|
+
* @param possibleParentValues A dictionary of lists of possible values for parent nodes.
|
|
118
|
+
* @param depth Depth of the current recursive call.
|
|
130
119
|
*/
|
|
131
|
-
|
|
120
|
+
recursivelyCalculateConditionalProbabilitiesAccordingToData(dataframe, possibleParentValues, depth) {
|
|
132
121
|
let probabilities = {
|
|
133
122
|
deeper: {},
|
|
134
123
|
};
|
|
135
|
-
|
|
136
124
|
if (depth < this.parentNames.length) {
|
|
137
125
|
const currentParentName = this.parentNames[depth];
|
|
138
126
|
for (const possibleValue of possibleParentValues[currentParentName]) {
|
|
139
127
|
const skip = !dataframe[currentParentName].unique().values.includes(possibleValue);
|
|
140
128
|
let filteredDataframe = dataframe;
|
|
141
129
|
if (!skip) {
|
|
142
|
-
filteredDataframe = dataframe.query(
|
|
143
|
-
column: currentParentName,
|
|
144
|
-
is: '==',
|
|
145
|
-
to: possibleValue,
|
|
146
|
-
});
|
|
130
|
+
filteredDataframe = dataframe.query(dataframe[currentParentName].eq(possibleValue));
|
|
147
131
|
}
|
|
148
|
-
const nextLevel = this.
|
|
149
|
-
filteredDataframe,
|
|
150
|
-
possibleParentValues,
|
|
151
|
-
depth + 1,
|
|
152
|
-
);
|
|
153
|
-
|
|
132
|
+
const nextLevel = this.recursivelyCalculateConditionalProbabilitiesAccordingToData(filteredDataframe, possibleParentValues, depth + 1);
|
|
154
133
|
if (!skip) {
|
|
155
134
|
probabilities.deeper[possibleValue] = nextLevel;
|
|
156
|
-
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
157
137
|
probabilities.skip = nextLevel;
|
|
158
138
|
}
|
|
159
139
|
}
|
|
160
|
-
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
161
142
|
probabilities = getRelativeFrequencies(dataframe, this.name);
|
|
162
143
|
}
|
|
163
|
-
|
|
164
144
|
return probabilities;
|
|
165
145
|
}
|
|
166
|
-
|
|
167
146
|
get name() {
|
|
168
147
|
return this.nodeDefinition.name;
|
|
169
148
|
}
|
|
170
|
-
|
|
171
149
|
get parentNames() {
|
|
172
150
|
return this.nodeDefinition.parentNames;
|
|
173
151
|
}
|
|
174
|
-
|
|
175
152
|
get possibleValues() {
|
|
176
153
|
return this.nodeDefinition.possibleValues;
|
|
177
154
|
}
|
|
178
155
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
BayesianNode,
|
|
182
|
-
};
|
|
156
|
+
exports.BayesianNode = BayesianNode;
|
|
157
|
+
//# sourceMappingURL=bayesian-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bayesian-node.js","sourceRoot":"","sources":["../src/bayesian-node.ts"],"names":[],"mappings":";;;AAEA;;;;EAIE;AACF,SAAS,sBAAsB,CAAC,SAAoB,EAAE,aAAqB;IACvE,MAAM,WAAW,GAA4B,EAAE,CAAC;IAChD,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,WAAW,GAAI,SAAS,CAAC,aAAa,CAAY,CAAC,WAAW,EA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AC,CAAC;SAChE;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IACpC,CAAC;IAED,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;IAC3C,CAAC;IAED,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC;IAC9C,CAAC;CACJ;AAvJD,oCAuJC"}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BayesianNetwork = void 0;
|
|
4
|
+
var bayesian_network_1 = require("./bayesian-network");
|
|
5
|
+
Object.defineProperty(exports, "BayesianNetwork", { enumerable: true, get: function () { return bayesian_network_1.BayesianNetwork; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAA5C,mHAAA,eAAe,OAAA"}
|
package/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"lint:fix": "eslint ./src --ext .js,.jsx --fix",
|
|
38
|
-
"test": "jest --maxWorkers=3 --forceExit"
|
|
39
|
-
},
|
|
40
|
-
"version": "0.1.0-beta.3"
|
|
2
|
+
"name": "generative-bayesian-network",
|
|
3
|
+
"version": "2.0.0-dev.2",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Apify"
|
|
6
|
+
},
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "index.mjs",
|
|
9
|
+
"types": "index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.mjs",
|
|
13
|
+
"require": "./index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/apify/generative-bayesian-network/issues"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"adm-zip": "^0.5.9",
|
|
21
|
+
"danfojs-node": "^1.1.1"
|
|
22
|
+
},
|
|
23
|
+
"description": "An implementation of a bayesian network usable for .",
|
|
24
|
+
"homepage": "https://github.com/apify/generative-bayesian-network#readme",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/apify/generative-bayesian-network.git"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "npm run clean && npm run compile",
|
|
32
|
+
"clean": "rimraf ./dist",
|
|
33
|
+
"compile": "tsc -p tsconfig.build.json && gen-esm-wrapper ./index.js ./index.mjs",
|
|
34
|
+
"copy": "ts-node -T ../../scripts/copy.ts"
|
|
35
|
+
},
|
|
36
|
+
"gitHead": "fcabade6175f3098cf3e314dd5c3542972956652"
|
|
41
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/typescript/lib/lib.esnext.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../../../node_modules/table/dist/types/api.d.ts","../../../node_modules/table/dist/createStream.d.ts","../../../node_modules/table/dist/getBorderCharacters.d.ts","../../../node_modules/table/dist/table.d.ts","../../../node_modules/table/dist/index.d.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/form-data/index.d.ts","../../../node_modules/@types/node-fetch/externals.d.ts","../../../node_modules/@types/node-fetch/index.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/core/strings.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/core/datetime.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/core/series.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/core/frame.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/aggregators/groupby.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/shared/types.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/shared/config.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/core/generic.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/shared/utils.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/shared/tensorflowlib.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/scalers/min.max.scaler.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/scalers/standard.scaler.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/encoders/label.encoder.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/encoders/one.hot.encoder.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/encoders/dummy.encoder.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/concat.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/transformers/merge.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/core/daterange.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/index.d.ts","../../../node_modules/danfojs-node/dist/danfojs-node/src/core/frame.d.ts","../../../node_modules/danfojs-node/dist/danfojs-node/src/streams/csv.stream.transformer.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/io/node/io.csv.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/io/node/io.json.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/io/node/io.excel.d.ts","../../../node_modules/danfojs-node/dist/danfojs-base/io/node/index.d.ts","../../../node_modules/danfojs-node/dist/danfojs-node/src/core/series.d.ts","../../../node_modules/danfojs-node/dist/danfojs-node/src/index.d.ts","../../../node_modules/@types/adm-zip/util.d.ts","../../../node_modules/@types/adm-zip/index.d.ts","../src/bayesian-node.ts","../src/bayesian-network.ts","../src/index.ts","../../../node_modules/@babel/types/lib/index.d.ts","../../../node_modules/@types/babel__generator/index.d.ts","../../../node_modules/@babel/parser/typings/babel-parser.d.ts","../../../node_modules/@types/babel__template/index.d.ts","../../../node_modules/@types/babel__traverse/index.d.ts","../../../node_modules/@types/babel__core/index.d.ts","../../../node_modules/@types/graceful-fs/index.d.ts","../../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../node_modules/@types/istanbul-lib-report/index.d.ts","../../../node_modules/@types/istanbul-reports/index.d.ts","../../../node_modules/chalk/index.d.ts","../../../node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../node_modules/pretty-format/build/types.d.ts","../../../node_modules/pretty-format/build/index.d.ts","../../../node_modules/jest-diff/build/types.d.ts","../../../node_modules/jest-diff/build/diffLines.d.ts","../../../node_modules/jest-diff/build/printDiffs.d.ts","../../../node_modules/jest-diff/build/index.d.ts","../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../node_modules/@types/jest/index.d.ts","../../../node_modules/@types/json-schema/index.d.ts","../../../node_modules/@types/json5/index.d.ts","../../../node_modules/@types/long/index.d.ts","../../../node_modules/@types/minimatch/index.d.ts","../../../node_modules/@types/minimist/index.d.ts","../../../node_modules/@types/normalize-package-data/index.d.ts","../../../node_modules/@types/offscreencanvas/index.d.ts","../../../node_modules/@types/parse-json/index.d.ts","../../../node_modules/@types/prettier/index.d.ts","../../../node_modules/@types/puppeteer/index.d.ts","../../../node_modules/@types/seedrandom/index.d.ts","../../../node_modules/@types/stack-utils/index.d.ts","../../../node_modules/@types/useragent/index.d.ts","../../../node_modules/@types/webgl-ext/index.d.ts","../../../node_modules/@types/webgl2/index.d.ts","../../../node_modules/@types/yargs-parser/index.d.ts","../../../node_modules/@types/yargs/index.d.ts","../../../node_modules/@types/yauzl/index.d.ts"],"fileInfos":[{"version":"f5c28122bee592cfaf5c72ed7bcc47f453b79778ffa6e301f45d21a0970719d4","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","3eb679a56cab01203a1ba7edeade937f6a2a4c718513b2cd930b579807fa9359","aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c",{"version":"3f149f903dd20dfeb7c80e228b659f0e436532de772469980dbd00702cc05cc1","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"cd483c056da900716879771893a3c9772b66c3c88f8943b4205aec738a94b1d0","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"ff667ee99e5a28c3dc5063a3cfd4d3436699e3fb035d4451037da7f567da542a","affectsGlobalScope":true},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true},{"version":"6ea9ab679ea030cf46c16a711a316078e9e02619ebaf07a7fcd16964aba88f2d","affectsGlobalScope":true},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true},{"version":"c37f8a49593a0030eecb51bbfa270e709bec9d79a6cc3bb851ef348d4e6b26f8","affectsGlobalScope":true},"4576b4e61049f5ffd7c9e935cf88832e089265bdb15ffc35077310042cbbbeea","db9694641f29e0f111295746a163919a65a6888134f3371a1ae8d3b0cf0bc4a9","90747c589a64ccb08d72aed5dc235de9aeb725a85c5982514f2c7fb807bcdb42","0f795f93a2af6dc07587a92c1b4e6a9c0cf75d42274c30964a9c12e5d34fe739","e4badf9107d538cf7d598d76c7f1250cec594e31dda987c1c0570e09f52206d0","da246e9a2cedd122d5ba2bbfad53ce2aee3c8666c3c647b6bc2d38b1218ce701","0cba3a5d7b81356222594442753cf90dd2892e5ccfe1d262aaca6896ba6c1380","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"77f0b5c6a193a699c9f7d7fb0578e64e562d271afa740783665d2a827104a873","affectsGlobalScope":true},"e5979905796fe2740d85fbaf4f11f42b7ee1851421afe750823220813421b1af",{"version":"fcdcb42da18dd98dc286b1876dd425791772036012ae61263c011a76b13a190f","affectsGlobalScope":true},"1dab5ab6bcf11de47ab9db295df8c4f1d92ffa750e8f095e88c71ce4c3299628","f71f46ccd5a90566f0a37b25b23bc4684381ab2180bdf6733f4e6624474e1894",{"version":"54e65985a3ee3cec182e6a555e20974ea936fc8b8d1738c14e8ed8a42bd921d4","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","5b30f550565fd0a7524282c81c27fe8534099e2cd26170ca80852308f07ae68d","34e5de87d983bc6aefef8b17658556e3157003e8d9555d3cb098c6bef0b5fbc8","d97cd8a4a42f557fc62271369ed0461c8e50d47b7f9c8ad0b5462f53306f6060","f27371653aded82b2b160f7a7033fb4a5b1534b6f6081ef7be1468f0f15327d3","c762cd6754b13a461c54b59d0ae0ab7aeef3c292c6cf889873f786ee4d8e75c9","f4ea7d5df644785bd9fbf419930cbaec118f0d8b4160037d2339b8e23c059e79",{"version":"bfea28e6162ed21a0aeed181b623dcf250aa79abf49e24a6b7e012655af36d81","affectsGlobalScope":true},"b8aca9d0c81abb02bec9b7621983ae65bde71da6727580070602bd2500a9ce2a","ae97e20f2e10dbeec193d6a2f9cd9a367a1e293e7d6b33b68bacea166afd7792","10d4796a130577d57003a77b95d8723530bbec84718e364aa2129fa8ffba0378","063f53ff674228c190efa19dd9448bcbd540acdbb48a928f4cf3a1b9f9478e43","bf73c576885408d4a176f44a9035d798827cc5020d58284cb18d7573430d9022","7ae078ca42a670445ae0c6a97c029cb83d143d62abd1730efb33f68f0b2c0e82",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"963fe86b2ebd07a34b92b52c6532ab45ec5ccda218a6c477de354fcad2aae0cb","12eea70b5e11e924bb0543aea5eadc16ced318aa26001b453b0d561c2fd0bd1e","08777cd9318d294646b121838574e1dd7acbb22c21a03df84e1f2c87b1ad47f2","08a90bcdc717df3d50a2ce178d966a8c353fd23e5c392fd3594a6e39d9bb6304",{"version":"9f8dd3922db205bc8a362a6b18078708fd699185b11648522159cbf3743561b5","affectsGlobalScope":true},"2a12d2da5ac4c4979401a3f6eaafa874747a37c365e4bc18aa2b171ae134d21b","002b837927b53f3714308ecd96f72ee8a053b8aeb28213d8ec6de23ed1608b66","1dc9c847473bb47279e398b22c740c83ea37a5c88bf66629666e3cf4c5b9f99c","a9e4a5a24bf2c44de4c98274975a1a705a0abbaad04df3557c2d3cd8b1727949","821dcb2b571bf698841d8ec25fde9d5f615ef3958957227962602f9dbfa8d800","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","5f0ed51db151c2cdc4fa3bb0f44ce6066912ad001b607a34e65a96c52eb76248",{"version":"af9771b066ec35ffa1c7db391b018d2469d55e51b98ae95e62b6cbef1b0169ca","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","103d70bfbeb3cd3a3f26d1705bf986322d8738c2c143f38ebb743b1e228d7444","f52fbf64c7e480271a9096763c4882d356b05cab05bf56a64e68a95313cd2ce2","59bdb65f28d7ce52ccfc906e9aaf422f8b8534b2d21c32a27d7819be5ad81df7",{"version":"3a2da34079a2567161c1359316a32e712404b56566c45332ac9dcee015ecce9f","affectsGlobalScope":true},"28a2e7383fd898c386ffdcacedf0ec0845e5d1a86b5a43f25b86bc315f556b79","3aff9c8c36192e46a84afe7b926136d520487155154ab9ba982a8b544ea8fc95","a880cf8d85af2e4189c709b0fea613741649c0e40fffb4360ec70762563d5de0","85bbf436a15bbeda4db888be3062d47f99c66fd05d7c50f0f6473a9151b6a070","9f9c49c95ecd25e0cb2587751925976cf64fd184714cb11e213749c80cf0f927","f0c75c08a71f9212c93a719a25fb0320d53f2e50ca89a812640e08f8ad8c408c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"aee3379fb20741a337a779530cc3e608aba5f34776511033d1d2db7ca45c4193","736097ddbb2903bef918bb3b5811ef1c9c5656f2a73bd39b22a91b9cc2525e50","208bb742e0f201470da121bc73847c74b62cff4172f38ae5949ae77d6c9c6b71","3663d1b50f356656a314e5df169bb51cb9d5fd75905fa703f75db6bb32030568","3dc3b72a8f4c563df5c7458e537b6ea6c66187bf9fa4861619b5cb30a3cb2b1c","0586cfb5a4056ee62c60f727d58a73367e4bbc9c22edd35290784fe92ad18d91","ae6ebb482f2d155b54aea394e8dfc54f12b1f51a298c4dfc7c7a066ef75a2db8","e61f756f59161bc73fb0a0c8349a307eb1d972f5a68bbd74f62a766d4e6fff15","7f82006a244abf1c1889ce5102f08528d99accc4af41fc7e00d8eaba9f1632ec","fe2a2227dc41dedfa3cfb4cd3b3082ec0abb8f3315fdf6a735d8a4949575b448","42e7c25f7ed40d124f52ddba93f616756e0af28a546f70a115b629b840788290","5c82939ee86589dc0f0ee179819cc000b0f82b29111eb4aaa3272565622aa87a","38ef6b9e6fde966d12b4767b5953d8cd2d91d91a41f17d4d6e301d7e5e10a4d4","eb13213caa0daec7883dfd5410703e6bff59a6e25610922444b4b56e3ba01c73","a31ef24d5572c3b810a9d83e2e3ff0844aa5ae8379aa35da3fec07886734bd1e","38238f5148c3e5fd6774049587b1be427f56a33858fe15bac1a1226d5ef73659","0412823b628aba36d768befa95dc87a5459cf555e0c582148b003f37cf8df112","8f3661f770c998f4daccbd391e1bf8ca2281c38626ed5f4aa872e39f192690fd","26394f8ec0157a4272a5f5e25126802dc5602a3a6b13e53420beef863f07adbc","e38579df34197fed1360f8a0c9f45a53de798bd27d93b24b1cf9ac3aeb6946a6","b67a32c2c005699808d916010028a339d3e8f04744ed5fe3be44167ea673d2da","467454238252d6091a9b51744bb89a35897fe9e6ffdfcd0c831b00d1214fb6e4","b019dafd084284e011f997aa4f7ec815028bcc13d13ee3f4880a908059901e9c","abc4a6548691f1c5d80baf1284b951694017f9a3e04b4146aa26d41a904c49c0","060844490d30b34e0bb4e35947194ac0c7bc7238decfe09771620224bbd16ca2","73d606873b27cac730ed51ec493bc0a8f88cb4d31a71384718bd63917671f035","7eb124b879b9cd042a88f6664cea1d23c1c498d660d222e0d0c517e38d189b93","4ac1de6afc5f0ceebcf5062e2769ad84a7061287d56b1396990c0531314e84a5","3b95d3f9f41601e1241f081074e9e710ccd9e290d09af94b5f2b8ab030c827bc","1d4e8370bfca7933a8990ae7fbeb3d973cae8eab52ab8504e07602393b0f5a8e","6f68103a4b7ee58ade1e1394adb7f3b4befb975657889d0ab8b734f0a4f4fbfa","0e0b0baaf6e3845418c2741c9b47478cf6fc086ef8dd5ad4b9ab91499e51de28","ca6e8a62a3e4f5cc3fea6ab45c2e5e128db4d90d81d70547a65047e3f13996f1",{"version":"29e3580b6b483054f690e6447a0e63fb4bd292dc50175abb5ac4b2a26f15e2a9","signature":"3fcb1d1dda1c7db768ba67903b685757c01b68e061f609989d27de383fc01f5b"},{"version":"fa79e8211fca3c20583742e6fb41de3b611df8e8756cc49f30c5d56c181941bb","signature":"98e952c28558e6c57598e0ad2f7a5f9271c87f8f6875a7daed7acbfcd57b0a3d"},"b36fed136ab154cc5f53c60b33b1b0a8615d2ff5ea2a57d806fe2be858e4fb97","e432b56911b58550616fc4d54c1606f65fe98c74875b81d74601f5f965767c60","cc957354aa3c94c9961ebf46282cfde1e81d107fc5785a61f62c67f1dd3ac2eb","a46a2e69d12afe63876ec1e58d70e5dbee6d3e74132f4468f570c3d69f809f1c","93de1c6dab503f053efe8d304cb522bb3a89feab8c98f307a674a4fae04773e9","fc72135da24040641388fb5f2c2a7a99aa5b962c0fa125bd96fabeec63dd2e63","5426e62886b7be7806312d31a00e8f7dccd6fe63ba9bbefe99ee2eab29cc48a3","3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba","8b06ac3faeacb8484d84ddb44571d8f410697f98d7bfa86c0fda60373a9f5215","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","d8aab31ba8e618cc3eea10b0945de81cb93b7e8150a013a482332263b9305322","462bccdf75fcafc1ae8c30400c9425e1a4681db5d605d1a0edb4f990a54d8094","5923d8facbac6ecf7c84739a5c701a57af94a6f6648d6229a6c768cf28f0f8cb","7adecb2c3238794c378d336a8182d4c3dd2c4fa6fa1785e2797a3db550edea62","dc12dc0e5aa06f4e1a7692149b78f89116af823b9e1f1e4eae140cd3e0e674e6","1bfc6565b90c8771615cd8cfcf9b36efc0275e5e83ac7d9181307e96eb495161","8a8a96898906f065f296665e411f51010b51372fa260d5373bf9f64356703190","7f82ef88bdb67d9a850dd1c7cd2d690f33e0f0acd208e3c9eba086f3670d4f73",{"version":"4564f780fd20582c57ae218a4cd017717181ab0e228639d905ef054288655b5e","affectsGlobalScope":true},"f3e604694b624fa3f83f6684185452992088f5efb2cf136b62474aa106d6f1b6","96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","0e60e0cbf2283adfd5a15430ae548cd2f662d581b5da6ecd98220203e7067c70","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","209e814e8e71aec74f69686a9506dd7610b97ab59dcee9446266446f72a76d05","6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a",{"version":"fc35a74dd14f55d6fea9e5a4804ae812d559519352fa3836eb5f5555a64dd0ac","affectsGlobalScope":true},"2b8264b2fefd7367e0f20e2c04eed5d3038831fe00f5efbc110ff0131aab899b","f1d8b21cdf08726021c8cce0cd6159486236cf1d633eeabbc435b5b2e5869c2e","dd432baba70577d8ef35db945b4e5e536013d73e3e8595683aafc277bf226f75","1268e311431a3b23db043921bb743be87f3ec0acb2d675564d7961620f4569e0","b0d10e46cfe3f6c476b69af02eaa38e4ccc7430221ce3109ae84bb9fb8282298","48220b3395376205a0938f3f23c363a1084e86534caaec82b885efb1e0407408",{"version":"49febed15cc962e5823a8b0781f0fcd8f5f63f6bcadcdda5e30e4d173ce738d4","affectsGlobalScope":true},{"version":"6e0d9ddfdf1488763a9f32c960ddf6de227421099266c6e2a3c580a7478547be","affectsGlobalScope":true},"70e9a18da08294f75bf23e46c7d69e67634c0765d355887b9b41f0d959e1426e","105b9a2234dcb06ae922f2cd8297201136d416503ff7d16c72bfc8791e9895c1","65dfa4bc49ccd1355789abb6ae215b302a5b050fdee9651124fe7e826f33113c"],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"importsNotUsedAsValues":0,"module":1,"newLine":1,"noEmitHelpers":true,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","preserveConstEnums":true,"removeComments":false,"skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"useDefineForClassFields":true},"fileIdsList":[[103,146],[103],[76,103,110,141],[103,146,147,148,149,150],[103,146,148],[76,103,110],[103,153],[103,154],[103,159,164],[78,102,103,110,111,112],[60,103],[63,103],[64,69,103],[65,75,76,83,92,102,103],[65,66,75,83,103],[67,103],[68,69,76,84,103],[69,92,99,103],[70,72,75,83,103],[71,103],[72,73,103],[74,75,103],[75,103],[75,76,77,92,102,103],[75,76,77,92,103],[103,107],[78,83,92,102,103],[75,76,78,79,83,92,99,102,103],[78,80,92,99,102,103],[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109],[75,81,103],[82,102,103],[72,75,83,92,103],[84,103],[85,103],[63,86,103],[87,101,103,107],[88,103],[89,103],[75,90,103],[90,91,103,105],[75,92,93,94,103],[92,94,103],[92,93,103],[95,103],[96,103],[75,97,98,103],[97,98,103],[69,83,92,99,103],[100,103],[83,101,103],[64,78,89,102,103],[69,103],[92,103,104],[103,105],[103,106],[64,69,75,77,86,92,102,103,105,107],[92,103,108],[65,103,110],[103,181],[75,92,103,110],[103,116,117,119],[103,116,119],[103,116,118,119,121],[103,119,120],[103,114,115,117,119,121],[103,116],[103,114,115,116,117,120,121,122,123,124,125,126,127,128,129,130,131],[103,135,136,137],[92,103,110,119,132],[103,119,132],[59,103,119],[59,103,113,114,115,116,117,118],[103,116,117],[103,116,123],[103,116,117,123],[103,117],[103,117,119],[103,132,133,134,138,139],[92,103,110,119,133],[78,92,103,110],[103,157,160],[103,157,160,161,162],[103,159],[103,156,163],[103,158],[55,103],[55,56,57,58,103],[54,103,140,142,143],[54,103,140],[54,103,144],[140]],"referencedMap":[[148,1],[146,2],[142,3],[141,2],[151,4],[147,1],[149,5],[150,1],[152,6],[153,2],[154,7],[155,8],[165,9],[166,2],[167,2],[168,2],[169,2],[170,2],[112,2],[113,10],[60,11],[61,11],[63,12],[64,13],[65,14],[66,15],[67,16],[68,17],[69,18],[70,19],[71,20],[72,21],[73,21],[74,22],[75,23],[76,24],[77,25],[62,26],[109,2],[78,27],[79,28],[80,29],[110,30],[81,31],[82,32],[83,33],[84,34],[85,35],[86,36],[87,37],[88,38],[89,39],[90,40],[91,41],[92,42],[94,43],[93,44],[95,45],[96,46],[97,47],[98,48],[99,49],[100,50],[101,51],[102,52],[103,53],[104,54],[105,55],[106,56],[107,57],[108,58],[171,2],[172,2],[173,2],[174,2],[175,59],[176,2],[177,2],[178,2],[179,2],[180,2],[181,2],[182,60],[183,61],[156,2],[118,62],[131,2],[115,63],[117,64],[121,65],[116,66],[114,67],[132,68],[138,69],[135,70],[137,71],[136,71],[120,72],[123,2],[119,73],[122,71],[129,74],[128,74],[126,75],[127,76],[130,77],[124,76],[125,76],[133,78],[139,63],[140,79],[134,80],[111,81],[157,2],[161,82],[163,83],[162,82],[160,84],[164,85],[159,86],[158,2],[56,87],[57,87],[59,88],[58,87],[55,2],[54,2],[11,2],[13,2],[12,2],[2,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[3,2],[4,2],[25,2],[22,2],[23,2],[24,2],[26,2],[27,2],[28,2],[5,2],[29,2],[30,2],[31,2],[32,2],[6,2],[33,2],[34,2],[35,2],[36,2],[7,2],[37,2],[42,2],[43,2],[38,2],[39,2],[40,2],[41,2],[8,2],[47,2],[44,2],[45,2],[46,2],[48,2],[9,2],[49,2],[50,2],[51,2],[52,2],[1,2],[10,2],[53,2],[144,89],[143,90],[145,91]],"exportedModulesMap":[[148,1],[146,2],[142,3],[141,2],[151,4],[147,1],[149,5],[150,1],[152,6],[153,2],[154,7],[155,8],[165,9],[166,2],[167,2],[168,2],[169,2],[170,2],[112,2],[113,10],[60,11],[61,11],[63,12],[64,13],[65,14],[66,15],[67,16],[68,17],[69,18],[70,19],[71,20],[72,21],[73,21],[74,22],[75,23],[76,24],[77,25],[62,26],[109,2],[78,27],[79,28],[80,29],[110,30],[81,31],[82,32],[83,33],[84,34],[85,35],[86,36],[87,37],[88,38],[89,39],[90,40],[91,41],[92,42],[94,43],[93,44],[95,45],[96,46],[97,47],[98,48],[99,49],[100,50],[101,51],[102,52],[103,53],[104,54],[105,55],[106,56],[107,57],[108,58],[171,2],[172,2],[173,2],[174,2],[175,59],[176,2],[177,2],[178,2],[179,2],[180,2],[181,2],[182,60],[183,61],[156,2],[118,62],[131,2],[115,63],[117,64],[121,65],[116,66],[114,67],[132,68],[138,69],[135,70],[137,71],[136,71],[120,72],[123,2],[119,73],[122,71],[129,74],[128,74],[126,75],[127,76],[130,77],[124,76],[125,76],[133,78],[139,63],[140,79],[134,80],[111,81],[157,2],[161,82],[163,83],[162,82],[160,84],[164,85],[159,86],[158,2],[56,87],[57,87],[59,88],[58,87],[55,2],[54,2],[11,2],[13,2],[12,2],[2,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[3,2],[4,2],[25,2],[22,2],[23,2],[24,2],[26,2],[27,2],[28,2],[5,2],[29,2],[30,2],[31,2],[32,2],[6,2],[33,2],[34,2],[35,2],[36,2],[7,2],[37,2],[42,2],[43,2],[38,2],[39,2],[40,2],[41,2],[8,2],[47,2],[44,2],[45,2],[46,2],[48,2],[9,2],[49,2],[50,2],[51,2],[52,2],[1,2],[10,2],[53,2],[144,92],[143,92],[145,91]],"semanticDiagnosticsPerFile":[148,146,142,141,151,147,149,150,152,153,154,155,165,166,167,168,169,170,112,113,60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,62,109,78,79,80,110,81,82,83,84,85,86,87,88,89,90,91,92,94,93,95,96,97,98,99,100,101,102,103,104,105,106,107,108,171,172,173,174,175,176,177,178,179,180,181,182,183,156,118,131,115,117,121,116,114,132,138,135,137,136,120,123,119,122,129,128,126,127,130,124,125,133,139,140,134,111,157,161,163,162,160,164,159,158,56,57,59,58,55,54,11,13,12,2,14,15,16,17,18,19,20,21,3,4,25,22,23,24,26,27,28,5,29,30,31,32,6,33,34,35,36,7,37,42,43,38,39,40,41,8,47,44,45,46,48,9,49,50,51,52,1,10,53,144,143,145]},"version":"4.7.2"}
|
package/src/bayesian-network.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
|
|
3
|
-
const { BayesianNode } = require('./bayesian-node');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* BayesianNetwork is an implementation of a bayesian network capable of randomly sampling from the distribution
|
|
7
|
-
* represented by the network.
|
|
8
|
-
*/
|
|
9
|
-
class BayesianNetwork {
|
|
10
|
-
/**
|
|
11
|
-
* @param {object} networkDefinition - object defining the network structure and distributions
|
|
12
|
-
*/
|
|
13
|
-
constructor(networkDefinition) {
|
|
14
|
-
this.nodesInSamplingOrder = networkDefinition.nodes.map((nodeDefinition) => new BayesianNode(nodeDefinition));
|
|
15
|
-
this.nodesByName = {};
|
|
16
|
-
for (const node of this.nodesInSamplingOrder) {
|
|
17
|
-
this.nodesByName[node.name] = node;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Randomly samples from the distribution represented by the bayesian network.
|
|
23
|
-
* @param {object} inputValues - node values that are known already
|
|
24
|
-
*/
|
|
25
|
-
generateSample(inputValues = {}) {
|
|
26
|
-
const sample = inputValues;
|
|
27
|
-
for (const node of this.nodesInSamplingOrder) {
|
|
28
|
-
if (!(node.name in sample)) {
|
|
29
|
-
sample[node.name] = node.sample(sample);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return sample;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Randomly samples from the distribution represented by the bayesian network,
|
|
38
|
-
* making sure the sample is consistent with the provided restrictions on value possibilities.
|
|
39
|
-
* Returns false if no such sample can be generated.
|
|
40
|
-
* @param {object} valuePossibilities - a dictionary of lists of possible values for nodes
|
|
41
|
-
* (if a node isn't present in the dictionary, all values are possible)
|
|
42
|
-
*/
|
|
43
|
-
generateConsistentSampleWhenPossible(valuePossibilities) {
|
|
44
|
-
return this._recursivelyGenerateConsistentSampleWhenPossible({}, valuePossibilities, 0);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Recursively generates a random sample consistent with the given restrictions on possible values.
|
|
49
|
-
* @param {object} sampleSoFar - node values that are known already
|
|
50
|
-
* @param {object} valuePossibilities - a dictionary of lists of possible values for nodes
|
|
51
|
-
* (if a node isn't present in the dictionary, all values are possible)
|
|
52
|
-
* @param {number} depth - in what depth of the recursion this function call is,
|
|
53
|
-
* specifies what node this function call is sampling
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
_recursivelyGenerateConsistentSampleWhenPossible(sampleSoFar, valuePossibilities, depth) {
|
|
57
|
-
const bannedValues = [];
|
|
58
|
-
const node = this.nodesInSamplingOrder[depth];
|
|
59
|
-
|
|
60
|
-
let sampleValue;
|
|
61
|
-
do {
|
|
62
|
-
sampleValue = node.sampleAccordingToRestrictions(sampleSoFar, valuePossibilities[node.name], bannedValues);
|
|
63
|
-
|
|
64
|
-
if (!sampleValue) break;
|
|
65
|
-
|
|
66
|
-
sampleSoFar[node.name] = sampleValue;
|
|
67
|
-
|
|
68
|
-
if (depth + 1 < this.nodesInSamplingOrder.length) {
|
|
69
|
-
const sample = this._recursivelyGenerateConsistentSampleWhenPossible(sampleSoFar, valuePossibilities, depth + 1);
|
|
70
|
-
if (sample) {
|
|
71
|
-
return sample;
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
return sampleSoFar;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
bannedValues.push(sampleValue);
|
|
78
|
-
} while (sampleValue);
|
|
79
|
-
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Sets the conditional probability distributions of this network's nodes to match the given data.
|
|
85
|
-
* @param {object} dataframe - a Danfo.js dataframe containing the data
|
|
86
|
-
*/
|
|
87
|
-
setProbabilitiesAccordingToData(dataframe) {
|
|
88
|
-
this.nodesInSamplingOrder.forEach((node) => {
|
|
89
|
-
const possibleParentValues = {};
|
|
90
|
-
for (const parentName of node.parentNames) {
|
|
91
|
-
possibleParentValues[parentName] = this.nodesByName[parentName].possibleValues;
|
|
92
|
-
}
|
|
93
|
-
node.setProbabilitiesAccordingToData(dataframe, possibleParentValues);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Saves the network definition to the specified file path to be used later.
|
|
99
|
-
* @param {string} networkDefinitionFilePath - a file path where the network definition should be saved
|
|
100
|
-
*/
|
|
101
|
-
saveNetworkDefinition(networkDefinitionFilePath) {
|
|
102
|
-
const network = {
|
|
103
|
-
nodes: this.nodesInSamplingOrder.map((node) => node.nodeDefinition),
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
fs.writeFileSync(networkDefinitionFilePath, JSON.stringify(network));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
module.exports = {
|
|
111
|
-
BayesianNetwork,
|
|
112
|
-
};
|
package/src/main.js
DELETED