-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// source: https://www.bnlearn.com/bnrepository/discrete-small.html#asia | ||
network unknown { | ||
} | ||
variable asia { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable tub { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable smoke { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable lung { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable bronc { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable either { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable xray { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
variable dysp { | ||
type discrete [ 2 ] { yes, no }; | ||
} | ||
probability ( asia ) { | ||
table 0.01, 0.99; | ||
} | ||
probability ( tub | asia ) { | ||
(yes) 0.05, 0.95; | ||
(no) 0.01, 0.99; | ||
} | ||
probability ( smoke ) { | ||
table 0.5, 0.5; | ||
} | ||
probability ( lung | smoke ) { | ||
(yes) 0.1, 0.9; | ||
(no) 0.01, 0.99; | ||
} | ||
probability ( bronc | smoke ) { | ||
(yes) 0.6, 0.4; | ||
(no) 0.3, 0.7; | ||
} | ||
probability ( either | lung, tub ) { | ||
(yes, yes) 1.0, 0.0; | ||
(no, yes) 1.0, 0.0; | ||
(yes, no) 1.0, 0.0; | ||
(no, no) 0.0, 1.0; | ||
} | ||
probability ( xray | either ) { | ||
(yes) 0.98, 0.02; | ||
(no) 0.05, 0.95; | ||
} | ||
probability ( dysp | bronc, either ) { | ||
(yes, yes) 0.9, 0.1; | ||
(no, yes) 0.7, 0.3; | ||
(yes, no) 0.8, 0.2; | ||
(no, no) 0.1, 0.9; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// source: https://www.bnlearn.com/bnrepository/discrete-small.html#cancer | ||
network unknown { | ||
} | ||
variable Pollution { | ||
type discrete [ 2 ] { low, high }; | ||
} | ||
variable Smoker { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
variable Cancer { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
variable Xray { | ||
type discrete [ 2 ] { positive, negative }; | ||
} | ||
variable Dyspnoea { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
probability ( Pollution ) { | ||
table 0.9, 0.1; | ||
} | ||
probability ( Smoker ) { | ||
table 0.3, 0.7; | ||
} | ||
probability ( Cancer | Pollution, Smoker ) { | ||
(low, True) 0.03, 0.97; | ||
(high, True) 0.05, 0.95; | ||
(low, False) 0.001, 0.999; | ||
(high, False) 0.02, 0.98; | ||
} | ||
probability ( Xray | Cancer ) { | ||
(True) 0.9, 0.1; | ||
(False) 0.2, 0.8; | ||
} | ||
probability ( Dyspnoea | Cancer ) { | ||
(True) 0.65, 0.35; | ||
(False) 0.3, 0.7; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// source: https://www.bnlearn.com/bnrepository/discrete-small.html#earthquake | ||
network unknown { | ||
} | ||
variable Burglary { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
variable Earthquake { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
variable Alarm { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
variable JohnCalls { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
variable MaryCalls { | ||
type discrete [ 2 ] { True, False }; | ||
} | ||
probability ( Burglary ) { | ||
table 0.01, 0.99; | ||
} | ||
probability ( Earthquake ) { | ||
table 0.02, 0.98; | ||
} | ||
probability ( Alarm | Burglary, Earthquake ) { | ||
(True, True) 0.95, 0.05; | ||
(False, True) 0.29, 0.71; | ||
(True, False) 0.94, 0.06; | ||
(False, False) 0.001, 0.999; | ||
} | ||
probability ( JohnCalls | Alarm ) { | ||
(True) 0.9, 0.1; | ||
(False) 0.05, 0.95; | ||
} | ||
probability ( MaryCalls | Alarm ) { | ||
(True) 0.7, 0.3; | ||
(False) 0.01, 0.99; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// source: https://www.bnlearn.com/bnrepository/discrete-small.html#sachs | ||
network unknown { | ||
} | ||
variable Akt { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable Erk { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable Jnk { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable Mek { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable P38 { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable PIP2 { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable PIP3 { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable PKA { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable PKC { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable Plcg { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
variable Raf { | ||
type discrete [ 3 ] { LOW, AVG, HIGH }; | ||
} | ||
probability ( Akt | Erk, PKA ) { | ||
(LOW, LOW) 0.6721176592, 0.3277794919, 0.0001028489; | ||
(AVG, LOW) 0.3349505840, 0.6648697215, 0.0001796945; | ||
(HIGH, LOW) 7.682262e-05, 1.183068e-01, 8.816163e-01; | ||
(LOW, AVG) 0.62038586, 0.37950262, 0.00011152; | ||
(AVG, AVG) 0.8214081840, 0.1782019687, 0.0003898473; | ||
(HIGH, AVG) 0.177105936, 0.813732581, 0.009161483; | ||
(LOW, HIGH) 0.9750859107, 0.0240549828, 0.0008591065; | ||
(AVG, HIGH) 9.483619e-01, 5.154733e-02, 9.075234e-05; | ||
(HIGH, HIGH) 0.1703412073, 0.8293963255, 0.0002624672; | ||
} | ||
probability ( Erk | Mek, PKA ) { | ||
(LOW, LOW) 0.85051343, 0.13872433, 0.01076224; | ||
(AVG, LOW) 0.3870326, 0.4836913, 0.1292761; | ||
(HIGH, LOW) 0.008682883, 0.187958884, 0.803358233; | ||
(LOW, AVG) 0.1177122, 0.6919357, 0.1903521; | ||
(AVG, AVG) 0.04895789, 0.72823961, 0.22280250; | ||
(HIGH, AVG) 0.001153403, 0.748558247, 0.250288351; | ||
(LOW, HIGH) 0.07405991, 0.70044614, 0.22549395; | ||
(AVG, HIGH) 0.003663004, 0.102564103, 0.893772894; | ||
(HIGH, HIGH) 0.03333333, 0.03333333, 0.93333333; | ||
} | ||
probability ( Jnk | PKA, PKC ) { | ||
(LOW, LOW) 0.2899262, 0.2457641, 0.4643097; | ||
(AVG, LOW) 5.766701e-01, 4.232872e-01, 4.271314e-05; | ||
(HIGH, LOW) 9.961240e-01, 3.806755e-03, 6.921373e-05; | ||
(LOW, AVG) 0.5794436587, 0.4203206035, 0.0002357379; | ||
(AVG, AVG) 6.129037e-01, 3.870808e-01, 1.543138e-05; | ||
(HIGH, AVG) 0.8623005877, 0.1368597817, 0.0008396306; | ||
(LOW, HIGH) 0.00456621, 0.99086758, 0.00456621; | ||
(AVG, HIGH) 0.04468980, 0.93495569, 0.02035451; | ||
(HIGH, HIGH) 0.155367232, 0.841807910, 0.002824859; | ||
} | ||
probability ( Mek | PKA, PKC, Raf ) { | ||
(LOW, LOW, LOW) 0.7451772095, 0.2545984747, 0.0002243158; | ||
(AVG, LOW, LOW) 7.576915e-01, 2.422767e-01, 3.181572e-05; | ||
(HIGH, LOW, LOW) 9.977281e-01, 2.244485e-03, 2.737176e-05; | ||
(LOW, AVG, LOW) 0.7066581578, 0.2931291215, 0.0002127207; | ||
(AVG, AVG, LOW) 7.148153e-01, 2.851753e-01, 9.338376e-06; | ||
(HIGH, AVG, LOW) 0.9689835575, 0.0306427504, 0.0003736921; | ||
(LOW, HIGH, LOW) 0.854385965, 0.143859649, 0.001754386; | ||
(AVG, HIGH, LOW) 8.256463e-01, 1.743254e-01, 2.831337e-05; | ||
(HIGH, HIGH, LOW) 0.725950783, 0.272930649, 0.001118568; | ||
(LOW, LOW, AVG) 0.3846008, 0.1231368, 0.4922624; | ||
(AVG, LOW, AVG) 0.343172087, 0.649403298, 0.007424615; | ||
(HIGH, LOW, AVG) 0.9996370895, 0.0001814553, 0.0001814553; | ||
(LOW, AVG, AVG) 0.2692763938, 0.7304863582, 0.0002372479; | ||
(AVG, AVG, AVG) 0.27465766, 0.72002723, 0.00531511; | ||
(HIGH, AVG, AVG) 0.854385965, 0.143859649, 0.001754386; | ||
(LOW, HIGH, AVG) 0.01190476, 0.97619048, 0.01190476; | ||
(AVG, HIGH, AVG) 0.1054112554, 0.8943722944, 0.0002164502; | ||
(HIGH, HIGH, AVG) 0.006060606, 0.987878788, 0.006060606; | ||
(LOW, LOW, HIGH) 0.262181426, 0.001450275, 0.736368299; | ||
(AVG, LOW, HIGH) 0.8652899, 0.1010029, 0.0337072; | ||
(HIGH, LOW, HIGH) 0.9361046959, 0.0007698229, 0.0631254811; | ||
(LOW, AVG, HIGH) 0.85065617, 0.10656168, 0.04278215; | ||
(AVG, AVG, HIGH) 0.2814957, 0.5851161, 0.1333882; | ||
(HIGH, AVG, HIGH) 0.498470948, 0.498470948, 0.003058104; | ||
(LOW, HIGH, HIGH) 0.3333333, 0.3333333, 0.3333333; | ||
(AVG, HIGH, HIGH) 0.3333333, 0.3333333, 0.3333333; | ||
(HIGH, HIGH, HIGH) 0.3333333, 0.3333333, 0.3333333; | ||
} | ||
probability ( P38 | PKA, PKC ) { | ||
(LOW, LOW) 0.30691159, 0.06458648, 0.62850193; | ||
(AVG, LOW) 0.919186742, 0.078464036, 0.002349223; | ||
(HIGH, LOW) 0.80737818, 0.09163898, 0.10098283; | ||
(LOW, AVG) 0.6558227251, 0.3439415370, 0.0002357379; | ||
(AVG, AVG) 8.149777e-01, 1.850069e-01, 1.543138e-05; | ||
(HIGH, AVG) 0.3862301, 0.1595298, 0.4542401; | ||
(LOW, HIGH) 0.86757991, 0.12785388, 0.00456621; | ||
(AVG, HIGH) 0.80313955, 0.19272946, 0.00413099; | ||
(HIGH, HIGH) 0.765536723, 0.231638418, 0.002824859; | ||
} | ||
probability ( PIP2 | PIP3, Plcg ) { | ||
(LOW, LOW) 9.967915e-01, 3.169817e-03, 3.865631e-05; | ||
(AVG, LOW) 9.867112e-01, 1.326991e-02, 1.887612e-05; | ||
(HIGH, LOW) 0.872401162, 0.120070734, 0.007528104; | ||
(LOW, AVG) 0.997890295, 0.001054852, 0.001054852; | ||
(AVG, AVG) 0.9571651090, 0.0424454829, 0.0003894081; | ||
(HIGH, AVG) 0.52180956, 0.46245517, 0.01573528; | ||
(LOW, HIGH) 0.2218092, 0.4936493, 0.2845415; | ||
(AVG, HIGH) 0.07672787, 0.39110315, 0.53216898; | ||
(HIGH, HIGH) 0.02641691, 0.05235351, 0.92122959; | ||
} | ||
probability ( PIP3 | Plcg ) { | ||
(LOW) 0.2184310, 0.4473238, 0.3342453; | ||
(AVG) 0.07796694, 0.21120158, 0.71083148; | ||
(HIGH) 0.4237055, 0.4396535, 0.1366411; | ||
} | ||
probability ( PKA | PKC ) { | ||
(LOW) 0.3864255, 0.3794243, 0.2341501; | ||
(AVG) 0.06039638, 0.92264651, 0.01695712; | ||
(HIGH) 0.01577014, 0.95873839, 0.02549147; | ||
} | ||
probability ( PKC ) { | ||
table 0.42313152, 0.48163920, 0.09522928; | ||
} | ||
probability ( Plcg ) { | ||
table 0.81213356, 0.08337962, 0.10448682; | ||
} | ||
probability ( Raf | PKA, PKC ) { | ||
(LOW, LOW) 0.06232176, 0.14724878, 0.79042946; | ||
(AVG, LOW) 0.4475056, 0.3125747, 0.2399197; | ||
(HIGH, LOW) 0.84288483, 0.12714563, 0.02996955; | ||
(LOW, AVG) 0.3694012, 0.3312117, 0.2993871; | ||
(AVG, AVG) 0.55082326, 0.39291391, 0.05626283; | ||
(HIGH, AVG) 0.74895046, 0.15952981, 0.09151973; | ||
(LOW, HIGH) 0.86757991, 0.12785388, 0.00456621; | ||
(AVG, HIGH) 8.842572e-01, 1.156677e-01, 7.510891e-05; | ||
(HIGH, HIGH) 0.841807910, 0.155367232, 0.002824859; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ch/idsia/crema/model/io/bif/BIFAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ch.idsia.crema.model.io.bif; | ||
|
||
/** | ||
* Author: Claudio "Dna" Bonesana | ||
* Project: crema | ||
* Date: 25.01.2021 10:41 | ||
*/ | ||
class BIFAttribute { | ||
String name; | ||
String value; | ||
|
||
@Override | ||
public String toString() { | ||
return " " + name + " " + value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ch.idsia.crema.model.io.bif; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Author: Claudio "Dna" Bonesana | ||
* Project: crema | ||
* Date: 25.01.2021 10:41 | ||
*/ | ||
class BIFBlock { | ||
String type; | ||
String name; | ||
List<BIFAttribute> attributes = new ArrayList<>(); | ||
|
||
@Override | ||
public String toString() { | ||
return type + " " + String.join(" ", name) + " {\n" + | ||
attributes.stream().map(Object::toString).collect(Collectors.joining("\n ")) + | ||
"\n}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ch.idsia.crema.model.io.bif; | ||
|
||
import ch.idsia.crema.factor.bayesian.BayesianFactor; | ||
import ch.idsia.crema.model.graphical.BayesianNetwork; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Author: Claudio "Dna" Bonesana | ||
* Project: crema | ||
* Date: 25.01.2021 09:38 | ||
*/ | ||
public class BIFObject { | ||
|
||
public String name; | ||
public BayesianNetwork network = new BayesianNetwork(); | ||
public BayesianFactor[] factors = null; | ||
|
||
public Map<String, Integer> variableName = new HashMap<>(); | ||
public Map<String, Integer> variableStates = new HashMap<>(); | ||
public Map<String, BayesianFactor> variableFactors = new HashMap<>(); | ||
|
||
} |
Oops, something went wrong.