eu.amidst.core.datastream.Attributes.getAttributeByName()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(134)

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

Attributes.getAttributeByName介绍

暂无

代码示例

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

public PlateauLDAFlink(Attributes attributes, String wordDocumentName, String wordCountName) {
  this.attributes = attributes;
  this.wordDocumentName = wordDocumentName;
  this.wordCountAtt = this.attributes.getAttributeByName(wordCountName);
}

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

public PlateauLDA(Attributes attributes, String wordDocumentName, String wordCountName) {
  this.attributes = attributes;
  this.wordDocumentName = wordDocumentName;
  this.wordCountAtt = this.attributes.getAttributeByName(wordCountName);
}

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

public static void process2(String[] args) throws IOException {
  DataStream<DataInstance> dataInstances = DataStreamLoader.open("/Users/andresmasegosa/Dropbox/Amidst/datasets/NFSAbstracts/docswords-joint.arff");
  double minWord = Double.MAX_VALUE;
  double maxWord = -Double.MAX_VALUE;
  for (DataInstance dataInstance : dataInstances) {
    double word = dataInstance.getValue(dataInstance.getAttributes().getAttributeByName("word"));
    if (minWord>word)
      minWord = word;
    if (maxWord<word)
      maxWord=word;
  }
  System.out.println(minWord);
  System.out.println(maxWord);
}

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

/**
 * Sets a new set of attributes. It links current variables with this new set by matching
 * variable names with attributes names.
 * @param attributes an object of class {@link Attributes}.
 */
public void setAttributes(Attributes attributes){
  for (Variable variable : nonInterfaceVariables) {
    VariableImplementation variableImplementation = (VariableImplementation)variable;
    variableImplementation.setAttribute(attributes.getAttributeByName(variable.getName()));
  }
  for (Variable variable : interfaceVariables) {
    VariableImplementation variableImplementation = (VariableImplementation)variable;
    variableImplementation.setAttribute(attributes.getAttributeByName(getVariableFromInterface(variable).getName()));
  }
}

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

inputAtts.add(dataAttributes.getAttributeByName("DiscreteVar0"));
inputAtts.add(dataAttributes.getAttributeByName("DiscreteVar1"));
inputAtts.add(dataAttributes.getAttributeByName("DiscreteVar2"));
List<Attribute> outputAtts = new ArrayList<>();
outputAtts.add(dataAttributes.getAttributeByName("GaussianVar0"));
outputAtts.add(dataAttributes.getAttributeByName("GaussianVar1"));
outputAtts.add(dataAttributes.getAttributeByName("GaussianVar2"));

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

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

    //Open the data stream using the class DynamicDataStreamLoader
    DataStream<DynamicDataInstance> data = DynamicDataStreamLoader.loadFromFile("datasets/simulated/exampleDS_d2_c3.arff");

    //Access the attributes defining the data stream
    System.out.println("Attributes defining the data set");
    for (Attribute attribute : data.getAttributes()) {
      System.out.println(attribute.getName());
    }
    Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0");

    //Iterate over dynamic data instances
    System.out.println("1. Iterating over samples using a for loop");
    for (DynamicDataInstance dataInstance : data) {
      System.out.println("SequenceID = "+dataInstance.getSequenceID()+", TimeID = "+dataInstance.getTimeID());
      System.out.println("The value of attribute discreteVar0 for the current data instance is: " +
          dataInstance.getValue(discreteVar0));
    }

  }
}

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

/**
 * This method contains an example about how to compute the monthly average value of one variable.
 * @throws Exception if an error occurs while reading the file.
 */
public static void computeMonthlyAverage() throws Exception {
  //For each month of the period
  for (int i = 0; i < MONTHS; i++) {
    //We load the data for that month
    DataStream<DataInstance> instances = DataStreamLoader.open("./datasets/bnaic2015/BCC/Month"+i+".arff");
    //We get the attribute credit
    Attribute credit = instances.getAttributes().getAttributeByName("credit");
    //We compute the average, using a parallel stream.
    double creditMonthlyAverage = instances
        .parallelStream(1000)
        .mapToDouble(instance -> instance.getValue(credit))
        .average()
        .getAsDouble();
    //We print the computed average
    System.out.println("Average Monthly Credit " + i + ": " + creditMonthlyAverage);
  }
}

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

Attribute att = data.getAttributes().getAttributeByName("GaussianVar0");
data.stream()
    .forEach(d->System.out.println(d.getValue(att)));

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

public static void main(String[] args) {

    //Generate the data stream using the class DataSetGenerator
    DataStream<DataInstance> data = DataSetGenerator.generate(1,10,5,5);

    //Filter example: print only instances such that DiscreteVar0 = 1.0
    data.filter(d -> d.getValue(data.getAttributes().getAttributeByName("DiscreteVar0")) == 1)
        .forEach(d -> System.out.println(d));

    //Map example: new DataStream in which each instance has been multiplyed by 10
    data.map(d -> {
      Attribute gaussianVar0 = d.getAttributes().getAttributeByName("GaussianVar0");
      d.setValue(gaussianVar0, d.getValue(gaussianVar0)*10);
      return d;
    }).forEach(d -> System.out.println(d));

  }
}

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

word = variables.newSparseMultionomialVariable(attributes.getAttributeByName(wordDocumentName));

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

word = variables.newSparseMultionomialVariable(attributes.getAttributeByName(wordDocumentName));

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

System.out.println(attribute.getName());
Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0");

代码示例来源: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

fire[i] = variables.newMultinomialVariable(attributes.getAttributeByName("Fire_"+i));
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

/**
 * In this example we show how to create an input-outputString KF with Gaussian mixtures (as in Figure 4.29 of Deliverable 2.1).
 */
public static void VerdandeInputOutputHMM() throws IOException {
  DataStream<DynamicDataInstance> data = DynamicDataStreamLoader.loadFromFile("datasets/simulated/syntheticDataVerdandeScenario3.arff");
  Attribute attDepth = data.getAttributes().getAttributeByName("depth");
  Attribute attGammaDiff = data.getAttributes().getAttributeByName("gammaDiff");
  DynamicVariables dynamicVariables = new DynamicVariables();
  Variable observedDepth = dynamicVariables.newDynamicVariable(attDepth);
  Variable observedGammaDiff = dynamicVariables.newDynamicVariable(attGammaDiff);
  Variable formationNo = dynamicVariables.newMultinomialLogisticDynamicVariable("FormationNo", 2);
  Variable shift = dynamicVariables.newMultinomialDynamicVariable("Shift",2);
  DynamicDAG dynamicDAG = new DynamicDAG(dynamicVariables);
  dynamicDAG.getParentSetTimeT(formationNo).addParent(observedDepth);
  dynamicDAG.getParentSetTimeT(formationNo).addParent(dynamicVariables.getInterfaceVariable(formationNo));
  //TODO Error trying to add a duplicate parent. A -> B <- Aclone. We are considering A and AClone the same variables? Is that right?
  dynamicDAG.getParentSetTimeT(shift).addParent(formationNo);
  //dynamicDAG.getParentSetTimeT(shift).addParent(dynamicVariables.getInterfaceVariable(formationNo));
  dynamicDAG.getParentSetTimeT(shift).addParent(dynamicVariables.getInterfaceVariable(shift));
  dynamicDAG.getParentSetTimeT(observedGammaDiff).addParent(shift);
  System.out.println("-------------------------------------\n");
  System.out.println("Input-outputString HMM (Figure 4.31 of D2.1)\n");
  System.out.println(dynamicDAG.toString());
  DynamicBayesianNetwork dbn = new DynamicBayesianNetwork(dynamicDAG);
  System.out.println(dbn.toString());
  DynamicBayesianNetworkWriter.save(dbn, "networks/simulated/HuginVerdandeIOHMM.dbn");
}

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

Variable fire = variables.newMultinomialDynamicVariable(attributes.getAttributeByName("Fire"));
Variable temperature = variables.newGaussianDynamicVariable("Temperature");
Variable smoke = variables.newMultinomialDynamicVariable("Smoke", 2);
Variable sensorT1 = variables.newGaussianDynamicVariable(attributes.getAttributeByName("SensorTemp1"));
Variable sensorT2 = variables.newGaussianDynamicVariable(attributes.getAttributeByName("SensorTemp2"));
Variable sensorSmoke = variables.newGaussianDynamicVariable(attributes.getAttributeByName("SensorSmoke"));

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

model.setClassVarID(data.getAttributes().getAttributeByName("DEFAULT").getIndex() + 2);
model.setParallelMode(true);
model.learn(data);

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

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"));

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

Attribute attTRQ = data.getAttributes().getAttributeByName("TRQ");
Attribute attROP = data.getAttributes().getAttributeByName("ROP");

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

Attribute attWOB = data.getAttributes().getAttributeByName("WOB");
Attribute attRPM = data.getAttributes().getAttributeByName("RPMB");
Attribute attMFI = data.getAttributes().getAttributeByName("MFI");
Attribute attTRQ = data.getAttributes().getAttributeByName("TRQ");
Attribute attROP = data.getAttributes().getAttributeByName("ROP");
Attribute attPRESSURE = data.getAttributes().getAttributeByName("PRESSURE");

相关文章