eu.amidst.core.variables.Variables.newGaussianVariable()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中eu.amidst.core.variables.Variables.newGaussianVariable()方法的一些代码示例,展示了Variables.newGaussianVariable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Variables.newGaussianVariable()方法的具体详情如下:
包路径:eu.amidst.core.variables.Variables
类名称:Variables
方法名:newGaussianVariable

Variables.newGaussianVariable介绍

暂无

代码示例

代码示例来源:origin: amidst/toolbox

/**
 * Builds the graph
 */
@Override
protected void buildDAG() {
  List<Variable> observableVariables = new ArrayList<>();
  List<Variable> latentVariables = new ArrayList<>();
  vars.forEach(observableVariables::add);
  Variable discreteLatentVar = vars.newMultinomialVariable("DiscreteLatentVar",numberOfStatesLatentDiscreteVar);
  IntStream.range(0,numberOfLatentVariables).forEach(i -> {
    Variable latentVar = vars.newGaussianVariable("LatentVar" + i);
    latentVariables.add(latentVar);
  });
  dag = new DAG(vars);
  for (Variable variable : observableVariables) {
    dag.getParentSet(variable).addParent(discreteLatentVar);
    latentVariables.forEach(latentVariable -> dag.getParentSet(variable).addParent(latentVariable));
  }
}

代码示例来源:origin: amidst/toolbox

/**
 * Builds the DAG
 */
@Override
protected void buildDAG() {
  List<Variable> observableVariables = new ArrayList<>();
  List<Variable> latentVariables = new ArrayList<>();
  vars.forEach(observableVariables::add);
  IntStream.range(0,numberOfLatentVariables).forEach(i -> {
    Variable latentVar = vars.newGaussianVariable("LatentVar" + i);
    latentVariables.add(latentVar);
  });
  dag = new DAG(vars);
  for (Variable variable : observableVariables) {
    latentVariables.forEach(latentVariable -> dag.getParentSet(variable).addParent(latentVariable));
  }
  IntStream.range(0,numberOfLatentVariables).forEach(i -> {
    Variable latentVarChildren = vars.getVariableByName("LatentVar" + i);
    IntStream.range(0,i).forEach(j -> {
      Variable latentVarParent = vars.getVariableByName("LatentVar" + j);
      dag.getParentSet(latentVarChildren).addParent(latentVarParent);
    });
  });
}

代码示例来源:origin: amidst/toolbox

/**
 * Builds the DAG over the set of variables given with the naive Bayes structure
 */
@Override
protected void buildDAG() {
  //Obtain the predictive attributes
  List<Variable> attrVars = vars.getListOfVariables().stream()
      .filter(v -> !v.equals(classVar)).collect(Collectors.toList());
  //Create the hidden variabels
  hiddenMultinomial = vars.newMultinomialVariable("M", numStatesHidden);
  contHiddenList = new ArrayList<Variable>();
  for(int i=0; i<numContinuousHidden; i++) {
    contHiddenList.add(vars.newGaussianVariable("Z"+Integer.toString(i)));
  }
  dag = new DAG(vars);
  //arcs from the class to the hidden variables
  dag.getParentSet(hiddenMultinomial).addParent(classVar);
  contHiddenList.stream().forEach(z -> dag.getParentSet(z).addParent(classVar));
  //arcs from the hidden vars to each attribute
  attrVars.stream().forEach(x->dag.getParentSet(x).addParent(hiddenMultinomial));
  for (Variable z : contHiddenList) {
    attrVars.stream().forEach(x->dag.getParentSet(x).addParent(z));
  }
}
/*

代码示例来源:origin: amidst/toolbox

public static void main(String[] args) throws Exception {

    //We first create an empty Variables object
    Variables variables = new Variables();

    //We invoke the "new" methods of the object Variables to create new variables.
    //Now we create a Gaussian variables
    Variable gaussianVar = variables.newGaussianVariable("Gaussian");

    //Now we create a Multinomial variable with two states
    Variable multinomialVar = variables.newMultinomialVariable("Multinomial", 2);

    //Now we create a Multinomial variable with two states: TRUE and FALSE
    Variable multinomialVar2 = variables.newMultinomialVariable("Multinomial2", Arrays.asList("TRUE, FALSE"));

    //For Multinomial variables we can iterate over their different states
    FiniteStateSpace states = multinomialVar2.getStateSpaceType();
    states.getStatesNames().forEach(System.out::println);

    //Variable objects can also be used, for example, to know if one variable can be set as parent of some other variable
    System.out.println("Can a Gaussian variable be parent of Multinomial variable? " +
        (multinomialVar.getDistributionType().isParentCompatible(gaussianVar)));

    System.out.println("Can a Multinomial variable be parent of Gaussian variable? " +
        (gaussianVar.getDistributionType().isParentCompatible(multinomialVar)));

  }
}

代码示例来源:origin: amidst/toolbox

/**
 * Builds the DAG structure of a Naive Bayes classifier with a global hidden Gaussian variable.
 */
private void buildGlobalDAG(){
  Variables variables = new Variables(attributes);
  String className = attributes.getFullListOfAttributes().get(classIndex).getName();
  hiddenVars = new ArrayList<Variable>();
  for (int i = 0; i < this.numberOfGlobalVars ; i++) {
    hiddenVars.add(variables.newGaussianVariable("GlobalHidden_"+i));
  }
  Variable classVariable = variables.getVariableByName(className);
  this.globalDAG = new DAG(variables);
  for (Attribute att : attributes.getListOfNonSpecialAttributes()) {
    if (att.getName().equals(className))
      continue;
    Variable variable = variables.getVariableByName(att.getName());
    globalDAG.getParentSet(variable).addParent(classVariable);
    for (int i = 0; i < this.numberOfGlobalVars ; i++) {
      globalDAG.getParentSet(variable).addParent(hiddenVars.get(i));
    }
  }
  System.out.println(globalDAG.toString());
}

代码示例来源:origin: amidst/toolbox

Variable globalHiddenGaussian = modelHeader.newGaussianVariable("globalHiddenGaussian");

代码示例来源:origin: amidst/toolbox

Variable globalHiddenGaussian = modelHeader.newGaussianVariable("globalHiddenGaussian");

代码示例来源:origin: amidst/toolbox

/**
 * Builds the DAG over the set of variables given with the structure of the model
 */
@Override
protected void buildDAG() {
  String className = atts.getFullListOfAttributes().get(classIndex).getName();
  hiddenVars = new ArrayList<Variable>();
  for (int i = 0; i < this.numberOfGlobalVars ; i++) {
    hiddenVars.add(vars.newGaussianVariable("GlobalHidden_"+i));
  }
  Variable classVariable = vars.getVariableByName(className);
  dag = new DAG(vars);
  for (Attribute att : atts.getListOfNonSpecialAttributes()) {
    if (att.getName().equals(className))
      continue;
    Variable variable = vars.getVariableByName(att.getName());
    dag.getParentSet(variable).addParent(classVariable);
    if (this.globalHidden) {
      for (int i = 0; i < this.numberOfGlobalVars ; i++) {
        dag.getParentSet(variable).addParent(hiddenVars.get(i));
      }
    }
  }
}

代码示例来源:origin: amidst/toolbox

Variable globalHiddenGaussian = modelHeader.newGaussianVariable("globalHiddenGaussian");

代码示例来源:origin: amidst/toolbox

/**
 * Define the Fire Dectector Model's DAG.
 * @param attributes
 * @return
 */
public static DAG creatFireDectectorModel(Attributes attributes){
  /********** Model Definition ************/
  //Create the object handling the random variables of the model
  Variables variables = new Variables();
  //Create the random variables of the model. Some of them are associated to one attribute to retrieve its observed values from the data set.
  Variable fire = variables.newMultinomialVariable(attributes.getAttributeByName("Fire"));
  Variable temperature = variables.newGaussianVariable("Temperature");
  Variable smoke = variables.newMultinomialVariable("Smoke",2);
  Variable sensorT1 = variables.newGaussianVariable(attributes.getAttributeByName("SensorTemp1"));
  Variable sensorT2 = variables.newGaussianVariable(attributes.getAttributeByName("SensorTemp2"));
  Variable sensorSmoke = variables.newGaussianVariable(attributes.getAttributeByName("SensorSmoke"));
  //Create the directed acyclic graph object encoding the conditional independe relaionship among the variables of the model.
  DAG dag = new DAG(variables);
  //Define the parent set for each random variable
  dag.getParentSet(sensorT1).addParent(temperature);
  dag.getParentSet(sensorT2).addParent(temperature);
  dag.getParentSet(sensorSmoke).addParent(smoke);
  dag.getParentSet(temperature).addParent(fire);
  dag.getParentSet(smoke).addParent(fire);
  return dag;
}

代码示例来源:origin: amidst/toolbox

Variable temperatureBuilding = variables.newGaussianVariable("TemperatureBuilding");
  temperature[i] = variables.newGaussianVariable("Temperature_"+i);
  smoke[i] = variables.newMultinomialVariable("Smoke_"+i, 2);
  sensorT1[i] = variables.newGaussianVariable(attributes.getAttributeByName("SensorTemp1_"+i));
  sensorT2[i] = variables.newGaussianVariable(attributes.getAttributeByName("SensorTemp2_"+i));
  sensorSmoke[i] = variables.newGaussianVariable(attributes.getAttributeByName("SensorSmoke_"+i));

代码示例来源:origin: amidst/toolbox

/**
 * This method contains the code needed to build the NaiveBayes DAG with a global hidden variable modelling
 * concept drift.
 * @return A poperly created {@link DAG} object.
 * @throws Exception if an error occurs while reading the file.
 */
public static DAG modelBuilding() throws Exception {
  //We load the data for one month
  DataStream<DataInstance> instances = DataStreamLoader.open("./datasets/bnaic2015/BCC/Month0.arff");
  //Define the variables. By default, a random variable is created for each attribute
  Variables variables  = new Variables(instances.getAttributes());
  //We create a new global hidden Gaussian variable
  Variable hiddenGaussian = variables.newGaussianVariable("HiddenGaussian");
  //We get the variable Default
  Variable defaultVariable = variables.getVariableByName("default");
  //We define the DAG
  DAG dag = new DAG(variables);
  //We add the links of the DAG
  dag.getVariables()
      .getListOfVariables()
      .stream()
      .filter(var -> var != defaultVariable)
      .filter(var -> var != hiddenGaussian)
      .forEach(var -> {
        dag.getParentSet(var).addParent(defaultVariable);
        dag.getParentSet(var).addParent(hiddenGaussian);
      });
  return dag;
}

代码示例来源:origin: amidst/toolbox

.forEach(i -> variables.newGaussianVariable("GaussianVar" + i));
IntStream.rangeClosed(0, getNumHiddenGaussVars() - 1).forEach(i -> variables.newGaussianVariable("GaussianSPVar_" + i));

代码示例来源:origin: amidst/toolbox

.forEach(i -> variables.newGaussianVariable("GaussianVar" + i));
IntStream.rangeClosed(0, getNumHiddenGaussVars() - 1).forEach(i -> variables.newGaussianVariable("GaussianSPVar_" + i));

代码示例来源:origin: amidst/toolbox

public static BayesianNetwork createBN(int nVars) throws Exception {
  Variables dynamicVariables = new Variables();
  Variable classVar = dynamicVariables.newMultinomialVariable("C", 2);
  for (int i = 0; i < nVars; i++) {
    dynamicVariables.newGaussianVariable("A" + i);
  }
  DAG dag = new DAG(dynamicVariables);
  for (int i = 0; i < nVars; i++) {
    dag.getParentSet(dynamicVariables.getVariableByName("A" + i)).addParent(classVar);
  }
  dag.setName("dbn1");
  BayesianNetwork bn = new BayesianNetwork(dag);
  bn.randomInitialization(new Random(1));
  return bn;
}

代码示例来源:origin: amidst/toolbox

.forEach(i -> variables.newGaussianVariable("GaussianVar" + i));

代码示例来源:origin: amidst/toolbox

Variable temperature = variables.newGaussianVariable("Temperature");
Variable smoke = variables.newMultinomialVariable("Smoke",2);
Variable sensorT1 = variables.newGaussianVariable(attributes.getAttributeByName("SensorTemp1"));
Variable sensorT2 = variables.newGaussianVariable(attributes.getAttributeByName("SensorTemp2"));
Variable sensorSmoke = variables.newGaussianVariable(attributes.getAttributeByName("SensorSmoke"));

代码示例来源:origin: amidst/toolbox

.forEach(i -> modelHeader.newGaussianVariable("HiddenG_" + i));
if(getnOfStatesMultHiddenVar_() > 0)
  modelHeader.newMultinomialVariable("HiddenM", getnOfStatesMultHiddenVar_());

代码示例来源:origin: amidst/toolbox

Variable temperature = variables.newGaussianVariable("Temperature");
Variable smoke = variables.newMultinomialVariable("Smoke", 2);
Variable sensorT1 = variables.newGaussianVariable("SensorTemp1");
Variable sensorT2 = variables.newGaussianVariable("SensorTemp2");
Variable sensorSmoke = variables.newGaussianVariable("SensorSmoke");

代码示例来源:origin: amidst/toolbox

Variable temperature = variables.newGaussianVariable("Temperature");
Variable smoke = variables.newMultinomialVariable("Smoke", 2);
Variable sensorT1 = variables.newGaussianVariable("SensorTemp1");
Variable sensorT2 = variables.newGaussianVariable("SensorTemp2");
Variable sensorSmoke = variables.newGaussianVariable("SensorSmoke");

相关文章