BNLearner.setDatabaseWeight

BNLearner.setDatabaseWeight(new_weight)

Set the database weight which is given as an equivalent sample size.

Warning

The same weight is assigned to all the rows of the learning database so that the sum of their weights is equal to the value of the parameter weight.

Parameters:
  • weight (float) – the database weight

  • new_weight (float)

Return type:

None

Example

import pyagrum as gum

with open("data.csv", "w") as f:  # C is mostly "A or B"
  f.write("A,B,C\n" + "0,0,0\n0,1,1\n1,0,1\n1,1,1\n" * 40 + "0,0,1\n0,1,0\n1,0,0\n1,1,0\n" * 5)
learner = gum.BNLearner("data.csv")
learner.setDatabaseWeight(18.0)  # 0.1 for each of the 180 rows
round(learner.databaseWeight(), 4), round(learner.recordWeight(0), 4)
# (18.0, 0.1)

Class

BNLearner